954,587 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Setting a Session Cookie

<?=$msg?>






Your Name:

Your E-mail Address:

Your Daytime Phone:





Club Event Title:



Date and Time:





Location:





Phone Number:





Price:



Event Description:

Enter Security Code:

<?=$Str?>  



Spycat
Light Poster
49 posts since Apr 2006
Reputation Points: 10
Solved Threads: 0
 

You really don't need to save anything in a cookie for this.

You can just pass on what the use has put in the form in the HTTP POST or GET and populate the form with this for the user.

It easiest if you use the same PHP script both for generating the form and processing the form. That way you don't have to pass your form fields via HTTP twice.

Simple example: (pseudo code)

[php]

$is_generate = false;

if (/* some validation failed */) {

$is_generate = true;
}

if ($is_generate) { // generate form

echo '';
echo '';

echo '... etc. etc..';
echo '';

} else { // process form


}

// your variable cleansing funtion
function clean($var) {
// do some sanitizing
return $clean_var;
}

[/php]

NOtice the line:

[php]
echo '';[/php]

Ive set the value="" to the HTTP POST param "foo" since that is what was passed last time the form was filled...


Edit:
The reason I have clean() function there is just to note that if you are going to print anything sent by the user, back to the browser, you will have to clean your variables with your own custom function.

usually to prevent cross-site scripting.. XSS.

Withought that lil bit it would look something like:

[php]
echo '';[/php]

digital-ether
Nearly a Posting Virtuoso
Moderator
1,293 posts since Sep 2005
Reputation Points: 461
Solved Threads: 101
 

Hi there Dig-Eth,

Thanks sooo much for taking the time to write all that out for me.
I am pretty new at PHP, so I will take what you have given me and try to piece it together.

I sincerely appreciate your help.

Have a GREAT Thanksgiving! :)

Rick

Spycat
Light Poster
49 posts since Apr 2006
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You