everett121 Posted February 27, 2007 Share Posted February 27, 2007 Not an expert with PHP so bare with me, I have a form that is filled in by the user and then submitted to a database. After submitting successfully they get the options which are links, 1) to enter a different time for the event they just submitted or 2) an option to enter an entirely new event. My issue is that I want the data to appear in the fields as was, before the submission when they choose to enter a different time for the same event. (don't want the user to have to retype everything just to change one field). <?php session_save_path("/home/content/*/**/**/******/html/test/search/tmp"); session_start(); include "sys_connect.php"; $_SESSION["newsign"]["book"] = $_POST['book']; $_SESSION["newsign"]["author_name"] = $_POST['author_name']; $_SESSION["newsign"]["location"] = $_POST['location']; $_SESSION["newsign"]["dates"] = $_POST['dates']; $_SESSION["newsign"]["hours"] = $_POST['hours']; $book=$_POST['book']; $author_name=$_POST['author_name']; $location=$_POST['location']; $dates=$_POST['dates']; $hours=$_POST['hours']; $mode = $_REQUEST['mode']; if($mode=="new") { //insert the data to the db $newsigning =mysql_query ("INSERT INTO table (book,author_name,location,dates,hours) VALUES ('$book', '$author_name', '$location', '$dates', '$hours')"); mysql_query($newsigning); $mode = "created";} if($mode=="created") { //Let the user know their signing has been added echo "Your signing has been added. Thank You!<br> <a href='newsigning.php?mode=add'>Enter more signings for this book</a><br> <a href='newsigning.php'>Enter a new signing</a>"; END; } if($mode=="add") { //Show data and allow user to change what they need w/out having to enter all data again echo <<<END <table align="center" width="413" border="0" cellpadding="12" cellspacing="5" class="eventsys"> <tr><td> <fieldset style="padding: 14px;"> <legend>Enter a new signing</legend> <br> <table align="center" border="0"><tr><td class="eventsys"> <font size="+1"><b>Enter a new book signing here</b></font> <br>Please enter the following information to post a new signing. All fields are required. </td></tr></table> <form method=POST action="newsigning.php?mode=add"> END; echo "<left><table align=\"left\" width=\"250px\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\" class=\"eventsys\"><tr><td>"; echo "Book:"; echo "</td><td><input type=text size=12 maxlength=50 name=book value=\"$book\"></td>"; echo "<tr><td valign=top>"; echo "Author Name:"; echo "</td><td><input type=text size=12 maxlength=25 name=author_name value=\"$author_name\"></td>"; echo "<tr><td valign=top>"; echo "Location:"; echo "</td><td><input type=text size=20 maxlength=25 name=location value=\"$location\"></td>"; echo "<tr><td valign=top>"; echo "Dates:"; echo "</td><td><input type=text size=20 maxlength=25 name=dates value=\"$dates\"></td>"; echo "<tr><td valign=top>"; echo "Hours:"; echo "</td><td><input type=text size=20 maxlength=25 name=hours value=\"$hours\"></td>"; echo "<tr><td valign=top>"; echo "<br><input type=submit value=\"Submit\"></form></center>"; echo "<form method=POST action=\"newsigning.php?mode=add\"><center><input type=submit value=\"Clear\"></center></form>"; } elseif($mode!="created") { echo <<<END <table align="center" width="413" border="0" cellpadding="12" cellspacing="5" class="eventsys"> <tr><td> <fieldset style="padding: 14px;"> <legend>Enter a new signing</legend> <br> <table align="center" border="0"><tr><td class="eventsys"> <font size="+1"><b>Enter a new book signing here</b></font> <br>Please enter the following information to post a new signing. All fields are required. </td></tr></table> <form method=POST action="newsigning.php?mode=new"> END; if (!get_magic_quotes_gpc()) { $book = addslashes($book); $author_name = addslashes($author_name); $location = addslashes($location); $dates = addslashes($dates); $hours = addslashes($hours); } /*echo <<<END <form action="insert_signing.php" method="post"> <table border="0"> <tr> <td>Book</td> <td><input type="text" name="book" maxlength="50" size="50"></td> </tr> <tr> <td>Author</td> <td> <input type="text" name="author_name" maxlength="30" size="30"></td> </tr> <tr> <td>Location</td> <td> <input type="text" name="location" maxlength="60" size="30"></td> </tr> <tr> <td>Dates</td> <td><input type="text" name="dates" maxlength="25" size="13"></td> </tr> <tr> <td>Hours</td> <td><input type="text" name="hours" maxlength="25" size="13"></td> </tr> <tr> <td colspan="2"><input type="submit" value="Submit"></td> </tr> </table> </form> END;*/ echo "<left><table align=\"left\" width=\"250px\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\" class=\"eventsys\"><tr><td>"; echo "Book:"; echo "</td><td><input type=text size=12 maxlength=20 name=book value=\"$book\"></td>"; echo "<tr><td valign=top>"; echo "Author Name:"; echo "</td><td><input type=text size=12 maxlength=25 name=author_name value=\"$author_name\"></td>"; echo "<tr><td valign=top>"; echo "Location:"; echo "</td><td><input type=text size=20 maxlength=25 name=location value=\"$location\"></td>"; echo "<tr><td valign=top>"; echo "Dates:"; echo "</td><td><input type=text size=20 maxlength=25 name=dates value=\"$dates\"></td>"; echo "<tr><td valign=top>"; echo "Hours:"; echo "</td><td><input type=text size=20 maxlength=25 name=hours value=\"$hours\"></td>"; echo "<tr><td valign=top>"; echo "<br><input type=submit value=\"Submit\"></form></center>"; echo "<form method=POST action=\"newsigning.php\"><center><input type=submit value=\"Clear\"></center></form>"; } ?> Thanks in advance Everett Quote Link to comment 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.