homepage Welcome to WebmasterWorld Guest from 50.17.21.7
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Sending email content to two places
sending email to mail and sepperate page
audaddy




msg:3260951
 1:03 am on Feb 23, 2007 (gmt 0)

Could someone please help me.

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]

 

phranque




msg:3261045
 3:39 am on Feb 23, 2007 (gmt 0)

your Location header is telling the browser to do a http GET request.
the new get request knows nothing about your browser's previous http POST, so it has no values for those form parameters.
why not combine them into one script or include one into the other?

mcibor




msg:3261248
 10:00 am on Feb 23, 2007 (gmt 0)

Exactly, as Phranque said redirecting looses all POST data,

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

audaddy




msg:3261990
 8:40 pm on Feb 23, 2007 (gmt 0)

Thanks mcibor, but how do you filter the contents of the email to stop spamming?

compose




msg:3262364
 4:19 am on Feb 24, 2007 (gmt 0)

you can use addslashes [in.php.net] and htmlentities [in.php.net] functions to filter your incoming data.

audaddy




msg:3262554
 10:59 am on Feb 24, 2007 (gmt 0)

Thanks guys for the input, but I am way to much of a newbie to go that deep into php. For the moment I will have to take the chance that noone uses the email to spam.

Thanks for your help as I can now do what I wanted to do.

David.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved