Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
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).
Code:Code: Select all
<?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 "<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>";
}
?>Everett
Everah | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]