Page 1 of 1

Form to email problems

Posted: Fri Aug 15, 2008 2:59 pm
by tribeka
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 and then type /feedback.php you'll see the simple form I'm using for testing purposes (ignore /request.html for the time being). Another file (also on the server) called sendmail.php is supposed to process the data and email it to root@scavengers-uk.com and then return the visitor to thanks.php.

The code of sendmail.php is

Code: Select all

<?php
 
mail("root@scavengers-uk.com", "Feedback Form results", $_REQUEST[message], "From: $_REQUEST[email]", "-froot@scavengers-uk.com".$_REQUEST[email]);
 
header( "Location: http://www.scavengers-uk.com/thanks.php" );
 
?>
Thing is, nothing happens. Once or twice I got the email but with no content and then it stopped working altogether (at least it redirects to thanks.php, though!)

Many thanks for your help

James

Re: Form to email problems

Posted: Fri Aug 15, 2008 8:35 pm
by Jade
Hi James, do you have fields on your email form with the names message and email? It seems to me that your field names got renamed. If that happens when the server requests those specific fields it won't find anything because they're not there.

Re: Form to email problems

Posted: Sat Aug 16, 2008 6:02 am
by tribeka
Hi there

Thanks for getting back to me.

I had another look at feedback.php and yes, I think I have the fields that sendmail.php looks for. This is the feedback.php code (I'm not using the request form currently uploaded until I can get this simpler one to work.)

Code: Select all

<FORM method=post action="sendmail.php">
Email: <INPUT name="email" type="text"><br>
Message:<br>
<TEXTAREA name="message">
</textarea><br>
<input type=submit> 
</FORM>
Thanks for your help

James

Re: Form to email problems

Posted: Sat Aug 16, 2008 6:44 am
by idevlin
Shouldn't there be single quotes around each of the field names? e.g. $_REQUEST['message']

Re: Form to email problems

Posted: Sun Aug 17, 2008 11:07 am
by tribeka
When I add single quotes as suugested I get

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/fhlinux143/s/scavengers-uk.com/user/htdocs/sendmail.php on line 3

Surely this can't be so complicated??

Cheers

James