Page 1 of 1

Form to E-mail

Posted: Wed Jul 05, 2006 8:29 pm
by derek barnstorm
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I am using the following process script for a form to e-mail page. Everything is fine, but when the message is sent to my e-mail address, the senders e-mail address shows 'From: thesender@the_path_to_my_server'. Does anyone know how I can convert it so that it is actually sent from the senders e-mail address.

Thanks,

Des.

Code: Select all

<?php
$errors=0;
if($Name=="" || $Age=="" || $Gender=="" || $Location=="" || $Interests=="" || $Bands=="" || $Gig=="" || $Discs=="" || $Books=="" || $Films=="" || $Email=="" || $Show=="" ){
header ("location: error.php");
exit;
}
if(!is_uploaded_file($Photo)){
header ("location: photo_error.php");
exit; 
}
if($errors==1) echo $error;
else{
$image_part = date("h_i_s")."_".$Photo_name;
$image_list[14] = $image_part;
copy($Photo, "files/".$image_part);
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
$message="Name: ".$Name."
Age: ".$Age."
Gender: ".$Gender."
Location: ".$Location."
Interests: ".$Interests."
Bands: ".$Bands."
Gig: ".$Gig."
Discs: ".$Discs."
Books: ".$Books."
Films: ".$Films."
Email: ".$Email."
Show: ".$Show."
Msn: ".$Msn."
Website: ".$Website."
Photo: ".$where_form_is."files/".$image_list[14]."
";
mail("me@mysite.com","Message Title",$message,"From: Sender");
header("Refresh: 0;url=http://mysite.com/folder/profile_sent.php ");
}
?>

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Wed Jul 05, 2006 8:42 pm
by Burrito
you need to send it the appropriate headers (the fourth argument of the function):

here's an example off of the manual:

Code: Select all

<?php
$to      = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
   'Reply-To: webmaster@example.com' . "\r\n" .
   'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>

Posted: Wed Jul 05, 2006 8:57 pm
by derek barnstorm
Sorry, I am total beginner at PHP. Can I just add that to the script I am using and if so, where abouts?

Thanks a lot,

Des.

Posted: Wed Jul 05, 2006 9:08 pm
by JellyFish
Yeah I'm not quite sure, but I think you need to have an @something.com in you the 4th argument of the mail() function. If you place:

Code: Select all

mail("me@mysite.com","Message Title",$message,"From: Sender@youwebstie.com");
instade of (what you have already):

Code: Select all

mail("me@mysite.com","Message Title",$message,"From: Sender");
Then I think it outta solve you problem. As I said I'm not quite sure.

Hope I helped.

Posted: Wed Jul 05, 2006 9:53 pm
by derek barnstorm
No, that is just the message title that appears as the subject.

Thanks anyway.