sandbudd Posted May 26, 2009 Share Posted May 26, 2009 Hey guys have a rather simple form that populates the database but when it goes to the thank you page it displays the wrong person? Don't know if I need a session or what? Thanks in advance. form <?php require_once('Connections/mastodon.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"] == "form1")) { $insertSQL = sprintf("INSERT INTO mastodon (name, email, bday_month, bday_day, ann_month, ann_day, address, city, `state`, zip, favorite, lunch, reservations, parties, new_menu, chef_specials) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['name'], "text"), GetSQLValueString($_POST['email'], "text"), GetSQLValueString($_POST['bday_month'], "text"), GetSQLValueString($_POST['bday_day'], "text"), GetSQLValueString($_POST['ann_month'], "text"), GetSQLValueString($_POST['ann_day'], "text"), GetSQLValueString($_POST['address'], "text"), GetSQLValueString($_POST['city'], "text"), GetSQLValueString($_POST['state'], "text"), GetSQLValueString($_POST['zip'], "text"), GetSQLValueString($_POST['favorite'], "text"), GetSQLValueString($_POST['lunch'], "text"), GetSQLValueString($_POST['reservations'], "text"), GetSQLValueString($_POST['parties'], "text"), GetSQLValueString($_POST['new_menu'], "text"), GetSQLValueString($_POST['chef_specials'], "text")); mysql_select_db($database_mastodon, $mastodon); $Result1 = mysql_query($insertSQL, $mastodon) or die(mysql_error()); $insertGoTo = "thankyou.php"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } mysql_select_db($database_mastodon, $mastodon); $query_Recordset1 = "SELECT * FROM mastodon"; $Recordset1 = mysql_query($query_Recordset1, $mastodon) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); ?> <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1"> <table width="100%" align="center" cellpadding="3" bgcolor="#CCFF99"> <tr> <td colspan="2"><div align="center" class="style40"><span class="style34">Sign up now for Special Offers,<br /> Discounts and Club Memberships</span> <hr /> </div></td> </tr> <tr valign="baseline"> <td width="19%" align="left" valign="top" nowrap="nowrap"><span class="style38 style40">Name</span></td> <td width="81%" align="left" valign="top"><input name="name" type="text" class="style39 style40" value="" size="32" /></td> </tr> <tr valign="baseline"> <td align="left" valign="top" nowrap="nowrap"><span class="style38 style40">Email</span></td> <td align="left" valign="top"><input name="email" type="text" class="style39 style40" value="" size="32" /></td> </tr> <tr bgcolor="#CCFF99"> <td><span class="style38 style39 style40 style40">Birthday</span></td> <td><span class="style38 style39 style40 style40"> <label for="month"></label> <select name="bday_month" id="bday_month"> <option selected="selected">Month</option> <option value="january">January</option> <option value="february">February</option> <option value="march">March</option> <option value="april">April</option> <option value="may">May</option> <option value="june">June</option> <option value="july">July</option> <option value="august">August</option> <option value="may">May</option> <option value="june">June</option> <option value="july">July</option> <option value="august">August</option> <option value="september">September</option> <option value="october">October</option> <option value="november">November</option> <option value="december">December</option> </select> <select name="bday_day" id="bday_day"> <option selected="selected">Day</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> </span></td> </tr> <tr bgcolor="#CCFF99"> <td><span class="style38 style39 style40 style40">Anniversary</span></td> <td><span class="style38 style39 style40 style40"> <label for="label"></label> <select name="ann_month" id="ann_month"> <option selected="selected">Month</option> <option value="january">January</option> <option value="february">February</option> <option value="march">March</option> <option value="april">April</option> <option value="may">May</option> <option value="june">June</option> <option value="july">July</option> <option value="august">August</option> <option value="may">May</option> <option value="june">June</option> <option value="july">July</option> <option value="august">August</option> <option value="september">September</option> <option value="october">October</option> <option value="november">November</option> <option value="december">December</option> </select> <select name="ann_day" id="ann_day"> <option selected="selected">Day</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> </span></td> </tr> <tr valign="baseline"> <td align="left" valign="top" nowrap="nowrap"><span class="style38 style40">Address</span></td> <td align="left" valign="top"><input name="address" type="text" class="style39 style40" value="" size="32" /></td> </tr> <tr bgcolor="#CCFF99"> <td><span class="style38 style39 style40 style40"> <label for="city"></label> City</span></td> <td><span class="style38 style39 style40 style40"> <label for="city"></label> <input name="city" type="text" id="city" size="10" /> <label for="state">State</label> <select name="state" id="state"> <option value="AK" selected="selected">AK</option> <option value="AL">AL</option> <option value="AR">AR</option> <option value="AZ">AZ</option> <option value="CA">CA</option> <option value="CO">CO</option> <option value="CT">CT</option> <option value="DC">DC</option> <option value="DE">DE</option> <option value="FL">FL</option> <option value="GA">GA</option> <option value="HI">HI</option> <option value="IA">IA</option> <option value="ID">ID</option> <option value="IL">IL</option> <option value="IN">IN</option> <option value="KS">KS</option> <option value="KY">KY</option> <option value="LA">LA</option> <option value="MA">MA</option> <option value="MD">MD</option> <option value="ME">ME</option> <option value="MI">MI</option> <option value="MN">MN</option> <option value="MO">MO</option> <option value="MS">MS</option> <option value="MT">MT</option> <option value="NC">NC</option> <option value="ND">ND</option> <option value="NE">NE</option> <option value="NH">NH</option> <option value="NJ">NJ</option> <option value="NM">NM</option> <option value="NV">NV</option> <option value="NY">NY</option> <option value="OH">OH</option> <option value="OK">OK</option> <option value="OR">OR</option> <option value="PA">PA</option> <option value="RI">RI</option> <option value="SC">SC</option> <option value="SD">SD</option> <option value="TN">TN</option> <option value="TX">TX</option> <option value="UT">UT</option> <option value="VA">VA</option> <option value="VT">VT</option> <option value="WA">WA</option> <option value="WI">WI</option> <option value="WV">WV</option> <option value="WY">WY</option> </select> <label for="zip">Zip</label> <input name="zip" type="text" id="zip" size="7" /> </span></td> </tr> <tr valign="baseline"> <td colspan="2" align="left" valign="top" nowrap="nowrap"><span class="style38 style39 style40 style40"> <label for="favorite">Favorite Menu Items</label> <input name="favorite" type="text" id="favorite" size="50" /> </span></td> </tr> <tr valign="baseline"> <td colspan="2" align="left" valign="top" nowrap="nowrap"><span class="style35 style39 style40">I am interested in information:</span></td> </tr> <tr valign="baseline"> <td colspan="2" align="left" valign="top" nowrap="nowrap"><span class="style38 style40"> <input <?php if (!(strcmp($row_Recordset1['lunch'],1))) {echo "checked=\"checked\"";} ?> type="checkbox" name="lunch" id="lunch" /> <label for="lunch">Lunch & Dinner Specials<span class="style41"></label> <br /> <input <?php if (!(strcmp($row_Recordset1['reservations'],1))) {echo "checked=\"checked\"";} ?> type="checkbox" name="reservations" id="reservations" /> <label for="reservations">Reservations</label> <label for="label"></label> <br /> <input <?php if (!(strcmp($row_Recordset1['parties'],1))) {echo "checked=\"checked\"";} ?> type="checkbox" name="parties" id="parties" /> <label for="parties"></label> <label for="label">Large Parties or Groups</label> <label for="checkbox"></label> <br /> <input <?php if (!(strcmp($row_Recordset1['new_menu'],1))) {echo "checked=\"checked\"";} ?> type="checkbox" name="new_menu" id="new_menu" /> <label for="new_menu">New Menu Selections</label> </span> <table width="150" border="0" align="right" cellpadding="0" cellspacing="0"> <tr> <td class="style38 style40"><input type="submit" value="Submit" /></td> </tr> </table> <span class="style38 style40"><br /> <input <?php if (!(strcmp($row_Recordset1['chef_specials'],1))) {echo "checked=\"checked\"";} ?> type="checkbox" name="chef_specials" id="chef_specials" /> Our Chef's Specials</span> <span class="style38 style40"> <label for="chef_specials"></label> </span></td> </tr> </table> <input type="hidden" name="MM_insert" value="form1" /> </form> Thank You page <?php require_once('Connections/mastodon.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; } } mysql_select_db($database_mastodon, $mastodon); $query_Recordset1 = "SELECT * FROM mastodon"; $Recordset1 = mysql_query($query_Recordset1, $mastodon) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); ?> <p class="style41">Congratulations <strong><?php echo $row_Recordset1['name']; ?> </strong>and thank you for joining The Mastodon Grill and Patio's Platinum Club.</p> <hr /> <p class="style42">Benefits of Platinum Club Membership:<span class="style43"><img src="images/menu.jpg" width="151" height="163" align="right" /></span></p> <ul> <li class="style43">Weekly Dining Specials</li> <li class="style43">Drink Specials</li> <li class="style43">Events</li> <li class="style43">News Letters</li> <li class="style43">Special Reservations</li> <li class="style43">Birthday Specials</li> <li class="style43">Anniversary Specials</li> <li class="style43">And More...</li> </ul> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><span class="style49">Your Personal Platinum Club Membership Number Is </span><span class="style46"><?php echo $row_Recordset1['id']; ?></span><span class="style50"><br /> <br /> <span class="style49"><?php echo $row_Recordset1['name']; ?><br /> <?php echo $row_Recordset1['address']; ?><br /> <?php echo $row_Recordset1['city']; ?>, <?php echo $row_Recordset1['state']; ?>, <?php echo $row_Recordset1['zip']; ?><br /> <?php echo $row_Recordset1['email']; ?></span></span></td> </tr> </table> </td> </tr> </table> Link to comment https://forums.phpfreaks.com/topic/159771-solved-populates-the-database-but-shows-different-person/ Share on other sites More sharing options...
sandbudd Posted May 26, 2009 Author Share Posted May 26, 2009 I guess my problem is that the thank you page does not know which Id to use? Link to comment https://forums.phpfreaks.com/topic/159771-solved-populates-the-database-but-shows-different-person/#findComment-842671 Share on other sites More sharing options...
sandbudd Posted May 26, 2009 Author Share Posted May 26, 2009 in the insert statement do I still to put Id even though I have it set for auto? Link to comment https://forums.phpfreaks.com/topic/159771-solved-populates-the-database-but-shows-different-person/#findComment-842685 Share on other sites More sharing options...
dennismonsewicz Posted May 26, 2009 Share Posted May 26, 2009 yeah I would pass the ID of the name you are wanting to use unless you set the ID to a session. And no you do not need to put ID if it is set to auto Link to comment https://forums.phpfreaks.com/topic/159771-solved-populates-the-database-but-shows-different-person/#findComment-842696 Share on other sites More sharing options...
sandbudd Posted May 26, 2009 Author Share Posted May 26, 2009 where would I get it to call the name from the previous form with a where clause $name Link to comment https://forums.phpfreaks.com/topic/159771-solved-populates-the-database-but-shows-different-person/#findComment-842698 Share on other sites More sharing options...
dennismonsewicz Posted May 26, 2009 Share Posted May 26, 2009 change $insertGoTo = "thankyou.php"; to $insertGoTo = "thankyou.php?name=" . $_POST['name'] . ""; and on thankyou.php make sure to grab the name from the URL and then in your SQL: SELECT * FROM mastodon WHERE name = $_GET['name'] Link to comment https://forums.phpfreaks.com/topic/159771-solved-populates-the-database-but-shows-different-person/#findComment-842702 Share on other sites More sharing options...
sandbudd Posted May 26, 2009 Author Share Posted May 26, 2009 get a blank page on the thank you page Link to comment https://forums.phpfreaks.com/topic/159771-solved-populates-the-database-but-shows-different-person/#findComment-842707 Share on other sites More sharing options...
dennismonsewicz Posted May 26, 2009 Share Posted May 26, 2009 what does your updated code look like? Link to comment https://forums.phpfreaks.com/topic/159771-solved-populates-the-database-but-shows-different-person/#findComment-842714 Share on other sites More sharing options...
dennismonsewicz Posted May 26, 2009 Share Posted May 26, 2009 change SELECT * FROM mastodon WHERE name = $_GET['name'] to $name = $_GET['name']; SELECT * FROM mastodon WHERE name = '$name' Link to comment https://forums.phpfreaks.com/topic/159771-solved-populates-the-database-but-shows-different-person/#findComment-842715 Share on other sites More sharing options...
sandbudd Posted May 26, 2009 Author Share Posted May 26, 2009 it is showing in the address bar correct but still blank page Link to comment https://forums.phpfreaks.com/topic/159771-solved-populates-the-database-but-shows-different-person/#findComment-842724 Share on other sites More sharing options...
redarrow Posted May 26, 2009 Share Posted May 26, 2009 show us the link it showing in the url then? Link to comment https://forums.phpfreaks.com/topic/159771-solved-populates-the-database-but-shows-different-person/#findComment-842726 Share on other sites More sharing options...
sandbudd Posted May 26, 2009 Author Share Posted May 26, 2009 thankyou.php?name=test& Link to comment https://forums.phpfreaks.com/topic/159771-solved-populates-the-database-but-shows-different-person/#findComment-842729 Share on other sites More sharing options...
dennismonsewicz Posted May 26, 2009 Share Posted May 26, 2009 something else is wrong in the PHP code Link to comment https://forums.phpfreaks.com/topic/159771-solved-populates-the-database-but-shows-different-person/#findComment-842733 Share on other sites More sharing options...
sandbudd Posted May 26, 2009 Author Share Posted May 26, 2009 Think I am going to get out of the Dreamweaver coding and just hand code it it would be easier...lol..thanks guys Link to comment https://forums.phpfreaks.com/topic/159771-solved-populates-the-database-but-shows-different-person/#findComment-842734 Share on other sites More sharing options...
redarrow Posted May 26, 2009 Share Posted May 26, 2009 dream weaver now you tell us lol. use a different editor like notepad++ look for a free text editor be better then dream weaver even note pad lol. Link to comment https://forums.phpfreaks.com/topic/159771-solved-populates-the-database-but-shows-different-person/#findComment-842736 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.