PDA

View Full Version : Forms



BIC
10-12-2007, 03:14 PM
I have created a form per the directions of the tutorials and have entered the following code on the .php page as directed:
<?PHP
$mailto = "info@sfevcx.com";
$email = $HTTP_POST_VARS['email'];
if ($email == "") {
$email = $mailto;
}
$mailsubj = "Contact BIC";
$mailhead = "From: $email\n";
reset ($HTTP_POST_VARS);
$mailbody = "Values submitted from web site form :\n";
while (list ($key, $val) = each ($HTTP_POST_VARS))
{
if ($key!="submit")
{
$mailbody .= "$key : $val\n";
}
}
mail($mailto, $mailsubj, $mailbody, $mailhead);
?>

The form is still not functional and I am receiveing the error message:

Parse error: syntax error, unexpected '<' in /home/qwxqsmue/public_html/action.php on line 40

Please help! What am I doing wrong.

Suzanne

Watdaflip
10-12-2007, 07:26 PM
You are probably missing a ?> at the end of the php script you inserted onto you page,

Sarah
10-12-2007, 07:47 PM
You have inserted your code twice, once between the head tags (which will not work) and then between the body tags. The second one is incomplete:

$email = $HTTP_POST_VARS[email];
$mailto = "info@biccorp.com";
$mailsubj = "Contact Form Submission";
$mailhead = "From: $email\n";
reset ($HTTP_POST_VARS);
$mailbody = "Values submitted from website form;\n";
while (list ($key, $val) = each ($HTTP_POST_VARS))
{

You need to recreate the page from scratch, this time insert the full script between the body tags and it will work!

Sarah

navaldesign
10-12-2007, 10:05 PM
Unless Sarah can see something that i cant, the script is correct. Only explanation, as Watdaflip said, you have forgotten (in the page, here it is correct) the closing tag

<?PHP
$mailto = "info@sfevcx.com";
$email = $HTTP_POST_VARS['email'];
if ($email == "") {
$email = $mailto;
}
$mailsubj = "Contact BIC";
$mailhead = "From: $email\n";
reset ($HTTP_POST_VARS);
$mailbody = "Values submitted from web site form :\n";
while (list ($key, $val) = each ($HTTP_POST_VARS))
{
if ($key!="submit")
{
$mailbody .= "$key : $val\n";
}
}
mail($mailto, $mailsubj, $mailbody, $mailhead);
?>

This last part in red is the one that you must have forgoten.

And, to my knowledge, the code will work in whichever tag of the page html : Start of page (which i prefer), Between head, inside body, end of page.

The php code is not like the html code, it is executed anywhere in the page code.

lemmondr
11-03-2007, 11:32 AM
Naval, Sarah, which is the correct code???? both PHP codes you have listed are different.

Daniel


Sarah's Code:

$email = $HTTP_POST_VARS[email];
$mailto = "info@biccorp.com";
$mailsubj = "Contact Form Submission";
$mailhead = "From: $email\n";
reset ($HTTP_POST_VARS);
$mailbody = "Values submitted from website form;\n";
while (list ($key, $val) = each ($HTTP_POST_VARS))
{

Naval's Code:

<?PHP
$mailto = "info@sfevcx.com";
$email = $HTTP_POST_VARS['email'];
if ($email == "") {
$email = $mailto;
}
$mailsubj = "Contact BIC";
$mailhead = "From: $email\n";
reset ($HTTP_POST_VARS);
$mailbody = "Values submitted from web site form :\n";
while (list ($key, $val) = each ($HTTP_POST_VARS))
{
if ($key!="submit")
{
$mailbody .= "$key : $val\n";
}
}
mail($mailto, $mailsubj, $mailbody, $mailhead);
?>

navaldesign
11-03-2007, 12:44 PM
Sarah DID NOT post any code, she was merely stating that the code that BIC had used was incomplete.
You can use the one i posted.

This is the same one that is included in the Forms Tutorial Part 1.