SESSION help needed

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
recycled
Forum Newbie
Posts: 3
Joined: Tue Feb 27, 2007 3:15 pm

SESSION help needed

Post by recycled »

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]


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>";
	}
?>
Thanks in advance
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]
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Post by califdon »

Just before your

Code: Select all

elseif($mode!="created")
line, there is a

Code: Select all

echo "<form method=POST action=\"newsigning.php?mode=add\"><center><input type=submit value=\"Clear\"></center></form>";
line that looks to me like it should be way down after all the if blocks. Otherwise, the first time this code executes, it falls through all the ifs and then there's no Form tag.
Post Reply