Jump to content

What is wrong with my code?


dandare

Recommended Posts

I am new to php and I am pulling my hair out. I made a form and I can't figure out what's wrong with the code. I keep getting this error when I try to click on the link on my site: Parse error: syntax error, unexpected $end in /home/petra/public_html/contactus.php on line 321

 

My website is www.stoneveneer.biz

 

Any help would be greatly appreciated.

 

The code of the page is:

<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>stone veneer - contact us</title>
<meta name="keywords" content="stone veneer, cultured stone, manufactured stone, petra stone, faux stone, fake brick">

<script language="JavaScript">
<!--
function FP_swapImg() {//v1.0
var doc=document,args=arguments,elm,n; doc.$imgSwaps=new Array(); for(n=2; n<args.length;
n+=2) { elm=FP_getObjectByID(args[n]); if(elm) { doc.$imgSwaps[doc.$imgSwaps.length]=elm;
elm.$src=elm.src; elm.src=args[n+1]; } }
}

function FP_preloadImgs() {//v1.0
var d=document,a=arguments; if(!d.FP_imgs) d.FP_imgs=new Array();
for(var i=0; i<a.length; i++) { d.FP_imgs[i]=new Image; d.FP_imgs[i].src=a[i]; }
}

function FP_getObjectByID(id,o) {//v1.0
var c,el,els,f,m,n; if(!o)o=document; if(o.getElementById) el=o.getElementById(id);
else if(o.layers) c=o.layers; else if(o.all) el=o.all[id]; if(el) return el;
if(o.id==id || o.name==id) return o; if(o.childNodes) c=o.childNodes; if(c)
for(n=0; n<c.length; n++) { el=FP_getObjectByID(id,c[n]); if(el) return el; }
f=o.forms; if(f) for(n=0; n<f.length; n++) { els=f[n].elements;
for(m=0; m<els.length; m++){ el=FP_getObjectByID(id,els[n]); if(el) return el; } }
return null;
}
// -->
</script>

<link rel="stylesheet" type="text/css" href="petrastone.css">

</head>

<body>

