PDA

View Full Version : modifcation of mail script


jonsaul
02-18-2008, 02:29 PM
Hi,


i was provided with an example mail script by my hosting provider.


<?php
//ini_set("sendmail_from", "root@whitbypark.co.uk");
mail( "testmail@whitbypark.co.uk", $_POST['subject'], $_POST['email'] , "-fuser@jsaul.eu" , "-froot@whitbypark.co.uk" );
header( "Location: http://www.whitbypark.co.uk" );
?>


This works ok with the provided form, but if I try to add additonal fields to my form and add them to the mail function of the php it no longer works.

eg...


<?php
//ini_set("sendmail_from", "root@whitbypark.co.uk");
mail( "testmail@whitbypark.co.uk", $_POST['subject'], $_POST['email'] , $_POST['telephone'] , $_POST['address'] , $_POST['age'] , "-fuser@jsaul.eu" , "-froot@whitbypark.co.uk" );
header( "Location: http://www.whitbypark.co.uk" );
?>



I need to add 3 more inputs to my form, any ideas ?

m1a2x3x7
02-18-2008, 04:53 PM
you're misunderstanding the mail function.

it works like this:
mail(address the message is sent to, the subject, the message, the header);

if you want to include the email, telephone address and age you'll need to store those into the message.

domedia
02-18-2008, 05:14 PM
http://us3.php.net/manual/en/ref.mail.php

m1a2x3x7
02-18-2008, 05:14 PM
try something like this.


$message = "Email:" . $_POST["email"] . "\r\n" . "Address:" . $_POST["address"] . "\r\n" . "Age:" . $_POST["age"] . "\r\n" . "Message:" . $_POST["message"];

//ini_set("sendmail_from", "root@whitbypark.co.uk");
mail( "testmail@whitbypark.co.uk", $_POST['subject'], $message, "-fuser@jsaul.eu" , "-froot@whitbypark.co.uk" );
header( "Location: http://www.whitbypark.co.uk" );