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
dankingsley
Forum Newbie
Posts: 8 Joined: Wed Oct 04, 2006 6:17 am
Post
by dankingsley » Wed Oct 04, 2006 6:20 am
JayBird | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi. I have been trying to set up a simple form for a little while now. It is basically to allow people to tell a friend about a website. There is an error every time i try, can someone please let me know what I have done wrong!
The form code is:Code: Select all
<p><img border="0" src="images/tell_a_friend.png" width="423" height="24"></p>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
<tr>
<td width="100%"><p>Pass the word on, tell other people about Spoken Groove!</p>
<p>
<form action="formtoemail_friend.php" method="post">
<table border="0" cellspacing="5">
<tr><td align="left"><p>Your Name:</p></td><td align="left">
<input type="text" size="36" name="Name"></td></tr>
<tr><td align="left"><p>Your Email address:</p></td><td align="left">
<input type="text" size="36" name="Email"></td></tr>
<tr><td align="left"><p>Friends Name:</p></td><td align="left">
<input type="text" size="36" name="FName"></td></tr>
<tr><td align="left"><p>Friends Email address:</p></td><td align="left">
<input type="text" size="36" name="FEmail"></td></tr>
<tr><td valign="top" align="left"><p>Message:</p></td><td align="left">
<textarea name="Message" rows="6" cols="30"></textarea></td></tr>
<tr><td align="left"> </td><td align="left"><input type="submit" value="Send"></td></tr>
</table>
</form>
</td>
</tr>
</table>
The code for formtoemail_friend.php is:
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Spoken Groove</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Language" content="en-uk">
</head>
<body bgcolor="#ffffff" text="#000000">
<div>
<center>
<p><font face="arial" size="2"><a href="index.php?location=thanks_friend">Click here to continue</a></font></p>
</center>
</div>
</body>
</html>
<?php
$name=$_post['Name'];
$email=$_post['Email'];
$fname=$_post['FName'];
$femail=$_post['FEmail'];
$message=$_post['Message];
$msg="$name says: $message;
$subject = "Spoken Groove";
$headers = "From: $email \r\n";
$headers .= "Reply-To: $email \r\n";
$headers .= "Return-Path: $email \r\n";
mail($femail, $subject, $msg, $headers);
?>
JayBird | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
impulse()
Forum Regular
Posts: 748 Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:
Post
by impulse() » Wed Oct 04, 2006 6:31 am
What's the error?
impulse()
Forum Regular
Posts: 748 Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:
Post
by impulse() » Wed Oct 04, 2006 6:32 am
dankingsley
Forum Newbie
Posts: 8 Joined: Wed Oct 04, 2006 6:17 am
Post
by dankingsley » Wed Oct 04, 2006 6:33 am
Sorry I forgot to post that!
Parse error: syntax error, unexpected $end in *********************/formtoemail_friend.php on line 36
impulse()
Forum Regular
Posts: 748 Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:
Post
by impulse() » Wed Oct 04, 2006 6:36 am
Which one's line 36?
I'm assuming it's the line with
on it.
dankingsley
Forum Newbie
Posts: 8 Joined: Wed Oct 04, 2006 6:17 am
Post
by dankingsley » Wed Oct 04, 2006 6:40 am
impulse() wrote:
Should be
Yeh well spotted! but it doesnt solve the problem, same error message (and i did clear my history!)
dankingsley
Forum Newbie
Posts: 8 Joined: Wed Oct 04, 2006 6:17 am
Post
by dankingsley » Wed Oct 04, 2006 6:41 am
nope. 36 is the last line! it doesnt help at all!
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Wed Oct 04, 2006 6:50 am
errors become obvious when you use sytnax highlighting
Hint, there are 2 errors...1 mentions above and another one...a missing single quote (')
impulse()
Forum Regular
Posts: 748 Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:
Post
by impulse() » Wed Oct 04, 2006 7:03 am
I've found it. Just look for the place where the code starts bleeding
dankingsley
Forum Newbie
Posts: 8 Joined: Wed Oct 04, 2006 6:17 am
Post
by dankingsley » Wed Oct 04, 2006 9:04 am
thanks
think that should be sorted now!
dankingsley
Forum Newbie
Posts: 8 Joined: Wed Oct 04, 2006 6:17 am
Post
by dankingsley » Wed Oct 04, 2006 9:11 am
actually! there is now no error, so it seems to be working, but if I test it out with a couple of my email address, no email is sent! Is there maybe something else which I have done wrong to stop it from working?
Here is the correct php at the moment:
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Spoken Groove</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Language" content="en-uk">
</head>
<body bgcolor="#ffffff" text="#000000">
<div>
<center>
<p><font face="arial" size="2"><a href="index.php?location=thanks_friend">Click here to continue</a></font></p>
</center>
</div>
</body>
</html>
<?php
$name=$_post['Name'];
$email=$_post['Email'];
$fname=$_post['FName'];
$femail=$_post['FEmail'];
$message=$_post['Message'];
$msg="$name says: $message";
$subject = "Spoken Groove";
$headers = "From: $email \r\n";
$headers .= "Reply-To: $email \r\n";
$headers .= "Return-Path: $email \r\n";
mail($femail, $subject, $msg, $headers);
?>
n00b Saibot
DevNet Resident
Posts: 1452 Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:
Post
by n00b Saibot » Wed Oct 04, 2006 9:12 am
$femail shoud be $email on last line
dankingsley
Forum Newbie
Posts: 8 Joined: Wed Oct 04, 2006 6:17 am
Post
by dankingsley » Wed Oct 04, 2006 9:14 am
n00b Saibot wrote: $femail shoud be $email on last line
are you sure? I dont think it should be, since that should be the email addy that the form is being sent to, and that is $femail.
n00b Saibot
DevNet Resident
Posts: 1452 Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:
Post
by n00b Saibot » Wed Oct 04, 2006 9:42 am
sorry my bad.
the $_post should be $_POST.
dankingsley
Forum Newbie
Posts: 8 Joined: Wed Oct 04, 2006 6:17 am
Post
by dankingsley » Wed Oct 04, 2006 9:43 am
ahhh! that shows my complete lack in php
Works now though, thanks for that! I should really do a more secure form! but this will have to do for now i guess. Thanks