From: Bruce Gilbert [mailto:[EMAIL PROTECTED]
> Hello,
>
> I am trying to get a form to work integrating html with PHP.
>
> the code I have is:
>
> <?
> $form_block = "
> <FORM METHOD=\"POST\" ACTION=\"$PHP_SELF\">
> <p><strong>Your Name:</strong>< /br>
> <INPUT type=\"text\" NAME=\"senders_name\" SIZE=30></p>
> <p><strong><p><Your E-mail Address:</strong>< /br>
> <INPUT type=\"text\" NAME=\"senders_email\" SIZE=30></p>
> <p><strong>Message:</strong>< /br>
> <TEXTAREA NAME=\"message\" COLS=30 ROWS=5 WRAP=virtual></TEXTAREA></p>
> <INPUT type=\"hidden\" name=\"op\" value=\"ds\">
> <p><INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"Send this
> Form\"></p>
> </FORM>";
>
> if ($_POST['op'] !="ds") {
> // they need to see the form
> echo "$form_block";
> } else if ($_POST['op'] =="ds") {
> //check value of $_POST['sender name']
> if ($_POST['sender_name'] =="") {
> $name_err = "<font color=red>Please
> enter your name!</font>< /br>";
> $send ="no";
> }
> //check value of $_POST['sender_email']
> if ($POST['sender_email'] =="") {
> $email_err ="<font color=red>Please enter your
> email address!</font>< /br>";
> $send= "no";
> }
> //check value of $_POST['message']
> if ($POST['message'] =="") {
> $message_err = "<font color=red>Please enter a
> message!</font>< /br>";
> $send ="no";
> }
> if ($send !="no") {
> //it's o.k to send, so build the mail
> $msg ="E-MAIL SENT FROM WWW SITE\n";
> $msg .="Senders Name:
> $POST['senders_name']\n";
> $msg .="Senders E-MAIL:
> $POST['senders_email']\n";
> $msg .="Senders Name: $POST['message']\n\n";
> $to ="[EMAIL PROTECTED]";
> $subject = "There has been a disturbance in the Force";
> $mailheaders .="Reply-To: $_POST['sender_email']\n";
> //send the mail
> mail ($to, $subject, $msg, $mailheaders);
> //display confirmation to user
> echo "<p>mail has been sent!</p>";
> } else if ($send =="no") {
> //print error messages
> echo "$name_err";
> echo "$email_err";
> echo "$message_err";
> echo "$form_block";
> }
> }
> ?>
>
> and the error I get is:
>
> Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE,
> expecting T_STRING or T_VARIABLE or T_NUM_STRING in
> /hsphere/local/home/bruceg/inspired-evolution.com/Contact_Form
> _test.php
> on line 58
>
> the above code is just the php form part of the page not the entire
> code, so it would be impossible to determine line 58, but I was hoping
> someone would be able to spot the problem or at least explain the
> error to a relative newbie.
>
> thanks
I don't think your error message is indicative of this, but PHP /will/
choke on your lines that include array key references in them, such as:
$mailheaders .="Reply-To: $_POST['sender_email']\n";
In those cases, you need to either leave the quotes for the variable or
enclose the var in curly braces:
$mailheaders .="Reply-To: " . $_POST['sender_email'] . "\n";
$mailheaders .="Reply-To: {$_POST['sender_email']}\n";
I generally prefer the latter, but it's entirely up to the user.
Try fixing those and see if it still errors.
--
Mike Johnson Smarter Living, Inc.
Web Developer www.smartertravel.com
[EMAIL PROTECTED] (617) 886-5539
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php