Tengo un pequeño problema que no puedo determinar qué lo produce. Ingreso al sistema (Paso 1) y me redirige a un formulario (Paso 2), ingreso los datos que me pide este formulario pero finalmente no graba en la base lo ingresado. El paso 1 trabaja con una base 1 y el formulario con una base 2. En la base_1 el id es la llave principal y en la base_2 el id es la llave foránea. Me sucede igual si en la base_1 asigno al “email” como llave principal y en la base_2 como llave foránea. Adjunto los scripts de ambos pasos así como el archivo de conexión (config.php). Les agradeceré mucho me den una mano, gracias desde ya.
ARCHIVO CONEXIÓN (config.php)
Código
<meta charset="utf-8" /> <?php PDO::ATTR_PERSISTENT => FALSE, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8', ); try { $DB = new PDO(DB_DRIVER . ':host=' . DB_SERVER . ';dbname=' . DB_DATABASE, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, $dboptions); } catch (Exception $ex) { echo $ex->getMessage(); die; } ?>
PASO 1: INGRESO AL SISTEMA (inreg1_2.php)
Código
<meta charset="utf-8" /> <?php require("config.php"); //if user already logged in redirect("logout.php"); } $errMSG = ""; //valiadte uerinput for security checks // add addslashes() function to prevent from sql injections if ($uemail == "" || $pass == "") { $errMSG = errorMessage("Ingrese sus Datos correctamente!"); } else { // check if username exist $sql = "SELECT * FROM dabas where email = :uemail"; try { $stmt = $DB->prepare($sql); $stmt->bindValue(":uemail", $uemail); $stmt->execute(); $emailRS = $stmt->fetchAll(); } catch (Exception $ex) { echo errorMessage($ex->getMessage()); } // user exist $sql = "SELECT * FROM dabas where email = :uemail AND pass = :pass"; try { $stmt = $DB->prepare($sql); $stmt->bindValue(":uemail", $uemail); $stmt->execute(); $userRS = $stmt->fetchAll(); } catch (Exception $ex) { echo errorMessage($ex->getMessage()); } // user exist // now check if the status of the user if ($userRS[0]["status"] == 'approved') { $_SESSION["email"] = $userRS[0]["email"]; if ($rem == 1) { // if user select to remember } else { } redirect("cuesti2_1.php"); } else { // user exist but the status is inactive $errMSG = errorMessage("Lo sentimos!!! Tu cuenta está temporalmente suspendida."); } } else { $errMSG = errorMessage("Los Datos ingresados son incorrectos."); } } else { // no user exist with same name $errMSG = errorMessage("El Correo@ ingresado no está registrado"); } } } ?> <!DOCTYPE html> <html> <style type="text/css"> #apDiv3 { position: absolute; width: 200px; height: 115px; z-index: 1; left: 745px; top: 535px; } </style> <head> <link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" /> <style type="text/css"> .letraCampos { font-family: Arial, Helvetica, sans-serif; font-size: 16px; color: #06C; height: 35px; width: 300px; } .letraBoton { font-family: Arial, Helvetica, sans-serif; font-size: 20px; color: #009; height: 40px; width: 200px; } .letratituolsgrande { font-family: "Swis721 LtCn BT"; font-size: 24px; font-weight: bold; color: #333; } #apDiv1 { position: absolute; width: 200px; height: 115px; z-index: 1; } #apDiv16 { position: absolute; width: 172px; height: 30px; z-index: 14; left: 548px; top: 506px; font-family: "Swis721 LtCn BT"; font-size: 18px; font-weight: normal; color: #666; } #apDiv18 { position: absolute; width: 200px; height: 26px; z-index: 25; left: 550px; top: 456px; font-family: "Swis721 LtCn BT"; font-size: 12px; color: #F00; } .linkLetras { font-family: "Swis721 LtCn BT"; font-size: 14px; color: #999; } #apDiv2 { position: absolute; width: 271px; height: 29px; z-index: 26; left: 550px; top: 505px; font-family: "Swis721 LtCn BT"; font-size: 20px; font-weight: bold; color: #009; } .letrasIngreso { font-family: "Swis721 LtCn BT"; font-size: 18px; color: #009; } </style> <title></title> </head> <body> <div id="container"> <div class="container"> <header></header> <article><br><br> <form method="post" action="" name="form1"> <input type="hidden" value="login" name="mode" /> <div class="loginbox"> </style><div class="container"> <div class="row" style="display: block; margin-top: 120px; margin-left: 450px; vertical-align: middle; color: #0066CC; font-size: 16px; font-family: Arial, Helvetica, sans-serif; width: 500px; height: 40px; text-align: left;"> <div style="height: 400px; clear: both; text-align: center; border-color: #999; border-bottom-width: thin; border-left-width: thin; border-right-width: thin; border-top-width: thin; border-style: solid; width: 500px; margin-top: -50px;"> <div style="height: 20px;clear: both"></div> <p class="letratituolsgrande">Inicio de sesión</p> <div style="height: 10px;clear: both"></div> <div class="col_left"></div><div class="col_right"><span class="letraCampos"> <input type="text" name="uemail" value="<?php echo $userame; ?>" placeholder="Ingresa tu correo@" maxlength="50" autocomplete="off" class="letraCampos" required /> </span></div> <div style="height: 20px;clear: both"></div> <div class="col_left"></div><div class="col_right"><span class="letraCampos"><span class="letraCampos"> <input type="password" name="upass" placeholder="Ingresa tu Contraseña" maxlength="40" value="" class="letraCampos" required /> </span></span></div> <div class="height10"></div> <div class="col_left"> </div><div class="letraCampos"><label for="remember_me"><input type="checkbox" value="1" name="remember_me" <?php echo ($userame != "") ? 'checked' : ''; ?>> Recordarme </label> </div> <div class="height10"></div> <div class="col_left"> </div><div class="col_right"><span class="letraBoton"><span class="letraBoton"> <input type="submit" name="sub" value="Ingresar" class="letraBoton" /> <div class="linkLetras" style="height: 40px;clear: both"> <p>¿Olvidaste tu Contraseña?</p> </style> </div> </span></span></div> <div class="height10"></div> </div> </form> </article> </div></div> <div id="apDiv3"><a href="index.php">REGÍSTRATE GRATIS AQUÍ</a></div> </body> </html> [b]PASO 2: INGRESO DATOS AL FORMULARIO (inreg1_2.php)[/b] <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Datos form 1 de 4</title> </head> <body> <?php //including the database connection file include_once("config.php"); $sql = "INSERT INTO profile(email, pp_yo, pp_pi) VALUES(:email, :pp_yo, :pp_pi)"; //$query = $dbConn->prepare($sql); $stmt = $DB->prepare($sql); $stmt->bindValue(':email', $email, PDO::PARAM_STR); $stmt->bindValue(':pp_yo', $pp_yo, PDO::PARAM_STR); $stmt->bindValue(':pp_pi', $pp_pi, PDO::PARAM_STR); $stmt->execute(); echo "<font color='green'>Los Datos ingresaron correctamente"; echo "<br/><a href='bien_regis.html'></a>"; } ?> <style type="text/css"> .letraCampos { font-family: Arial, Helvetica, sans-serif; font-size: 16px; color: #06C; height: 35px; width: 400px; margin-top: 20px; text-align: left; } .letraBoton { font-family: Arial, Helvetica, sans-serif; font-size: 20px; color: #009; height: 40px; width: 300px; text-align: center; margin-left: 0px; } #apDiv1 { position: absolute; width: 200px; height: 115px; z-index: 1; left: 53px; top: 16px; } .ContenedorMargen { padding: 60px; } .letratituolsgrande { color: #333; font-family: "Swis721 LtCn BT"; font-size: 24px; font-weight: bold; text-align: center; } .LetrasPequeñas { font-family: Arial, Helvetica, sans-serif; font-size: 14px; color: #666; } #apDiv2 { position: absolute; width: 200px; height: 115px; z-index: 1; left: 136px; top: 204px; font-family: "Swis721 LtCn BT"; font-size: 24px; } </style><div class="container"> <div class="row" style="display: block; margin-top: 120px; margin-left: 450px; vertical-align: middle; color: #0066CC; font-size: 16px; font-family: Arial, Helvetica, sans-serif; width: 500px; height: 40px; text-align: left;"> <div class="col-lg-6"> <div class="well contact-form-container"> <form class="form-horizontal contactform" action="cuesti2_1.php" method="post" name="f" onSubmit="return validateForm();"> <fieldset> <div class="form-group"> <div style="height: 850px; clear: both; text-align: center;"> <p class="letratituolsgrande">Ingresa los Datos requeridos</p> <div class="row"> <div class="col-md-3 col-md-offset-3"></div> <?php echo $_SESSION['email'];?> <span class="letraCampos"> <label class="col-lg-12 control-label" for="upp_yo"> <textarea name="upp_yo" cols="60" rows="7" class="letraCampos" id="upp_yo" placeholder="Cuéntanos sobre ti"></textarea> </label> </span><span style="text-align: center"></span></div> <div class="form-group"> <label class="letraCampos" for="upp_pi"> <textarea name="upp_pi" cols="60" rows="7" class="letraCampos" id="upp_pi" placeholder="Describe a la persona que buscas"></textarea> </label> </div> <div style="height: 30px;clear: both"></div> <div class="form-group"> <div class="col-lg-10"> <button class="letraBoton" type="submit" name="sub">Graba tus datos</button> </div> <div style="height: 40px;clear: both"></div> </div> </fieldset> </form> </div> </div> </div> </div> <div id="apDiv2"> <p>Estás en el primer paso:</p> <p>1 de 4</p> </div> </body> </html>[/c ode] [b]Mod: Los temas de PHP van al subforo de PHP.[/b]