vietboy505 Posted March 24, 2006 Share Posted March 24, 2006 I want to enter the data back once a user click submit and they haven't fill all data in yet.How would I do that?Also, if all fields are enter. It will go to another page instead staying on the same page.I use:[code]<form name="create_form" method="POST" action="<?php echo $PHP_SELF; ?>">[/code]This will add data to the database, but if I use like [code]<form name="create_form" method="POST" action="anotherPage.php">[/code]This will not add data to the database.Full code:[code]<?php include("config3.php"); ?><?phpif (isset($_POST['create_form'])) { submitData();} function submitData() {if (($_POST["NAME"] == "") or ($_POST["QUESTION"] == "")) { echo " <script type=\"text/javascript\"> alert(\"Please input all data.\") </script> ";}mysql_select_db($dbNAME) or die($errCon . mysql_error()); mysql_query("INSERT INTO $tableNEW (name,number,question) VALUES('$NAME', '$NUMBER','$QUESTION') ") or die($errCon . mysql_error());} //end function?><form name="create_form" method="POST" action="<?php echo $PHP_SELF; ?>"><table><tr> <td align="right">Name:</td> <td><input name="NAME" size="25"></td></tr><tr> <td align="right">Number:</td> <td><select name="NUMBER"> <option value="1">1 <option value="2">2 <option value="3">3 <option value="4">4 <option value="5">5 <option value="6">6 <option value="7">7 <option value="8">8 <option value="9">9 </select> </td></tr><tr> <td align="right">Question:</td> <td> <textarea name="QUESTION" rows="10" cols="40"></textarea> </td></tr><tr> <td colspan="2" align="center"><input type="submit" value="Submit" name="create_form"> <input type="reset" value="Reset" name="reset"></td></tr></table></form>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/5715-submit-remember-data/ Share on other sites More sharing options...
shortj75 Posted March 25, 2006 Share Posted March 25, 2006 it sounds like the variables arnt being passed i had the same problem once try this[code]<?php include("config3.php"); ?><?phpif (isset($_POST['create_form'])) { submitData();} function submitData() {$NAME=$_POST['NAME'];$NUMBER=$_POST['NUMBER'];$QUESTION=$_POST['QUESTION'];if (($_POST["NAME"] == "") or ($_POST["QUESTION"] == "")) { echo " <script type=\"text/javascript\"> alert(\"Please input all data.\") </script> ";}mysql_select_db($dbNAME) or die($errCon . mysql_error()); mysql_query("INSERT INTO $tableNEW (name,number,question) VALUES('$NAME', '$NUMBER','$QUESTION') ") or die($errCon . mysql_error());} //end function?><form name="create_form" method="POST" action="<?php echo $PHP_SELF; ?>"><table><tr> <td align="right">Name:</td> <td><input name="NAME" size="25"></td></tr><tr> <td align="right">Number:</td> <td><select name="NUMBER"> <option value="1">1 <option value="2">2 <option value="3">3 <option value="4">4 <option value="5">5 <option value="6">6 <option value="7">7 <option value="8">8 <option value="9">9 </select> </td></tr><tr> <td align="right">Question:</td> <td> <textarea name="QUESTION" rows="10" cols="40"></textarea> </td></tr><tr> <td colspan="2" align="center"><input type="submit" value="Submit" name="create_form"> <input type="reset" value="Reset" name="reset"></td></tr></table></form>[/code]by adding this $NAME=$_POST['NAME'];$NUMBER=$_POST['NUMBER'];$QUESTION=$_POST['QUESTION'];when you submit the form the php part of the page will grab the variables Quote Link to comment https://forums.phpfreaks.com/topic/5715-submit-remember-data/#findComment-20500 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.