post form memory
Posted: Fri Sep 16, 2005 4:11 pm
hi, im sure this has been discussed here before, but i tried searching and can't come up with the right words to find what to do.
my problem is that i have a form, and when i post it, php will check if everything is valid before sending out an email, but if things are not valid it will give you the proper error message and reload the form page. all this works fine, but how would i put all the information they have already entered back into the new form page?
here is my code:
any help would be greatly appreciated!
my problem is that i have a form, and when i post it, php will check if everything is valid before sending out an email, but if things are not valid it will give you the proper error message and reload the form page. all this works fine, but how would i put all the information they have already entered back into the new form page?
here is my code:
Code: Select all
//EMAIL FORM
function email_form()
{
?>
<form method="post" action="feedback.php">
Subject:
<SELECT name="topic">
<Option value="General feedback"> General feedback </option>
<Option value="Help with the website"> Help with the website </option>
<Option value="Help with an order"> Help with an order </option>
</SELECT>
<br><br>
Message:<br>
<TEXTAREA name="message" rows="6" cols="40"></textarea><br>
<br>
If you would like a reply please enter your email address here:<br>
<input type="text" name="from" cols=15></input><br>
<input type="submit" name="submit" value="submit"></input>
</form>
<?
}
//PAGE START
//if submit has been clicked
if ($submit)
{
if(!$message) //no message
{
echo "<b style='color:FF0000'> *Message cannot be blank</b><br><br>";
email_form();
}
else
{
if(!$from) //allowing blank from field for annonymous users
{
send_email($message, $from, $topic);
}
else
{
if(!valid_email($from)) //invalid email (user typo maybe)
{
echo "<b style='color:FF0000'> *Invalid email address</b><br><br>";
email_form();
}
else
{
//All checks have been made, you pass
send_email($message, $from, $topic);
}
}
}
}
else
{
//first time page view
email_form();
}
?>