tribeka Posted August 20, 2008 Share Posted August 20, 2008 Hi there I'm a designer trying to use a bit of php to process a form but am having problems getting it to work. If you visit http://www.scavengers-uk.com/request.html you'll see my form. Another file (also on the server) called sendmail.php is supposed to process the data and email it to [email protected] and then return the visitor to thanks.php. The code of sendmail.php is <?php mail("[email protected]", "Feedback Form results", $_REQUEST[message], "From: $_REQUEST", "[email protected]".$_REQUEST); header( "Location: http://www.scavengers-uk.com/thanks.php" ); ?> So far so good. The email gets sent to my email address but only with the data from the field [message]. Whenever I try to add some more fields from my form e.g. $_REQUEST[name] etc, the whole things stops working. I'm pretty close to begging for help. I've been working on this for a week, tried numerous scripts, forums, books but nothing fixes it. I would be extremely grateful for a bit of guidance cheers James Link to comment https://forums.phpfreaks.com/topic/120562-form-to-email-php-script-nightmare/ Share on other sites More sharing options...
ninedoors Posted August 20, 2008 Share Posted August 20, 2008 Are you looking for a recreation of the form to be sent to you? Like this: Name: Contact Number: Email: Address: Town: Postal Code: Message: If so that can be done quite easily. Link to comment https://forums.phpfreaks.com/topic/120562-form-to-email-php-script-nightmare/#findComment-621242 Share on other sites More sharing options...
tribeka Posted August 20, 2008 Author Share Posted August 20, 2008 That would be perfect! Link to comment https://forums.phpfreaks.com/topic/120562-form-to-email-php-script-nightmare/#findComment-621243 Share on other sites More sharing options...
ninedoors Posted August 20, 2008 Share Posted August 20, 2008 Ok try this! <?php $message = "Name: ".$_REQUEST['name']."<br> <br> Email: ".$_REQUEST['email']."<br> <br> Contact Number: ".$_REQUEST['contact']."<br> <br> Address: ".$_REQUEST['address']."<br> <br> Town: ".$_REQUEST['town']."<br> <br> Postal Code: ".$_REQUEST['postalcode']."<br> <br> Message: ".$_REQUEST['message']."<br> <br> "; mail("[email protected]", "Feedback Form results", $message, "From: $_REQUEST", "[email][email protected]".$_REQUEST[email]); header( "Location: http://www.scavengers-uk.com/thanks.php" ); ?> It isn't the pettiest thing in the world but it should work. Remember you need to change the $_REQUEST[name of variable] for each textbox to what ever you have named it on your form. Link to comment https://forums.phpfreaks.com/topic/120562-form-to-email-php-script-nightmare/#findComment-621252 Share on other sites More sharing options...
tribeka Posted August 20, 2008 Author Share Posted August 20, 2008 Thanks for that script. Unfortunately it didn't work! I ensured that the value in the braces after ".$_REQUEST[]." was the same name as the fields in my form but nothing.Not even an email this time. Cheers James Link to comment https://forums.phpfreaks.com/topic/120562-form-to-email-php-script-nightmare/#findComment-621311 Share on other sites More sharing options...
nitation Posted August 21, 2008 Share Posted August 21, 2008 @ Poster, What about trying this; <?php $msg = "Sender's Name:\t$_POST[name]\n"; $msg .= "Sender's E-Mail:\t$_POST[email]\n"; $msg .= "Sender's Comment:\t$_POST[comment]\n\n"; $mailheaders = "From: Message From My Website <[email protected]>\n"; $mailheaders .= "Reply-To: $email\n\n"; mail("[email protected]", "Contact Form", $msg, $mailheaders); echo "<H3 align=center>Thank you, $_POST[name] </H1>"; echo "<P align=center>One of our consultants will get back to you shortly</P>"; ?> Link to comment https://forums.phpfreaks.com/topic/120562-form-to-email-php-script-nightmare/#findComment-621561 Share on other sites More sharing options...
iversonm Posted August 21, 2008 Share Posted August 21, 2008 i would highly recommend not using $_REQUEST[] it is just pure laziness and its unsafe use $_POST or $_GET depending on what your dealing with Link to comment https://forums.phpfreaks.com/topic/120562-form-to-email-php-script-nightmare/#findComment-621567 Share on other sites More sharing options...
tribeka Posted August 21, 2008 Author Share Posted August 21, 2008 Thanks Nitation That didn't work either. I suspect I'm missing something really obvious as I have tried about 5 scripts kindly volunteered by forum users and none seem to work, although I think I'm copying them verbatim and making the appropriate changes (email address etc) My site is uploaded to a Linux server. I'm putting the PHP files in the same directory (htdocs) as the html files. Any ideas as to what I might be doing wrong would be appreciated. Many thanks James Link to comment https://forums.phpfreaks.com/topic/120562-form-to-email-php-script-nightmare/#findComment-621835 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.