Forum Moderators: coopster

Message Too Old, No Replies

Help!

What's wrong with my script?

         

lollyh

3:15 pm on Apr 13, 2007 (gmt 0)

10+ Year Member



Hi

Managed to make a small feedback.php form and sendmail.php work perfectly yesterday but as soon as I tried to do a larger form I failed miserably, here is the sendmail script, which is where I'm presuming I've gone wrong.

Please can someone let me know where I've gone wrong?

<?php
mail("info@example.co.uk", "Request A Quote Results", $_REQUEST['name'], $_REQUEST['business'], $_REQUEST['position'], $_REQUEST['address'], $_REQUEST['country'], $_REQUEST['telephone'], $_REQUEST['mobile'], $_REQUEST['requirements'], "From: $_REQUEST[email]", "-froot@example.co.uk".$_REQUEST[email]); header( "Location: http://www.example.co.uk/thankyou.html");
?>

It all appears to work perfectly well on screen but when I check my email there is nothing there!

Thanks!

Lolly

[edited by: eelixduppy at 4:37 pm (utc) on April 13, 2007]
[edit reason] please use example.com [/edit]

whoisgregg

4:58 pm on Apr 13, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld [webmasterworld.com], lollyh!

The mail function [us.php.net] accepts at most five parameters:

$to, string $subject, string $message [, string $additional_headers [, string $additional_parameters]]

To build your message to include all the submitted data, you could do something like this:

$message = '';
foreach($_REQUEST as $k=>$v){
$message .= '<p><b>'.$k.'</b> &nbsp; '.$v.'</p>';
}
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

Then write your mail function like so:

 mail("info@example.co.uk", "Request A Quote Results", $message, $headers); 

Caution! Your current code (and even the code snippets I've provided) are vulnerable to mail header injection -- an attack that turns your mail form into a relay for spammers. Take the time to learn more about it and protect your form. Here's a good library thread about the subject:
[webmasterworld.com...]

lollyh

8:06 am on Apr 14, 2007 (gmt 0)

10+ Year Member



Thanks!

I'll have a go at that and take a look at the link.

A little new to php scripting as you can probably tell!

lollyh