<div align="center">
<table border="1" width="700" cellspacing="0" cellpadding="0" id="table1" bordercolor="#000000" bgcolor="#CCCCCC">
	<tr>
		<td>
		<img border="0" src="petrastone2.jpg" width="700" height="157"></td>
	</tr>
	<tr>
		<td>
		<a href="index.htm">
		<img border="0" id="img1" src="button2.jpg" height="20" width="100" alt="Home" onmouseover="FP_swapImg(1,0,/*id*/'img1',/*url*/'button3.jpg')" onmouseout="FP_swapImg(0,0,/*id*/'img1',/*url*/'button2.jpg')" onmousedown="FP_swapImg(1,0,/*id*/'img1',/*url*/'button4.jpg')" onmouseup="FP_swapImg(0,0,/*id*/'img1',/*url*/'button3.jpg')" fp-style="fp-btn: Border Bottom 9; fp-font-color-hover: #FF0000; fp-orig: 0" fp-title="Home"></a><a href="products.htm"><img border="0" id="img2" src="button5.jpg" height="20" width="100" alt="Products" onmouseover="FP_swapImg(1,0,/*id*/'img2',/*url*/'button6.jpg')" onmouseout="FP_swapImg(0,0,/*id*/'img2',/*url*/'button5.jpg')" onmousedown="FP_swapImg(1,0,/*id*/'img2',/*url*/'button7.jpg')" onmouseup="FP_swapImg(0,0,/*id*/'img2',/*url*/'button6.jpg')" fp-style="fp-btn: Border Bottom 9; fp-font-color-hover: #FF0000; fp-orig: 0" fp-title="Products"></a><a href="homeowners.htm"><img border="0" id="img3" src="button8.jpg" height="20" width="100" alt="Homeowners" fp-style="fp-btn: Border Bottom 9; fp-font-color-hover: #FF0000; fp-orig: 0" fp-title="Homeowners" onmouseover="FP_swapImg(1,0,/*id*/'img3',/*url*/'button9.jpg')" onmouseout="FP_swapImg(0,0,/*id*/'img3',/*url*/'button8.jpg')" onmousedown="FP_swapImg(1,0,/*id*/'img3',/*url*/'buttonA.jpg')" onmouseup="FP_swapImg(0,0,/*id*/'img3',/*url*/'button9.jpg')"></a><a href="builders.htm"><img border="0" id="img4" src="buttonE.jpg" height="20" width="100" alt="Builders" onmouseover="FP_swapImg(1,0,/*id*/'img4',/*url*/'buttonF.jpg')" onmouseout="FP_swapImg(0,0,/*id*/'img4',/*url*/'buttonE.jpg')" onmousedown="FP_swapImg(1,0,/*id*/'img4',/*url*/'button10.jpg')" onmouseup="FP_swapImg(0,0,/*id*/'img4',/*url*/'buttonF.jpg')" fp-style="fp-btn: Border Bottom 9; fp-font-color-hover: #FF0000; fp-orig: 0" fp-title="Builders"></a><a href="architects.htm"><img border="0" id="img5" src="button11.jpg" height="20" width="100" alt="Architects" onmouseover="FP_swapImg(1,0,/*id*/'img5',/*url*/'button12.jpg')" onmouseout="FP_swapImg(0,0,/*id*/'img5',/*url*/'button11.jpg')" onmousedown="FP_swapImg(1,0,/*id*/'img5',/*url*/'button13.jpg')" onmouseup="FP_swapImg(0,0,/*id*/'img5',/*url*/'button12.jpg')" fp-style="fp-btn: Border Bottom 9; fp-font-color-hover: #FF0000; fp-orig: 0" fp-title="Architects"></a><a href="projects.htm"><img border="0" id="img6" src="button14.jpg" height="20" width="100" alt="Projects" onmouseover="FP_swapImg(1,0,/*id*/'img6',/*url*/'button15.jpg')" onmouseout="FP_swapImg(0,0,/*id*/'img6',/*url*/'button14.jpg')" onmousedown="FP_swapImg(1,0,/*id*/'img6',/*url*/'button16.jpg')" onmouseup="FP_swapImg(0,0,/*id*/'img6',/*url*/'button15.jpg')" fp-style="fp-btn: Border Bottom 9; fp-font-color-hover: #FF0000; fp-orig: 0" fp-title="Projects"></a><a href="contactus.php"><img border="0" id="img8" src="button23.jpg" height="20" width="100" alt="Contact Us" onmouseover="FP_swapImg(1,0,/*id*/'img8',/*url*/'button24.jpg')" onmouseout="FP_swapImg(0,0,/*id*/'img8',/*url*/'button23.jpg')" onmousedown="FP_swapImg(1,0,/*id*/'img8',/*url*/'button25.jpg')" onmouseup="FP_swapImg(0,0,/*id*/'img8',/*url*/'button24.jpg')" fp-style="fp-btn: Border Bottom 9; fp-font-color-hover: #FF0000; fp-orig: 0" fp-title="Contact Us"></a></td>
	</tr>
	<tr>
		<td height="12"> <table border="0" width="700" cellspacing="0" cellpadding="0" id="table2">
			<tr>
				<td width="21" rowspan="13"> </td>
				<td width="372" align="center"> </td>
				<td align="right" rowspan="13">
				<img border="1" src="coolpic4.jpg" width="285" height="225"></td>
				<td width="21" rowspan="13"> </td>
			</tr>
			<tr>
				<td width="372" align="center"><font face="Engravers MT">
				Contact</font></td>
			</tr>
			<tr>
				<td width="372" align="center"><hr width="290"></td>
			</tr>
			<tr>
				<td width="372" align="center"> </td>
			</tr>
			<tr>
				<td width="372" align="center"><b><font face="Arial">Petra 
				Stone of North Central Arkansas</font></b></td>
			</tr>
			<tr>
				<td width="372" align="center">202 S. Cherry Suite B</td>
			</tr>
			<tr>
				<td width="372" align="center">Harrison, Arkansas 72061</td>
			</tr>
			<tr>
				<td width="372" align="center">(870) 741-8429</td>
			</tr>
			<tr>
				<td width="372" align="center"> </td>
			</tr>
			<tr>
				<td width="372" align="center"> </td>
			</tr>
			<tr>
				<td width="372" align="center"> </td>
			</tr>
			<tr>
				<td width="372" align="center"> </td>
			</tr>
			<tr>
				<td width="372" align="center"> </td>
			</tr>
			</table>
		<p> </p>
		<div align="center">
			<table border="0" cellpadding="0" width="600" bordercolor="#000000" style="border-collapse: collapse" id="table3">
				<tr>
					<td>
  <?php  if($_POST['submit']) {
/*Here we are going to declare the variables*/
$name = $_POST['Name'];
$Address = $_POST['Address'];
$Address = $_POST['Address'];
$City = $_POST['City'];
$State = $_POST['State'];
$Zip = $_POST['Zip'];
$HomePhone = $_POST['Home Phone'];
$BusinessPhone = $_POST['Business Phone'];
$Email = $_POST['E-mail'];
$Message = $_POST['Message'];
$Besttimetocontact = $_POST['Best time to contact'];
//Save visitor name and entered message into one variable:
$formcontent="VISITOR NAME: $name\n\nFEEDBACK: $message";
$recipient = " *[email protected]";
$subject = "Contact Form";
$mailheader = "From: $email\r\n";
$mailheader .= "Reply-To: $email\r\n";
$mailheader .= "MIME-Version: 1.0\r\n";
if(mail($recipient, $subject, $formcontent, $mailheader))
  {
     echo "Thank You!";
  }
else
  {
     echo "error, email not sent.";
  }  
?>  		



        <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
    <table width="100%" border="0" cellspacing="2" cellpadding="0">
    <tr>
      <td width="150" align='right'>Name:</td>
      <td><input name="name" type="text" id="name" tabindex="1" size="50" maxlength="50" /></td>
    </tr>
    <tr>
      <td width="150" align='right'>Address:</td>

      <td><input name="add1" type="text" id="add1" tabindex="2" size="50" maxlength="50" /></td>
    </tr>
    <tr>
      <td width="150" align='right'>Address:</td>
      <td><input name="add2" type="text" id="add2" tabindex="3" size="50" maxlength="50" /></td>
    </tr>
    <tr>
      <td width="150" align='right'>City:</td>

      <td><input name="city" type="text" id="city" tabindex="4" size="50" maxlength="50" /></td>
    </tr>
    <tr>
      <td width="150" align='right'>State:</td>
      <td>
  
<select name="state" class="quote" style='width: 45px' tabindex="5">
  <option value="AL">AL</option>
  <option value="AK">AK</option>

  <option value="AZ">AZ</option>
  <option value="AR" selected="selected">AR</option>
  <option value="CA">CA</option>
  <option value="CT">CT</option>  
  <option value="DE">DE</option>
  <option value="DC">DC</option>

  <option value="FL">FL</option>  
  <option value="GA">GA</option>
  <option value="HI">HI</option>
  <option value="ID">ID</option>
  <option value="IL">IL</option>
  <option value="IN">IN</option>

  <option value="IA">IA</option>
  <option value="KS">KS</option>
  <option value="KY">KY</option>  
  <option value="LA">LA</option>
  <option value="ME">ME</option>
  <option value="MD">MD</option>

  <option value="MA">MA</option>
  <option value="MI">MI</option>
  <option value="MN">MN</option>
  <option value="MS">MS</option>
  <option value="MO">MO</option>
  <option value="MT">MT</option>

  <option value="NE">NE</option>
  <option value="NV">NV</option>
  <option value="NH">NH</option>
  <option value="NJ">NJ</option>  
  <option value="NM">NM</option>
  <option value="NY">NY</option>

  <option value="NC">NC</option>
  <option value="ND">ND</option>
  <option value="OH">OH</option>
  <option value="OK">OK</option>  
  <option value="OR">OR</option>
  <option value="PA">PA</option>

  <option value="RI">RI</option>
  <option value="SC">SC</option>
  <option value="SD">SD</option>
  <option value="TN">TN</option>
  <option value="TX">TX</option>
  <option value="UT">UT</option>

  <option value="VT">VT</option>
  <option value="VA">VA</option>
  <option value="WA">WA</option>
  <option value="WI">WI</option>
  <option value="WY">WY</option>
</select>	  
  
  </td>

    </tr>
    <tr>
      <td width="150" align='right'>Zip:</td>
      <td><input name="zip" type="text" id="zip" size="5" maxlength="5" tableindex='6'/></td>
    </tr>
    <tr>
      <td width="150"> </td>
      <td> </td>

    </tr>
    <tr>
      <td width="150" align='right'>Home Phone:</td>
      <td>
        <input name="HomePhone" type="text" id="HomePhone" tabindex="7" size="15" maxlength="15" />
       </td>
    </tr>

    <tr>
      <td width="150" align='right'>Business Phone:</td>
      <td>
        <input name="BusinessPhone" type="text" id="BusinessPhone" size="15" maxlength="15" />
        
        </td>
    </tr>
    <tr>

      <td width="150"> </td>
      <td> </td>
    </tr>
    <tr>
      <td width="150" align='right'>E-Mail:</td>
      <td><input name="email" type="text" id="email" size="50" maxlength="50" /></td>
    </tr>
    <tr>

      <td width="150"> </td>
      <td> </td>
    </tr>
    <tr>
      <td width="150" align='right' valign='top'>Message:</td>
      <td><textarea name="message" cols="45" rows="10" id="message"></textarea></td>
    </tr>
    <tr>

      <td width="150"> </td>
      <td> </td>
    </tr>
        <tr>
      <td width="150"> </td>
          </tr>
    <tr>
      <td width="150" align='right'>Best time to contact: </td>
      <td><select name="time">
  <option selected="selected">Choose</option>
  	<optgroup label='--------'>

        <option value="8-12">8am-12pm</option>
        <option value="12-4">12pm-4pm</option>
        <option value="4-8">4pm-8pm</option>
	</optgroup>
      </select>
      </td>
    </tr>

    <tr>
      <td width="150"> </td>
      <td> </td>
    </tr>
  </table><br />
  <input type="submit" name="submit" value="Submit" />
  

      
   </form>
   
</td>
				</tr>
			</table>
		</div>

		<table border="0" cellpadding="0" width="700" style="border-collapse: collapse" id="table4">
			<tr>
				<td align="center">Petra Stone of North Central Arkansas</td>
			</tr>
			<tr>
				<td align="center">Copyright <font face="Times New Roman">© 
				2006-2007</font></td>
			</tr>
			<tr>
				<td align="center"> </td>
			</tr>
		</table>
		</td>
	</tr>
	</table>
</div>

</body>

</html>

Link to comment
https://forums.phpfreaks.com/topic/49684-what-is-wrong-with-my-code/
Share on other sites

the php coding in the middle is missing a closing brace from the first "if" statement. try this

<?php  if($_POST['submit']) 
{
/*Here we are going to declare the variables*/
$name = $_POST['Name'];
$Address = $_POST['Address'];
$Address = $_POST['Address'];
$City = $_POST['City'];
$State = $_POST['State'];
$Zip = $_POST['Zip'];
$HomePhone = $_POST['Home Phone'];
$BusinessPhone = $_POST['Business Phone'];
$Email = $_POST['E-mail'];
$Message = $_POST['Message'];
$Besttimetocontact = $_POST['Best time to contact'];
//Save visitor name and entered message into one variable:
$formcontent="VISITOR NAME: $name\n\nFEEDBACK: $message";
$recipient = " *[email protected]";
$subject = "Contact Form";
$mailheader = "From: $email\r\n";
$mailheader .= "Reply-To: $email\r\n";
$mailheader .= "MIME-Version: 1.0\r\n";
if(mail($recipient, $subject, $formcontent, $mailheader))
  {
     echo "Thank You!";
  }
else
  {
     echo "error, email not sent.";
  }
}  
?>  		

 

edit: when posting code with an error showing a line number, please show where that line number is, that way helpers may be able to find the error faster than having to possibly count 300 plus lines....

does your email start with a space and then a * ???

 

$recipient = " *[email protected]"; //it does here

 

if the mail function is returning "true" which it is doing as you are getting the "if value is true" portion of the if else script then it has found no problems with what you have given it, even if that email address is rubbish, as long as it is properly formatted it will go ( to nowhere) but go

 

 

Yeah it was messed up. Thanks. I have one more issue.... on the following line:

$formcontent="VISITOR NAME: $name\n\nFEEDBACK: $message";

 

It is only sending the message portion of my form. If I want the rest sent too would I code it this way:?  $formcontent="VISITOR NAME: $name\n\nFEEDBACK: $name $address $city $state $zip $message";

 

Forgive me for not knowing the syntax but I am brand new to Php and I need to get this working today.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.