Forum Moderators: coopster
I need to send content from a form to email and to the adjoining script. I was using $_POST to get both sets of information, but the adjoining script will not show the inputs.
The scripts are as follows:
'mailscript.php'
<?php //send email script
$message .= "Salutation:".$_POST['salutation']."\n";
$message .= "First Name:".$_POST['first_name']."\n";
$message .= "Last Name:".$_POST['last_name']."\n\n";
$message .= "Address:".$_POST['no_and_street']."\n";
$message .= "Address:".$_POST['suburb']."\n";
$message .= "Address:".$_POST['post_code']."\n\n";
$message .= "Home Phone:".$_POST['home_phone']."\n";
$message .= "Work Phone:".$_POST['work_phone']."\n";
$message .= "Mobile:".$_POST['mobile']."\n\n";
$message .= "Email:".$_POST['email']."\n\n";
$message .= "Description:".$_POST['description']."\n";
mail( "dave@example.com.au", "Contact Form Information",
$message, "From: example.com.au" );
header( "Location: thankyou.php" );
?>
And the section of 'thankyou.php'
print "<p>Thank you {$_POST['salutation']} {$_POST['first_name']} {$_POST['last_name']} for submitting our contact form.</p>";
print "<p>Your contact details are:
<ul>
<li>{$_POST['no_and_street']}, {$_POST['suburb']}, {$_POST['post_code']}</li>
<li>Home phone - {$_POST['home_phone']}, work phone - {$_POST['work_phone']}, mobile - {$_POST['mobile']}</li>
<li>Email - {$_POST['email']}</li>
</ul>
</p>;
There is more of the 'thankyou.php' script, but I have only included the necessary bits. The 'thankyou.php' script displays the above information like this:
Thank you for submitting our contact form.
Your contact details are:
, ,
Home phone - , work phone - , mobile -
Email -
As you can see, the $_POST inputs are not showing up, but they were before I had written 'mailscript.php'. The form used to point to 'thankyou.php' and now points to 'mailscript.php'.
If possible, I want to send the information to the email and to a page thanking the person who submitted the form, and showing them the information they submitted.
Thanks.
[edited by: coopster at 3:58 am (utc) on Feb. 23, 2007]
[edit reason] generalized domain [/edit]
it's easier if you
mail( "dave@example.com.au", "Contact Form Information",
$message, "From: example.com.au" );
require_once("thankyou.php");
Moreover always filter your data before sending it outside, otherwise your script can be used to send spam
Regards
Michal