Buenas a todos compis
Soy nuevo en el foro y querria haceros una consulta que me está volviendo loco.
Seguro es una chorrada pero no se xq pasa.
He creado un simple form de inserccion de un registro y lo he incluido mediante un include en otra página (se que en este ejemplo es absurdo, pero es para que lo veais fácil, y en mi proyecto me interesa para no ensuciar la index y incluir los forms de registro y identificación).
Todas las páginas estan en la misma raiz. Y si intento insertar un registro, me lo inserta correctamente en la BD pero no me redirige a la página (en este caso index).
En cambio si lo hago desde la pagina original, funciona perfectamente.
Es como si la funcion de*$insertGoTo = "index.php", no funcionara desde un include.
El código está creado con Dreamweaver, ya que no soy un lumbreras que digamos con php.
Adjunto los codigos de las dos páginas
Pagina del formulario:
Código PHP:
Ver original<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
}
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;
}
}
$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 tblusers (nombre, email, password) VALUES (%s, %s, %s)", GetSQLValueString($_POST['nombre'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['password'], "text"));
$insertGoTo = "index.php";
if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ?
"&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING'];
}
}
?>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Nombre:</td>
<td><input type="text" name="nombre" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Email:</td>
<td><input type="text" name="email" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Password:</td>
<td><input type="text" name="password" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><input type="submit" value="Insertar registro" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p> </p>
Y esta es la página con el include
Código PHP:
Ver original<?php require_once('Connections/conexionwhatoo.php'); ?>
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8" />
<title>prueba</title>
</head>
<body>
<div><?php include("prueba_form.php"); ?></div>
</body>
</html>
Muchas gracias y espero me deis con la solucion yaque me estoy volviendo loco