View Full Version : PHp Email Forms

08-06-2008, 05:11 PM
Hi Guys,
Just a quick question I have to create multiple forms for different car inquires I was just wondering if I am able to include a Title tag from the page into the email that is sent with the customers details on it?


$to = 'jca@*****.co.uk';
$from = 'Contact Form';
$name = $_REQUEST['Name'];
$headers = "From: $from";
$subject = "Contact Form | $name";

$fields = array();
$fields{"Name"} = "Name";
$fields{"Number"} = "Number";
$fields{"Email"} = "Email";
$fields{"Message"} = "Message";

$body = "We have received the following information:\n\n";

foreach($fields as $a => $b){ $body .= sprintf("&#37;50s: %s\n",$b,$_REQUEST[$a]); }

$send = mail($to, $subject, $body, $headers);


This is the form code I am using I am wanting to display the Title of the page that has the submit button on.

08-06-2008, 05:22 PM
Depends - is the title hardcoded into the page or can it change depending on what the page is displaying (the form page, that is)? If it's static, just set a variable $title = 'the title of this page'; If the title is dynamically created it might already be stored in a variable like that. In either case, once the variable is set, you can use it freely inside of your php code that composes the email. Post the code and we can show you how.