You are here: Validating and Passing form data to Thanks Page « All PHP « IT news, forums, messages
Validating and Passing form data to Thanks Page

Posted by Newbie Supreme on 02/14/06 07:18

Hi all, SERIOUS newb here just beginning to look into php. I've tried a few
solutions to my issue from snippets I've seen, but so far nothing has
worked.

In an attempt to stop email harvesting and SPAM issues (I get about 2,400
every 24 hours), I'm making my contact forms use the php form handler from
Sitewizard. The email from the form sends OK, and my Thanks page loads, but
I'd like to carry the value the user entered for their email into the Thanks
page. Previously I used a FrontPage component to show it, but putting this:

<?
print "Email you entered is $_POST['email']\n";
?>
just leaves that part of the page blank. I tried using a php extension on
the page instead of htm, but that didn't help. PHP does work on the Windows
2003 server.

The Sitewizard form has the following:

<form action="feedback.php" method="post">
<table border="0" cellpadding="8" cellspacing="8" summary="feedback form">
<tr><td>Name:</td><td><input type="text" name="name" size="25" /></td></tr>
<tr><td>Email address:</td><td><input type="text" name="email" size="25"
/></td></tr>
<tr>
<td colspan="2">
Comments<br />
<textarea rows="15" cols="45" name="comments">
</textarea>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<input type="submit" value="Send Feedback" /><br />
</td>
</tr>
</table>
</form>

The Sitewizard formhandler (feedback.php) has the following (with the actual
working entries replaced w/ generic labels):

<?
$mailto = 'MyEmailAddress';
$subject = "Email Subject Line" ;
$formurl = "URL_of_form.htm" ;
$errorurl = "URL_of_Error_page.htm" ;
$thankyouurl = "URL_of_ThanksPage.htm" ;

ini_set ("SMTP", "mymailserver");

$name = $_POST['name'] ;
$email = $_POST['email'] ;
$comments = $_POST['comments'] ;
$http_referrer = getenv( "HTTP_REFERER" );

if (!isset($_POST['email'])) {
header( "Location: $formurl" );
exit ;
}
if (empty($name) || empty($email) || empty($comments)) {
header( "Location: $errorurl" );
exit ;
}
$name = strtok( $name, "\r\n" );
$email = strtok( $email, "\r\n" );
if (get_magic_quotes_gpc()) {
$comments = stripslashes( $comments );
}

$messageproper =

"This message was sent from:\n" .
"$http_referrer\n" .
"------------------------- COMMENTS -------------------------\n\n" .
$comments .
"\n\n------------------------------------------------------------\n" ;

mail($mailto, $subject, $messageproper, "From: \"$name\"
<$email>\r\nReply-To: \"$name\" <$email>\r\nX-Mailer: chfeedback.php
2.04" );
header( "Location: $thankyouurl" );
exit ;
?>

On the Thanks page, I tried putting:

<?
print "You entered email as $_POST ['email']\n" ;
?>
and several other variations, excluding the apostrophes, then the brackets,
several different combinations, etc.; you know, the usual attempts to see if
the problem was my syntax.

Can anyone tell me how this can be done?

If you have the time, I'd also like to know if there's a way with php to
validate that the email field was filled in (currently use FrontPage's
validation rule that just pops up a "no email address" error when user
attempts to click Send button).

If this belongs in a different group, please lead me in the right direction.

Thanks for reading, and for any help. I hope I don't wear out my welcome
while I start learning php.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация