Código HTML:
<form action="<?php echo $editFormAction; ?>" method="post" enctype="application/x-www-form-urlencoded" name="form1" id="form1"> <div class="form-user"> <div class="form-user-title"><h2>Registrate</h2></div> <label for="nombre">Nombre:</label><br/> <span id="sprytextfield1"> <input type="text" name="nombre" id="nombre" value="" size="32"> <span class="textfieldRequiredMsg">Nombre no válido.</span></span><br/> <label for="email">Email:</label><br/> <span id="sprytextfield2"> <input type="text" name="email" id="email" value="" size="32"> <span class="textfieldRequiredMsg">Correo no válido.</span><span class="textfieldInvalidFormatMsg">Formato no válido.</span></span><br/> <label for="pass">Contraseña:</label><br/> <span id="sprytextfield3"> <input type="password" name="pass" id="pass" value="" size="32"> <span class="textfieldRequiredMsg">Contraseña no válida.</span></span><br/> <input name="button" id="button" type="submit" value="Registrarse"> <input type="hidden" name="MM_insert" value="form1"> </div> </form>
Código PHP:
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO usuario (nombre, email, pass) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['nombre'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['pass'], "text"));
mysql_select_db($database_connect_db, $connect_db);
$Result1 = mysql_query($insertSQL, $connect_db) or die(mysql_error());
$insertGoTo = "registro_completado.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}