coppens Posted July 27, 2015 Share Posted July 27, 2015 I have a form that asks the user to input the business name and address. A hidden field assigns the user a ChildcareID for the childcare table. This is the relational key in the 'user' table. I have been trying for days to have the childcareID transfer to the next form whereby the user enters their personal information. I can not see where I am going wrong. I apologize now, I am learning how to code and will post both pages here. Thank you so much for your help. I am very grateful. Page 1 <?php session_start(); ?> <?php require_once('../Connections/Connect.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $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"] == "form1")) { $insertSQL = sprintf("INSERT INTO childcareinfo (ChildcareName, ChildcareAddress, ChildcareCity, ChildcareProvince, ChildcarePostalCode, ChildcareTelephone, Fax, ChildcareEmail) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['BusinessName'], "text"), GetSQLValueString($_POST['Address'], "text"), GetSQLValueString($_POST['City'], "text"), GetSQLValueString($_POST['Province'], "text"), GetSQLValueString($_POST['PostalCode'], "text"), GetSQLValueString($_POST['Telephone'], "text"), GetSQLValueString($_POST['CellPhone'], "int"), GetSQLValueString($_POST['Email'], "text")); mysql_select_db($database_Connect, $Connect); $Result1 = mysql_query($insertSQL, $Connect) or die(mysql_error()); $insertGoTo = "AdminRegistration.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } mysql_select_db($database_Connect, $Connect); $query_Childcare = "SELECT * FROM childcareinfo"; $Childcare = mysql_query($query_Childcare, $Connect) or die(mysql_error()); $row_Childcare = mysql_fetch_assoc($Childcare); $totalRows_Childcare = mysql_num_rows($Childcare); ?> <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title>Registration - Childcare Connect</title> <link rel="stylesheet" type="text/css" href="../css/style.css" /> <link href="../SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css"> <!--[if IE 6]> <link rel="stylesheet" type="text/css" href="css/ie6.css" /> <![endif]--> <script src="../SpryAssets/SpryValidationTextField.js" type="text/javascript"></script> <script type="text/javascript"> function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } </script> </head> <body> <div id="header"> <div> <a href="../index.php"><img src="../images/logo.gif" alt="Logo" width="199" height="82" /></a> <ul> <li><a href="../ConnectHome.php">Home</a></li> <li class="current"><a href="AnitasAnimalArk/AnimalAdminConsole.php">Back</a></li> <li><a href="../LogOut.php">Log Out</a></li> <li><a href="../contact.html">Contact us</a></li> </ul> </div> </div> <div class="content"> <div> <div> <table width="960" height="463" border="0" background="../images/UserRegistration.gif"> <tr> <td width="747" height="30"> </td> <td width="203"> </td> </tr> <tr> <td height="427"> </td> <td> </td> </tr> </table> </div> <div> <table> <tr> <td rowspan="2" align="center" valign="top"><div id="sidebar"> <h3>Instructions</h3> <ul> <li id="vision"> <span><a href="../LogoUpload.php">Profile Logo Upload</a></span> <p>Click the above 'Profile Logo Upload' link to upload a Profile Logo for the Childcare, School, Club, or Camp.</p> </li> <li id="mission"> <span>Our Mission</span> <p> </p> </li> <li id="wecare"> <span>We care</span> <p> </p> </li> </ul> </div></td> <td align="left" valign="top"><table width="100%" border="0" align="right"> <tr align="left"> <td align="center"><h3><u>Business Registration</u></h3></td> </tr> </table></td> </tr> <tr> <td width="630" align="right" valign="top"><table width="100%" border="4" align="right" bordercolor="#FFB33B"> <tr> <td align="right"> <form action="<?php echo $editFormAction; ?>" name="form1" method="POST" input type="submit"> <table border="0" align="center"> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2" align="center">Business Name:<br> <span id="sprytextfield3"> <label for="BusinessName"></label> <input type="text" name="BusinessName" id="BusinessName"> <span class="textfieldRequiredMsg">A value is required.</span></span></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"><span id="sprytextfield1"> <label for="Address">Address:<br> </label> <input name="Address" type="text" id="Address"> <span class="textfieldRequiredMsg">A value is required.</span></span></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td><span id="sprytextfield2"> <label for="City">City:</label> <br> <input name="City" type="text" id="City"> <span class="textfieldRequiredMsg">A value is required.</span></span></td> <td><span id="sprytextfield8"> <label for="Province">Province:</label> <input name="Province" type="text" id="Province"> <span class="textfieldRequiredMsg">A value is required.</span></span></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td><span id="sprytextfield9"> <label for="PostalCode7">PostalCode</label> :<br> <input type="text" name="PostalCode" id="PostalCode7"> <span class="textfieldRequiredMsg">A value is required.</span></span></td> <td> </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td><span id="sprytextfield10"> <label for="Telephone">Telephone:</label> <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span><span id="sprytextfield12"> <label for="Telephone"></label> <input type="text" name="Telephone" id="Telephone"> <span class="textfieldRequiredMsg">A value is required.</span></span></td> <td><span id="sprytextfield11"><span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span><span id="sprytextfield13"> <label for="CellPhone"></label> Fax:<br> <input type="text" name="CellPhone" id="CellPhone"> <span class="textfieldRequiredMsg">A value is required.</span></span></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"><span id="sprytextfield5"> <label for="Email3">Email:</label> <br> <input name="Email" type="text" id="Email"> <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"><input type="submit" name="RegisterUser" id="RegisterUser" value="Register User"></td> </tr> </table> <input type="hidden" name="MM_insert" value="form1"> </form></td> </tr> </table></td> </tr> </table> </div> </div> </div> <div id="footer"> <div> <div> <span>Follow us</span> <a href="http://facebook.com/childcareconnect" target="_blank" class="facebook">Facebook</a> <a href="#" class="subscribe">Subscribe</a></div> <ul> <li> <a href="#"><img src="../images/playing-in-grass.gif" alt="Image" /></a> <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna.</p> <a href="#" class="readmore">Read more</a> </li> <li> <a href="#"><img src="../images/baby-smiling.gif" alt="Image" /></a> <p>Sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud.</p> <a href="#" class="readmore">Read more</a> </li> </ul> </div> <p class="footnote">© Childcare Connect. All Rights Reserved.</p> </div> <script type="text/javascript"> var sprytextfield5 = new Spry.Widget.ValidationTextField("sprytextfield5", "email"); var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1"); var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2"); var sprytextfield8 = new Spry.Widget.ValidationTextField("sprytextfield8"); var sprytextfield10 = new Spry.Widget.ValidationTextField("sprytextfield10", "phone_number", {format:"phone_custom", pattern:"123-456-7890", hint:"123-456-7890"}); var sprytextfield11 = new Spry.Widget.ValidationTextField("sprytextfield11", "phone_number", {format:"phone_custom", pattern:"123-456-7890", hint:"123-456-7890"}); var sprytextfield12 = new Spry.Widget.ValidationTextField("sprytextfield12"); var sprytextfield13 = new Spry.Widget.ValidationTextField("sprytextfield13"); var sprytextfield9 = new Spry.Widget.ValidationTextField("sprytextfield9"); var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3"); </script> </body> </html> <?php mysql_free_result($Childcare); mysql_free_result($ChildcareRegistration); mysql_free_result($Users); mysql_free_result($ChildcareID); ?> Page 2 <?php session_start(); ?> <?php require_once('../Connections/Connect.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $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"] == "form1")) { $insertSQL = sprintf("INSERT INTO users (ChildcareID, FirstName, LastName, UserAddress, City, Province, PostalCode, Telephone, CellPhone, Email, UserName, Password, UserLevel) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['ChildcareID'], "int"), GetSQLValueString($_POST['FirstName'], "text"), GetSQLValueString($_POST['LastName'], "text"), GetSQLValueString($_POST['Address'], "text"), GetSQLValueString($_POST['City'], "text"), GetSQLValueString($_POST['Province'], "text"), GetSQLValueString($_POST['PostalCode'], "text"), GetSQLValueString($_POST['Telephone'], "text"), GetSQLValueString($_POST['CellPhone'], "text"), GetSQLValueString($_POST['Email'], "text"), GetSQLValueString($_POST['UserName'], "text"), GetSQLValueString($_POST['Password'], "text"), GetSQLValueString($_POST['UserLevel'], "text")); mysql_select_db($database_Connect, $Connect); $Result1 = mysql_query($insertSQL, $Connect) or die(mysql_error()); $insertGoTo = "../ConnectHome.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } $colname_Childcare = "-1"; if (isset($_GET['ChildcareID'])) { $colname_Childcare = $_GET['ChildcareID']; } mysql_select_db($database_Connect, $Connect); $query_Childcare = sprintf("SELECT * FROM childcareinfo WHERE ChildcareID = %s", GetSQLValueString($colname_Childcare, "int")); $Childcare = mysql_query($query_Childcare, $Connect) or die(mysql_error()); $row_Childcare = mysql_fetch_assoc($Childcare); $totalRows_Childcare = mysql_num_rows($Childcare);$colname_Childcare = "-1"; if (isset($_GET['ChildcareID'])) { $colname_Childcare = $_GET['ChildcareID']; } mysql_select_db($database_Connect, $Connect); $query_Childcare = sprintf("SELECT * FROM childcareinfo WHERE ChildcareID = %s", GetSQLValueString($colname_Childcare, "int")); $Childcare = mysql_query($query_Childcare, $Connect) or die(mysql_error()); $row_Childcare = mysql_fetch_assoc($Childcare); $totalRows_Childcare = mysql_num_rows($Childcare); session_start(); ?> <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title>Registration - Childcare Connect</title> <link rel="stylesheet" type="text/css" href="../css/style.css" /> <link href="../SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css"> <!--[if IE 6]> <link rel="stylesheet" type="text/css" href="css/ie6.css" /> <![endif]--> <script src="../SpryAssets/SpryValidationTextField.js" type="text/javascript"></script> <script type="text/javascript"> function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } </script> </head> <body> <div id="header"> <div> <a href="../index.php"><img src="../images/logo.gif" alt="Logo" width="199" height="82" /></a> <ul> <li><a href="../ConnectHome.php">Home</a></li> <li class="current"><a href="AnitasAnimalArk/AnimalArk.php">Back</a></li> <li><a href="../LogOut.php">Log Out</a></li> <li><a href="../contact.html">Contact us</a></li> </ul> </div> </div> <div class="content"> <div> <div> <table width="960" height="463" border="0" background="../images/UserRegistration.gif"> <tr> <td width="747" height="30"> </td> <td width="203"> </td> </tr> <tr> <td height="427"> </td> <td> </td> </tr> </table> </div> <div> <table width="100%" border="0"> <tr> <td width="320" rowspan="2" align="center" valign="top"><div id="sidebar"> <h3>Our Education</h3> <ul> <li id="vision"> <span>Our Vision</span> <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim venia.</p> </li> <li id="mission"> <span>Our Mission</span> <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim venia.</p> </li> <li id="wecare"> <span>We care</span> <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim venia.</p> </li> </ul> </div></td> <td align="right" valign="top"><table width="100%" height="66" border="0" align="right"> <tr> <td height="62" align="center">User Registration</td> </tr> </table></td> </tr> <tr> <td width="630" align="right" valign="top"><table width="100%" border="4" align="right" bordercolor="#FFB33B"> <tr> <td align="right"><form action="<?php echo $editFormAction; ?>" name="form1" method="POST"> <table width="600" border="0" align="center"> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2" align="center"><span id="sprytextfield3"> <label for="FirstName">First Name:<br> </label> <input name="FirstName" type="text" id="FirstName"> <span class="textfieldRequiredMsg">A value is required.</span></span></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"><span id="sprytextfield4"> <label for="LastName4">Last Name:</label> <br> <input name="LastName" type="text" id="LastName"> <span class="textfieldRequiredMsg">A value is required.</span></span></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"><span id="sprytextfield1"> <label for="Address">Address:</label> <br> <input name="Address" type="text" id="Address"> <span class="textfieldRequiredMsg">A value is required.</span></span></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td width="245"><span id="sprytextfield2"> <label for="City">City:<br> </label> <input name="City" type="text" id="City"> <span class="textfieldRequiredMsg">A value is required.</span></span></td> <td width="245"><span id="sprytextfield8"> <label for="Province">Province:</label> <input name="Province" type="text" id="Province"> <span class="textfieldRequiredMsg">A value is required.</span></span></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td><span id="sprytextfield9"> <label for="PostalCode">Postal Code:</label> <input name="PostalCode" type="text" id="PostalCode"> <span class="textfieldRequiredMsg">A value is required.</span></span></td> <td> </td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td><span id="sprytextfield10"> <label for="Telephone">Telephone:</label> <input name="Telephone" type="text" id="Telephone"> <span class="textfieldRequiredMsg">A value is required.</span></span></td> <td><span id="sprytextfield11"> <label for="CellPhone">Cell Phone:</label> <input name="CellPhone" type="text" id="CellPhone"> <span class="textfieldRequiredMsg">A value is required.</span></span></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2"><span id="sprytextfield5"> <label for="Email3">Email:</label> <br> <input name="Email" type="text" id="Email"> <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td><span id="sprytextfield6"> <label for="UserName3">User Name:</label> <br> <input name="UserName" type="text" id="UserName"> <span class="textfieldRequiredMsg">A value is required.</span></span></td> <td><span id="sprytextfield7"> <label for="Password">Password:</label> <input name="Password" type="text" id="Password"> <span class="textfieldRequiredMsg">A value is required.</span></span><br> <span class="textfieldRequiredMsg">A value is required.</span></td> </tr> <tr> <td height="34" colspan="2"><input name="UserLevel" type="hidden" id="UserLevel" value="2"> <input name="ChildcareID" type="hidden" id="ChildcareID" value="<?php echo $row_Childcare['ChildcareID']; ?>"></td> </tr> <tr> <td height="62" colspan="2"><input type="submit" name="RegisterUser" id="RegisterUser" value="Register User"></td> </tr> </table> <input type="hidden" name="MM_insert" value="form1"> </form></td> </tr> </table></td> </tr> </table> </div> </div> </div> <div id="footer"> <div> <div> <span>Follow us</span> <a href="http://facebook.com/childcareconnect" target="_blank" class="facebook">Facebook</a> <a href="#" class="subscribe">Subscribe</a></div> <ul> <li> <a href="#"><img src="../images/playing-in-grass.gif" alt="Image" /></a> <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna.</p> <a href="#" class="readmore">Read more</a> </li> <li> <a href="#"><img src="../images/baby-smiling.gif" alt="Image" /></a> <p>Sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud.</p> <a href="#" class="readmore">Read more</a> </li> </ul> </div> <p class="footnote">© Childcare Connect. All Rights Reserved.</p> </div> <script type="text/javascript"> var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3"); var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4"); var sprytextfield5 = new Spry.Widget.ValidationTextField("sprytextfield5", "email"); var sprytextfield6 = new Spry.Widget.ValidationTextField("sprytextfield6"); var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1"); var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2"); var sprytextfield8 = new Spry.Widget.ValidationTextField("sprytextfield8"); var sprytextfield9 = new Spry.Widget.ValidationTextField("sprytextfield9"); var sprytextfield10 = new Spry.Widget.ValidationTextField("sprytextfield10", "none"); var sprytextfield11 = new Spry.Widget.ValidationTextField("sprytextfield11"); var sprytextfield7 = new Spry.Widget.ValidationTextField("sprytextfield7"); </script> </body> </html> <?php mysql_free_result($Users); mysql_free_result($Childcare); ?> Thank you! Link to comment https://forums.phpfreaks.com/topic/297492-passing-form-variable-into-a-new-form/ Share on other sites More sharing options...
Ch0cu3r Posted July 27, 2015 Share Posted July 27, 2015 There is nothing in the code for page 1 which sets or gets the childcareid? Can you tell use what/where the childcareid is? Link to comment https://forums.phpfreaks.com/topic/297492-passing-form-variable-into-a-new-form/#findComment-1517471 Share on other sites More sharing options...
coppens Posted July 27, 2015 Author Share Posted July 27, 2015 ChildcareID is the primary key. When the information in page 1 is entered, it populates the childcareinfo table in the database. I would like page 2 to retrieve the ChildcareID (primary key) from the childcareinfo table and enter this information into the hidden field on Page 2. Thank you for your help. Link to comment https://forums.phpfreaks.com/topic/297492-passing-form-variable-into-a-new-form/#findComment-1517478 Share on other sites More sharing options...
Ch0cu3r Posted July 27, 2015 Share Posted July 27, 2015 ChildcareID is the primary key If it is also auto_increment then you maybe able to change $insertGoTo = "AdminRegistration.php"; to be $newChildcareId = mysql_insert_id(); $insertGoTo = "AdminRegistration.php?ChildcareID=$newChildcareId"; BTW In page2 you have duplicated code on lines 68 to 84, you only need to the code that is on lines 68 to 76 Link to comment https://forums.phpfreaks.com/topic/297492-passing-form-variable-into-a-new-form/#findComment-1517481 Share on other sites More sharing options...
coppens Posted July 27, 2015 Author Share Posted July 27, 2015 You did it! I am so grateful. Thank you so much! Link to comment https://forums.phpfreaks.com/topic/297492-passing-form-variable-into-a-new-form/#findComment-1517483 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.