Foros del Web » Programando para Internet » PHP »

Saltar a otra pagina

Estas en el tema de Saltar a otra pagina en el foro de PHP en Foros del Web. Buenas que tal, tengo una dudilla. Tengo este codigo que introduce unos campos en una BBDD. Lo que quiero es que una vez se almacene ...
  #1 (permalink)  
Antiguo 19/05/2008, 15:37
 
Fecha de Ingreso: mayo-2008
Ubicación: Barcelona
Mensajes: 249
Antigüedad: 15 años, 11 meses
Puntos: 1
Busqueda Saltar a otra pagina

Buenas que tal, tengo una dudilla. Tengo este codigo que introduce unos campos en una BBDD. Lo que quiero es que una vez se almacene esta inforamción, el php nos envie a una pagina llamada agradecimientos.php


CODIGO


<?php


function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")

{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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;
}

$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 animales (id_perro, `nombre`, area,
VALUES (%s, %s, %s)",

GetSQLValueString($_POST['id_perro'], "int"),
GetSQLValueString($_POST['nombre'], "text"),
GetSQLValueString($_POST['area'], "text"));

mysql_select_db($database_infoper, $infoper);
$Result1 = mysql_query($insertSQL, $infoper) or die(mysql_error());
}
?>
  #2 (permalink)  
Antiguo 19/05/2008, 16:22
Avatar de ferbux  
Fecha de Ingreso: mayo-2007
Ubicación: por ahí intentado ayudar
Mensajes: 823
Antigüedad: 16 años, 11 meses
Puntos: 6
Respuesta: Saltar a otra pagina

Hola puedes poner algo asi:

Código:
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO animales (id_perro, `nombre`, area, 
VALUES (%s, %s, %s)",

if(!empty($insertSQL)){
	        echo "<script languaje=javascript>".
            "alert(\"Tu datos fueron ingresados correctamente!\");".
            "location.href=\"pag.php\";".
            "</script>";
}
SALDU2
__________________
"Eres grande por que caminas entre gigantes"
  #3 (permalink)  
Antiguo 19/05/2008, 16:31
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: Saltar a otra pagina

http://php.net/header

location: URL

... a estudiar!
  #4 (permalink)  
Antiguo 19/05/2008, 16:31
 
Fecha de Ingreso: septiembre-2007
Mensajes: 83
Antigüedad: 16 años, 7 meses
Puntos: 0
Respuesta: Saltar a otra pagina

bueno para solucionar tu problema podrias imprimir tus varables en esa pagina... o redireccionar a una nueva pagina pasando las variables a insertar

Código PHP:
function GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue "")

{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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;
}

$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 animales (id_perro, `nombre`, area,
VALUES (%s, %s, %s)"
,

GetSQLValueString($_POST['id_perro'], "int"),
GetSQLValueString($_POST['nombre'], "text"),
GetSQLValueString($_POST['area'], "text"));

mysql_select_db($database_infoper$infoper);
$Result1 mysql_query($insertSQL$infoper) or die(mysql_error());

header("Location: agradecimentos.php?valor1=$_POST['id_perro']&...")
}

?> 
seria mas o menos asi...
y cuando lo recojas en la otra pagina seria asi...

Código PHP:
 print "Primer valor:"." ".$_REQUEST['valor1']; 
la idea seria mas o menos asi
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 12:18.