Form help again Please
Moderator: General Moderators
Form help again Please
HI,
I have tried to obtain info from my form using php but only manage to get the Subject line and one line in the message. I cannot get any of the other fields. I even removed all fields except three and I still cannot get the last field. Everything else works. I am very new to this. I have enclosed the code I am using.
Thanks.
HTML FORM
<html>
<head>
</HEAD>
<BODY BGCOLOR=#FFFFFF LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>
<form action="contact_small.php" method="POST">
Subject:<input type="text" name="subject" size="60" tabindex="1">
<p>Message: <textarea name="content" rows="4" cols="58" tabindex="2"></textarea></p>
<p>Name: <input type="text" name="username" tabindex="3"></p>
<p></p>
<p>
<input type="submit" name="submit" value="Submit"></p>
</form>
</body>
</html>
PHP File
<html>
<head>
<title>Title here!</title>
</head>
<body>
<?php
$sendto = "sroussie@adelphia.net";
$subject = $_POST['subject'];
$content = $_POST['content'];
$username = $_POST['username'];
mail("$sendto","Subject: $subject","Message: $content","Name: $username");
echo 'Thank you.'
?>
</body>
</html>
I have tried to obtain info from my form using php but only manage to get the Subject line and one line in the message. I cannot get any of the other fields. I even removed all fields except three and I still cannot get the last field. Everything else works. I am very new to this. I have enclosed the code I am using.
Thanks.
HTML FORM
<html>
<head>
</HEAD>
<BODY BGCOLOR=#FFFFFF LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>
<form action="contact_small.php" method="POST">
Subject:<input type="text" name="subject" size="60" tabindex="1">
<p>Message: <textarea name="content" rows="4" cols="58" tabindex="2"></textarea></p>
<p>Name: <input type="text" name="username" tabindex="3"></p>
<p></p>
<p>
<input type="submit" name="submit" value="Submit"></p>
</form>
</body>
</html>
PHP File
<html>
<head>
<title>Title here!</title>
</head>
<body>
<?php
$sendto = "sroussie@adelphia.net";
$subject = $_POST['subject'];
$content = $_POST['content'];
$username = $_POST['username'];
mail("$sendto","Subject: $subject","Message: $content","Name: $username");
echo 'Thank you.'
?>
</body>
</html>
-
microthick
- Forum Regular
- Posts: 543
- Joined: Wed Sep 24, 2003 2:15 pm
- Location: Vancouver, BC
While this might not change anything, try simplifying the mail() call:
Code: Select all
mail($sendto, $subject, $content, $username);-
Cruzado_Mainfrm
- Forum Contributor
- Posts: 346
- Joined: Sun Jun 15, 2003 11:22 pm
- Location: Miami, FL
I tried the above and it worked. Then I added the label for subject and content. That worked. As soon as I added the label for username it stopped working. Now I just have to figure out why.microthick wrote:While this might not change anything, try simplifying the mail() call:
Code: Select all
mail($sendto, $subject, $content, $username);
Sue
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
The fourth parameter in the mail() function is for e-mail headers, so if you want the username to be part of the message then it should be added to the content.
could become
Mac
Code: Select all
mail("$sendto","Subject: $subject","Message: $content","Name: $username");Code: Select all
$message =<<<END
Message: $content
Name: $username
END;
mail($sendto, $subject, $message);