Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/wreyesus/Sencillo_Carrito_de_Compras_en_PHP/llms.txt

Use this file to discover all available pages before exploring further.

YUME|TEC relies on a small set of utility functions that appear repeatedly across its PHP pages. Some of these — most notably GetSQLValueString() and the pagination variable block — were generated by Dreamweaver’s server behaviors and are pasted verbatim into each page that needs them. Others, such as comparar_contra() and the session guard, were written by hand for specific interactions. Understanding where each one comes from and what it does is the fastest way to orient yourself in the codebase.

GetSQLValueString()

Dreamweaver’s server behaviors insert this helper into every page that constructs a parameterized SQL query. It sanitizes a raw PHP value and returns a string safe for direct interpolation into a MySQL query. The function is wrapped in if (!function_exists(...)) so that it can be pasted into multiple files that are all included on the same request without causing a fatal redeclaration error.
if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
    {
        if (PHP_VERSION < 6) {
            $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
        }

        $theValue = function_exists("mysql_real_escape_string")
            ? mysql_real_escape_string($theValue)
            : mysql_escape_string($theValue);

        switch ($theType) {
            case "text":
                $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
                break;
            case "long":
            case "int":
                $theValue = ($theValue != "") ? intval($theValue) : "NULL";
                break;
            case "double":
                $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
                break;
            case "date":
                $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
                break;
            case "defined":
                $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
                break;
        }
        return $theValue;
    }
}

Parameters

ParameterDescription
$theValueThe raw value to sanitize (typically from $_GET or $_POST)
$theTypeType hint controlling how the value is cast and quoted: "text", "int", "long", "double", "date", or "defined"
$theDefinedValueSubstituted when $theType is "defined" and the value is non-empty
$theNotDefinedValueSubstituted when $theType is "defined" and the value is empty
Returns: An escaped, appropriately quoted string safe for direct interpolation into a MySQL query. Numeric types are returned unquoted (42); text and date types are wrapped in single quotes ('value'); empty values for any type return the bare string NULL. A typical call in detalles.php reads the product ID from the query string:
$colname_detalle_proce = "-1";
if (isset($_GET['id_producto'])) {
    $colname_detalle_proce = $_GET['id_producto'];
}

$query_detalle_proce = sprintf(
    "SELECT * FROM productos WHERE id_producto = %s",
    GetSQLValueString($colname_detalle_proce, "int")
);
GetSQLValueString() relies on the legacy mysql_real_escape_string(), which requires an active mysql_* connection to be open at the time of the call. It falls back to mysql_escape_string() if the preferred function is not available. Both functions are removed in PHP 7 — see the PHP 7+ compatibility section for the migration path.

toolTip() JavaScript helper

The shopping cart page (carrito.php) calls a toolTip() function via inline onmouseover attributes on the update and delete image-buttons. The function reads the label text passed as its first argument and renders it into the adjacent <span id="toolTipBox"> element positioned next to the triggering element.
<span id="toolTipBox" width="200"></span>
<input type="image" src="imagenes/actualizar.gif"
       onmouseover="toolTip('Presione para actualizar su pedido', this)">
<span id="toolTipBox" width="200"></span>
<input type="image" src="imagenes/eliminar.gif"
       onmouseover="toolTip('Presione para eliminar su pedido', this)">
The toolTip() function itself is not defined within the repository source files — it was likely intended to be included from an external library or written as a small inline script block. If you need tooltip behavior, you can provide a minimal implementation directly in the page <head>:
<script type="text/javascript">
function toolTip(msg, el) {
    var box = document.getElementById('toolTipBox');
    if (box) { box.innerHTML = msg; }
}
</script>
The companion file funciones.js in the project root contains a jQuery-based login panel toggle helper — not the toolTip function — and is included by several pages that use the sliding #login-form panel:
$(function() {
    $('#login').toggle(function() {
        $('#login-form').slideDown();
    }, function() {
        $('#login-form').slideUp();
    });

    $('#usuario').focus(function() {
        $(this).val('');
    });

    $('#password').focus(function() {
        $(this).val('');
    });
});

Session guard pattern

Pages that require a logged-in user check for $_SESSION['usuario'] at the top of the file before any output. The guard used in resumenc_compra.php immediately redirects unauthenticated visitors to the registration/login page:
if (!isset($_SESSION['usuario'])) {
    header("location:nuevo_usuario.php?nologin=false");
}
Other pages — notably carrito.php — take a softer approach: they allow guests to view the page and only redirect to nuevo_usuario.php after a failed login attempt embedded in the same page. This means a guest can browse the cart but cannot proceed to checkout. The logout handler in cerrar_sesion.php completes the session lifecycle by clearing all session data and redirecting to the homepage:
<?php
    session_start();
    $_SESSION = array();
    session_destroy();
    header("location:index2.php?logout");
?>

Dreamweaver pagination variables

Each cat_*.php listing page uses a three-variable block inserted by Dreamweaver’s recordset paging server behavior. The variables control which page of results is fetched:
VariableDescription
$maxRows_listadoPage size, hardcoded to 9 on every category page
$pageNum_listadoCurrent page index read from $_GET['pageNum_listado']; defaults to 0 (first page)
$startRow_listadoRow offset for the SQL LIMIT clause, calculated as $pageNum_listado * $maxRows_listado
$maxRows_listado = 9;
$pageNum_listado = 0;
if (isset($_GET['pageNum_listado'])) {
    $pageNum_listado = $_GET['pageNum_listado'];
}
$startRow_listado = $pageNum_listado * $maxRows_listado;
The offset and page size are then injected directly into the query using sprintf():
$query_listado       = "SELECT * FROM productos WHERE id_cat=1";
$query_limit_listado = sprintf("%s LIMIT %d, %d", $query_listado, $startRow_listado, $maxRows_listado);
$listado             = mysql_query($query_limit_listado, $tienda) or die(mysql_error());
A second query runs against the same WHERE clause without a LIMIT to count total rows, allowing the template to compute $totalPages_listado and render previous/next pagination links.

comparar_contra()

The registration section of nuevo_usuario.php includes a small inline JavaScript function that compares the two password fields before the form is submitted. It is triggered by the onChange event on the confirmation password input:
function comparar_contra() {
    var contra1 = document.getElementById('contra1').value;
    var contra2 = document.getElementById('contra2').value;

    if (contra1 != contra2) {
        alert('Las contraseñas no coinciden');
    }
}
The confirmation field wires it up as:
<input type="password" name="contrasena_vali" id="contra2"
       onChange="javascript:comparar_contra(this.form)" />
This is a client-side convenience check only. The server-side registro.php handler does not independently verify that both password values match, so the check can be bypassed by submitting the form programmatically.

Build docs developers (and LLMs) love