Form to email problems

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tribeka
Forum Newbie
Posts: 3
Joined: Fri Aug 15, 2008 2:49 pm

Form to email problems

Post 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
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: Form to email problems

Post 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.
tribeka
Forum Newbie
Posts: 3
Joined: Fri Aug 15, 2008 2:49 pm

Re: Form to email problems

Post 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
User avatar
idevlin
Forum Commoner
Posts: 78
Joined: Tue Jun 26, 2007 1:10 pm
Location: Cambridge, UK

Re: Form to email problems

Post by idevlin »

Shouldn't there be single quotes around each of the field names? e.g. $_REQUEST['message']
tribeka
Forum Newbie
Posts: 3
Joined: Fri Aug 15, 2008 2:49 pm

Re: Form to email problems

Post 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
Post Reply