Foros del Web » Programando para Internet » PHP »

Problemas con require e insertar registro

Estas en el tema de Problemas con require e insertar registro en el foro de PHP en Foros del Web. buenas.. estoy teniendo un problemita con require() a la hora de insertar un registro.. estoy haciendo una carga de datos con un formulario (formulario.php) cuya ...
  #1 (permalink)  
Antiguo 12/06/2009, 14:17
 
Fecha de Ingreso: marzo-2009
Mensajes: 14
Antigüedad: 15 años, 1 mes
Puntos: 0
Desacuerdo Problemas con require e insertar registro

buenas.. estoy teniendo un problemita con require() a la hora de insertar un registro.. estoy haciendo una carga de datos con un formulario (formulario.php) cuya accion apunta a otro php (validador.php), bueno, en validador.php hago la verificacion para que los campos del "formulario.php" no esten vacios, en caso de ser asi abro mediante require() el mismo (formulario.php) y muestro unos mensajes de error, y en caso que todo en el formulario se haya llenado correctamente abro un siguiente php mediante require()(confirmacion_de_carga.php) en el cual se muestran los datos que se han introducido en el formulario y se pregunta "son correctos los datos?", en el caso de ser positiva la respuesta se presiona "si" y ahi se deveria insertar el registro.. el sistema funciona, sin utilizar require() pero cuando lo llamo con require() ya no me inserta el registro y vuelve a "formulario.php". estoy haciendo esto con dreamweaver.. agradeceria me ayudaran a solucionar esto en PHP, de ser posible nada de java u otros lenguajes. muchas gracias.
  #2 (permalink)  
Antiguo 12/06/2009, 14:20
Avatar de abimaelrc
Colaborador
 
Fecha de Ingreso: mayo-2009
Ubicación: En el planeta de Puerto Rico
Mensajes: 14.734
Antigüedad: 14 años, 11 meses
Puntos: 1517
Respuesta: Problemas con require e insertar registro

trata con require_once(). Si no te es util escribe el original y luego escribe el que usas con require aca en el foro

me dejas saber
  #3 (permalink)  
Antiguo 12/06/2009, 14:29
 
Fecha de Ingreso: marzo-2009
Mensajes: 14
Antigüedad: 15 años, 1 mes
Puntos: 0
Respuesta: Problemas con require e insertar registro

ok, gracias por responder rapido.. no se me habia ocurrido escribir el original, lo voy a probar y les cuento..
  #4 (permalink)  
Antiguo 12/06/2009, 14:47
 
Fecha de Ingreso: marzo-2009
Mensajes: 14
Antigüedad: 15 años, 1 mes
Puntos: 0
Respuesta: Problemas con require e insertar registro

no me funciono de ninguna de las dos formas.. intente con require_once() y pegar todo el codigo de la insercion de registro y tampoco.. aca esta como lo estoy haciendo..

<?php

if ($_POST['nombre_txt']=="")
{
$error_nombre="Debe ingresar un nombre";
require ("registrar_juegos.php");
}

elseif ($_POST['version_txt']=="")
{
$error_version="Debe ingresar una version";
require ("registrar_juegos.php");
}

elseif ($_POST['descripcion_txt']=="")
{
$error_descripcion="Debe ingresar una descripcion";
require ("registrar_juegos.php");
}

else
{
require_once ("confirmar_registro_juego.php");
}
  #5 (permalink)  
Antiguo 12/06/2009, 14:48
Avatar de abimaelrc
Colaborador
 
Fecha de Ingreso: mayo-2009
Ubicación: En el planeta de Puerto Rico
Mensajes: 14.734
Antigüedad: 14 años, 11 meses
Puntos: 1517
Respuesta: Problemas con require e insertar registro

Si pero pon el codigo de todos de registrar_juegos.php y confirmar_registro_juego.php
  #6 (permalink)  
Antiguo 12/06/2009, 14:50
 
Fecha de Ingreso: marzo-2009
Mensajes: 14
Antigüedad: 15 años, 1 mes
Puntos: 0
Respuesta: Problemas con require e insertar registro

y este es el que llamo con require()..


