PDA

View Full Version : Need help with required fields



quyhurry
02-07-2006, 10:10 AM
Hi all,
I made this form using Pablo's way:
http://www.nguyenthaihocfoundation.com/essay.html
and the acknowledge php page:
http://www.nguyenthaihocfoundation.com/ack.php
Everything works fine.

Now i wanted to validate required fields and made 3 more errors pages:
http://www.nguyenthaihocfoundation.com/error_name.html
http://www.nguyenthaihocfoundation.com/error_email.html
http://www.nguyenthaihocfoundation.com/error_essay.html

And try this script, using navaldesign's way:
<?php
@$Name = addslashes($_POST['Name']);
@$Email = addslashes($_POST['Email']);
@$Essay = addslashes($_POST['Essay']);
if (strlen($Name) >40)
{
header("Location: error_name.html");
exit;
}
if (strlen($Name) == 0 )
{
header("Location: error_name.html");
exit;
}
if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $Email))
{
header("Location: error_email.html");
exit;
}
if (strlen($Email) == 0 )
{
header("Location: error_email.html");
exit;
}
if (strlen($Essay) == 0 )
{
header("Location: error_essay.html");
exit;
}
$pfw_header = "From: $Email\n"
. "Reply-To: $Email\n";
$pfw_subject = "Data Submitted from Webform";
$pfw_email_to = "duyanhvq@nguyenthaihocfoundation.com";
$pfw_message = "Name: $Name\n"
. "Email: $Email\n"
. "Essay: $Essay\n"
*****($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;
header("Location: ack.php");
?>

I put the script inside body tag of ack.php and replaced the former one.
It didn't work and got the message:
Parse error: parse error, unexpected '@' in /home/nguyent/public_html/ack.php on line 60

What did i do wrong? Please help. Thank you so much.
Quy

quyhurry
02-08-2006, 03:38 AM
I 'VE GOT IT !!!!
My errors were:
-. "Essay: $Essay\n" --> missed a ; at the end of the line
-header("Location: ack.php"); --> totally wrong .
I made a confirmation page and change to :
header("Location: confirmation.html");

I figured it out but breaking down the required fileds to ONE and did some testings

mark d
06-24-2006, 10:43 PM
I need a php script for required email fields. I would like a user to fill out required fields, click submit and I receive the required field information via email. After clicking the submit button the user is served a "thank you" page with information on it. Does anyone have a script? Thank you!

navaldesign
06-25-2006, 10:00 AM
http://netisopen.com/computer/TF005/T005.html