Please help with Simple form script and error

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
Kobus
Forum Newbie
Posts: 2
Joined: Wed May 27, 2009 4:24 pm

Please help with Simple form script and error

Post by Kobus »

Hello All

I am having some issues with a simple form script. The script works fine in my testing server (Ipower) but when I move it to my site host (JustHost and Godaddy) this script no longer works.
I get this error Parse error: syntax error, unexpected T_IF in /home/inourow1/public_html/html/thanks.php on line 27

This is the form script

Code: Select all

 
<form action="thankyou.php" method="post">
            <p>Name<br />
            <input name="name" type="text" size="40">
            </p>
            <p>            Email Address *<br>
            <input name="emailaddress" type="text" size="40">
            <br>
            </p>
            <p>Street<br>
            <input name="streetname" type="text" size="40">
            <br>
            </p>
            <p>City / State / Zip<br>
            <input name="city" type="text" size="21">
            <input name="state" type="text" size="5">
            <input name="zip" type="text" size="10">
            <br>
            </p>
            <p>Phone Number<br>
            <input name="phonenumber" type="text" size="40">
            </p>
            <p>
              <input type="submit" name="Submit" value="Submit">
          </p>
        </form>
 
and this is the php script

Code: Select all

 
 
<?PHP
global $_POST;
$name = $_POST["name"] ;
$emailaddress = $_POST["emailaddress"];
$streetname = $_POST["streetname"];
$city = $_POST["city"];
$state = $_POST["state"];
$zip = $_POST["zip"];
$phonenumber = $_POST["phonenumber"];
 
$to = "tazzmans1977@gmail.com";
$subject = "In Our Own Backyeard Website Form Submission";
$headers = "From: $emailaddress\n";
 
$message = "A visitor to the In our own backyard site has filled out the following information.\n
Name: $name
Email Address: $emailaddress
Address: $streetname
City: $city
State: $state
Zip: $zip
Phone Number: $phonenumber";
 
if (preg_match(' /[\r\n,;\'"]/ ', $_POST['emailaddress'])) {
  exit('Invalid Email Address');
}
else {
mail($to,$subject,$message,$headers);
}
 
?>
 
 
its called by this code in the body of the thankyou.php page

Code: Select all

 
<?php include("thanks.php"); ?>
 
here are links to the actual pages
broken form - http://www.inourownbackyard.us/html/join.html

working form - http://jessicamans.com/dev/ioob/html/join.html

please if anyone can help me, I will really appreciate it.

Kobus
:banghead:
Last edited by Benjamin on Fri May 29, 2009 10:25 am, edited 1 time in total.
Reason: Changed code type from text to php.
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: Please help with Simple form script and error

Post by Darhazer »

I didn't seen such problem before, but maybe a server settings like magic_quotes is causing the error.
Try this:

Code: Select all

 
$message = <<<EOL
A visitor to the In our own backyard site has filled out the following information.\n
Name: $name
Email Address: $emailaddress
Address: $streetname
City: $city
State: $state
Zip: $zip
Phone Number: $phonenumber
EOL;
P.S. I was able to submit both forms
Kobus
Forum Newbie
Posts: 2
Joined: Wed May 27, 2009 4:24 pm

Re: Please help with Simple form script and error

Post by Kobus »

yeah, it's kinda strange... The script now works without a hitch, must have been some lag time, between moving the DNS and files to the form catching up.

anyway, thanks for looking into it.
Post Reply