<?php require_once('Connections/slc_base.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form_confirmar_registro")) {
$insertSQL = sprintf("INSERT INTO slc_registro_juegos (id_num, nombre_juego, version, tipo, plataforma, idioma, descripcion, obs) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['ins_num_txt'], "int"),
GetSQLValueString($_POST['ins_nombre_txt'], "text"),
GetSQLValueString($_POST['ins_version_txt'], "text"),
GetSQLValueString($_POST['ins_tipo_txt'], "text"),
GetSQLValueString($_POST['ins_plataforma_txt'], "text"),
GetSQLValueString($_POST['ins_idioma_txt'], "text"),
GetSQLValueString($_POST['ins_descripcion_txt'], "text"),
GetSQLValueString($_POST['ins_obs_txt'], "text"));

mysql_select_db($database_slc_base, $slc_base);
$Result1 = mysql_query($insertSQL, $slc_base) or die(mysql_error());

$insertGoTo = "registro_exitoso.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}

mysql_select_db($database_slc_base, $slc_base);
$query_reg_tipo_juego = "SELECT * FROM slc_tipo_juego ORDER BY id_num ASC";
$reg_tipo_juego = mysql_query($query_reg_tipo_juego, $slc_base) or die(mysql_error());
$row_reg_tipo_juego = mysql_fetch_assoc($reg_tipo_juego);
$totalRows_reg_tipo_juego = mysql_num_rows($reg_tipo_juego);

mysql_select_db($database_slc_base, $slc_base);
$query_reg_plataforma = "SELECT * FROM slc_plataforma ORDER BY id_num ASC";
$reg_plataforma = mysql_query($query_reg_plataforma, $slc_base) or die(mysql_error());
$row_reg_plataforma = mysql_fetch_assoc($reg_plataforma);
$totalRows_reg_plataforma = mysql_num_rows($reg_plataforma);

mysql_select_db($database_slc_base, $slc_base);
$query_reg_idioma = "SELECT * FROM slc_idioma ORDER BY id_num ASC";
$reg_idioma = mysql_query($query_reg_idioma, $slc_base) or die(mysql_error());
$row_reg_idioma = mysql_fetch_assoc($reg_idioma);
$totalRows_reg_idioma = mysql_num_rows($reg_idioma);
<style type="text/css">
<!--
.Estilo1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-weight: bold;
font-size: small;
}
.Estilo18 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: small; }
.Estilo19 {font-size: small}
.Estilo20 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: x-small; }
.Estilo22 {color: #FFFF99}
-->
</style>
</head>


<?php //ACA HACEMOS UN DO WHILE PARA QUE NOS CREE LOS IF'S QUE VAMOS A NECESITAR PARA TOMAR EL VALOR DEL LISTBOX TIPO DE JUEGO
do {
if ($_POST['tipo_juego']==$row_reg_tipo_juego['id_num'])
{
$var_tipo_juego=$row_reg_tipo_juego['tipo_juego'];
}
} while ($row_reg_tipo_juego = mysql_fetch_assoc($reg_tipo_juego));
?>

<?php //ACA HACEMOS UN DO WHILE PARA QUE NOS CREE LOS IF'S QUE VAMOS A NECESITAR PARA TOMAR EL VALOR DEL LISTBOX PLATAFORMA
do {
if ($_POST['plataforma']==$row_reg_plataforma['id_num'])
{
$var_plataforma=$row_reg_plataforma['plataforma'];
}
} while ($row_reg_plataforma = mysql_fetch_assoc($reg_plataforma));
?>

<?php //ACA HACEMOS UN DO WHILE PARA QUE NOS CREE LOS IF'S QUE VAMOS A NECESITAR PARA TOMAR EL VALOR DEL LISTBOX IDIOMA
do {
if ($_POST['idioma']==$row_reg_idioma['id_num'])
{
$var_idioma=$row_reg_idioma['idioma'];
}
} while ($row_reg_idioma = mysql_fetch_assoc($reg_idioma));
?>




<body>
<table width="286" height="34" border="0" align="center">
<tr>
<td><form action="<?php echo $editFormAction; ?>" id="form_confirmar_registro" name="form_confirmar_registro" method="POST">
<table width="286" border="0" bgcolor="#FFFF99">
<tr>
<td width="9">&nbsp;</td>
<td colspan="2"><div align="center" class="Estilo1">CONFIRMAR DATOS</div></td>
<td width="10">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td width="83"><span class="Estilo19"></span></td>
<td width="170"><span class="Estilo19"></span></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right" class="Estilo20">Nombre: </div></td>
<td><span class="Estilo20"><strong><?php echo $_POST['nombre_txt'];?></strong>&nbsp;</span></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right" class="Estilo20">Version:</div></td>
<td><span class="Estilo20"><strong><?php echo $_POST['version_txt'];?></strong>&nbsp;</span></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right" class="Estilo20">Tipo:</div></td>
<td><span class="Estilo20"><strong><?php echo $var_tipo_juego; ?></strong></span></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right" class="Estilo20">Plataforma:</div></td>
<td><span class="Estilo20"><strong><?php echo $var_plataforma; ?></strong></span></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right" class="Estilo20">Idioma:</div></td>
<td><span class="Estilo20"><strong><?php echo $var_idioma; ?></strong></span></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right" class="Estilo20">Descripcion:</div></td>
<td><span class="Estilo20"><strong><?php echo $_POST['descripcion_txt'];?></strong>&nbsp;</span></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align="right" class="Estilo20">Obs.:</div></td>
<td><span class="Estilo20"><strong><?php echo $_POST['obs_txt'];?></strong>&nbsp;</span></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><span class="Estilo19"></span></td>
<td><span class="Estilo19">
<input name="ins_num_txt" type="hidden" id="ins_nombre_txt" value=" " />
<label>
<input name="ins_nombre_txt" type="hidden" id="ins_nombre_txt" value="<?php echo $_POST['nombre_txt'];?>" />
</label>
<label>
<input name="ins_version_txt" type="hidden" id="ins_version_txt" value="<?php echo $_POST['version_txt'];?>" />
</label>
<label>
<input name="ins_tipo_txt" type="hidden" id="ins_tipo_txt" value="<?php echo $var_tipo_juego; ?>" />
</label>
<label>
<input name="ins_plataforma_txt" type="hidden" id="ins_plataforma_txt" value="<?php echo $var_plataforma; ?>" />
</label>
<label>
<input name="ins_idioma_txt" type="hidden" id="ins_idioma_txt" value="<?php echo $var_idioma; ?>" />
</label>
<label>
<input name="ins_descripcion_txt" type="hidden" id="ins_descripcion_txt" value="<?php echo $_POST['descripcion_txt'];?>" />
</label>
<label>
<input name="ins_obs_txt" type="hidden" id="ins_obs_txt" value="<?php echo $_POST['obs_txt'];?>" />
</label>
</span></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="2"><span class="Estilo18">Desea registrar los datos mostrados? </span></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="2"><label>
<div align="center">
<input type=button value=No onclick=document.location='principal_admin.php' />
<span class="Estilo22">.........</span>
<input type="submit" name="si_btn" id="si_btn" value="Si" />
</div>
</label></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="2">&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>

<input type="hidden" name="MM_insert" value="form_confirmar_registro" />
</form>
</td>
</tr>
</table>
</body>
</html>
  #7 (permalink)  
Antiguo 12/06/2009, 15:01
 
Fecha de Ingreso: marzo-2009
Mensajes: 14
Antigüedad: 15 años, 1 mes
Puntos: 0
Respuesta: Problemas con require e insertar registro

o en todo caso lo que necesitaria seria redireccionar a la pagina confirmar_datos.php y que se pasen los parametros que estan viniendo del formulario.php para luego asi insertar el registro, creo que el problema es con la pagina validar.php potque se queda en ella y ahi no inserta el registro, sin embargo si hago sin esta pagina intermedia y paso directamente del formulario.php a confirmar_datos.php si me inserta el registro.. alguien tiene alguna idea para redireccionar la pagina pero que se pasen los parametros que vienen del formulario.php?
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 16:25.