Forum Moderators: coopster

Message Too Old, No Replies

PHP formmail - troubleshoot

PHP form troubleshoot, I hope Im in right category!

         

Rose_1171

2:48 pm on Jan 26, 2006 (gmt 0)

10+ Year Member



Hi,
I have a form on website, <snip>
This form is not working for soem reason Please help troubleshoot it.
Following is php code Ive used:
<?
$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$message = $_REQUEST['Message'] ;
$company = $_REQUEST['company'] ;
$phone = $_REQUEST['phone'] ;

mail( "contact@example.com", "contact us form",
$message, $name, $company, $phone, "From: $email" );
header( "Location: http://www.example.com/thankyou.html" );
?>

Contact.php is the script.
Following is the code of htm form, which calls this script.

<form method="post" action="http://example.com/contact.php">

Please help!

Regards,
Primrose

[edited by: encyclo at 3:33 pm (utc) on Jan. 26, 2006]
[edit reason] examplified [/edit]

chriswragg

5:50 pm on Jan 26, 2006 (gmt 0)

10+ Year Member



The problem lies in the mail fuction:
mail("contact@example.com", "contact us form", $message, $name, $company, $phone, "From: $email" );

The problem is

$message, $name, $company, $phone,

If you want to combine all these use a dot:
$message.$name.$company.$phone,

or use:

$emailmessage = "Message = $message\n Name= $name\nCompany = $company\nPhone= $phone";
mail("contact@example.com", "contact us form", $emailmessage, "From: $email" );

Also you should add die(); after the header function, just to stop the file being parsed.

Chris