Page 1 of 1

Form help again Please

Posted: Thu Sep 25, 2003 2:32 pm
by sroussie
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>

Posted: Thu Sep 25, 2003 3:03 pm
by Unipus
Try echoing out your variables in the PHP page. It looks like it should work, so I'm guessing the problem is in your email code... probably you've got some character in the text you're sending that needs to be escaped with addslashes() or htmlspecialchars() or one of the other handlers.

Posted: Thu Sep 25, 2003 3:29 pm
by sroussie
Hi,

I tried echoing the variables and they displayed on the screen. SO now I am really confused as to why it doesn't work.

Sue

Posted: Thu Sep 25, 2003 4:16 pm
by microthick
While this might not change anything, try simplifying the mail() call:

Code: Select all

mail($sendto, $subject, $content, $username);

Posted: Thu Sep 25, 2003 7:02 pm
by Cruzado_Mainfrm
um, have you set a SMTP in your server? have you configured the php.ini file with it?
the mail() function won't work without setting up the smtp settings

Posted: Thu Sep 25, 2003 7:17 pm
by sroussie
w do I set the SMTP? Should I assume SMTP is working if I get the email - even though the info isn't there?

Sue

Posted: Thu Sep 25, 2003 7:30 pm
by sroussie
microthick wrote:While this might not change anything, try simplifying the mail() call:

Code: Select all

mail($sendto, $subject, $content, $username);
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.

Sue

Posted: Fri Sep 26, 2003 6:36 am
by twigletmac
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.

Code: Select all

mail("$sendto","Subject: $subject","Message: $content","Name: $username");
could become

Code: Select all

$message =<<<END

Message: $content

Name: $username
END;

mail($sendto, $subject, $message);
Mac

Posted: Sat Sep 27, 2003 9:55 am
by sroussie
Thanks much, that worked. I was kind of wondering about that myself. I understand it a lot better now. I have one last issue to resolve but I want to figure it out if I can before I ask for help.

Thanks,
Sue