...

View Full Version : Problem with PHP contact form



YellowMonkeyMan
03-03-2010, 01:51 PM
Hi there

If anyone could help with this I'd be extremely grateful. The contact form on my site is returning messages of:

From: $fullName\nSender E-mail address: $header\nCompany name: $subject\nContact number: $contactNumber\nTOCR Version: $version\nOS: $OS\nMessage: $comment\n

for every message.

I know I must have made a coding error somewhere, but for the life of me I can't see it, if someone else can I'll be very grateful.

The form is:

<form action="emailProcessor.php" method="post">
<table style="width: 780px">
<tr>
<td class="style1" style="height: 26px">
<label for="name" class="style1">Name</label></td>
<td style="height: 26px"><input name="fullName" size="40" type="text" /></td>
</tr>
<tr>
<td class="style1">Company name</td>
<td><input name="companyName" size="40" tabindex="2" type="text" /></td>
</tr>
<tr>
<td class="style1" style="height: 26px">E-mail</td>
<td style="height: 26px"><input name="eMail" size="40" tabindex="2" type="text" /></td>
</tr>
<tr>
<td class="style1" style="height: 26px">Contact number</td>
<td style="height: 26px"><input name="contactNumber" size="40" tabindex="2" type="text" /></td>
</tr>


<tr>
<td class="style1" style="height: 26px">TOCR Version</td>
<td style="height: 26px"><select name="version">
<option></option>
<option>1.4</option>
<option>2.0</option>
<option selected="selected">3.0</option>
</select></td>
</tr>
<tr>
<td class="style1" style="height: 26px">Operating System</td>
<td style="height: 26px"><select name="OS">
<option></option>
<option>Windows 95</option>
<option>Windows 98</option>
<option>Windows ME</option>
<option>Windows NT</option>
<option>Windows 2000</option>
<option selected="selected">Windows XP</option>
<option>Windows Vista</option>
</select></td>
</tr>

<tr>
<td class="style1">Message</td>
<td><textarea cols="70" name="Comment" rows="8" tabindex="4"></textarea>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;&nbsp;</td>
<td>
<input name="submitButton" tabindex="5" type="submit" value="submit" /><input name="resetButton" tabindex="6" type="reset" value="Reset" />&nbsp;</td>
</tr>
</table>
</form>

and the emailProcessor.php page is

<?php

$to = 'support@transym.com';
$subject = $_POST['companyName'];
$header = $_POST['eMail'];
$message = 'From: $fullName\nSender E-mail address: $header\nCompany name: $subject\nContact number: $contactNumber\nTOCR Version: $version\nOS: $OS\nMessage: $comment\n';

if ($header =="") {
echo "<meta http-equiv=\"refresh\" content =\"0;URL=error.htm\">";
exit;
}

$success = mail ($to, $subject, $message, "From: <$header>");

if ($success){
echo "<meta http-equiv=\"refresh\" content =\"0;URL=success.htm\">";
}
else {
echo "<meta http-equiv=\"refresh\" content =\"0;URL=failure.htm\">";
}


?>

Anyone got any idea what I've buggered up?

MattF
03-03-2010, 01:59 PM
Change:



$message = 'From: $fullName\nSender E-mail address: $header\nCompany name: $subject\nContact number: $contactNumber\nTOCR Version: $version\nOS: $OS\nMessage: $comment\n';


to:



$message = 'From: '.$fullName."\n".'Sender E-mail address: '.$header."\n".'Company name: '.$subject."\n".'Contact number: '.$contactNumber."\n".'TOCR Version: '.$version."\n".'OS: '.$OS."\n".'Message: '.$comment."\n";

YellowMonkeyMan
03-03-2010, 02:35 PM
Brilliant, thank you so much it's completely sorted now.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum