PHP Troubles

This is a discussion on "PHP Troubles" within the PHP Forum section. This forum, and the thread "PHP Troubles are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Aug 31st, 2006, 20:05
Junior Member
Join Date: Jul 2006
Location: Maine
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
PHP Troubles

I am new to PHP and I am having a bit of trouble. I am trying to create a php mail form but I am getting a parse error. I tried following this tutorial. http://www.webreference.com/programm...hpemail/2.html

Here is my html...

<form name="form" method="post" action="contact.php">
<p class="contentsmall">
Required Fields <span class="contentblue">*</span><br />
<br />
Your Company <span class="contentblue">*</span> <br /><input type="text" name="companyname"><br /><br />
Contact Name <span class="contentblue">*</span><br /><input type="text" name="contactname"><br /><br />
Contact Phone <span class="contentblue">*</span><br /><input type="text" name="contactphone"><br /><br />
Contact E-mail <span class="contentblue">*</span><br /><input type="text" name="contactemail" /><br /><br />
Contact Address <span class="contentblue">*</span><br /><input type="text" name="contactaddress" /><br /><br />
Contact City <span class="contentblue">*</span><br /><input type="text" name="contactcity" /><br /><br />
Contact State <span class="contentblue">*</span><br /><input type="text" name="contactstate" /><br /><br />
Contact Zip <span class="contentblue">*</span><br /><input type="text" name="contactzip" /><br /><br /><br />
<span class="contentblue">Property Information</span><br /><br />
Street Address <span class="contentblue">*</span><br /><input type="text" name="streetaddress" /><br /><br />
County <span class="contentblue">*</span><br /><input type="text" name="county" /><br /><br />
City <span class="contentblue">*</span><br /><input type="text" name="city" /><br /><br />
Zip Code <br /><input type="text" name"zipcode" /><br /><br />
Class: &nbsp;&nbsp;&nbsp; <input type="checkbox" name="singlefamily" />Single Family&nbsp; <input type="checkbox" name="multifamily">Multi-Family&nbsp;
<input type="checkbox" name="condo" />Condo<br /><br />
If other please specify<br /><input type="text" name="other" /><br /><br />
Selling Price<br /><input type="text" name="sellingprice" /><br /><br />
Mortgage Amount<br /><input type="text" name="mortgageamount" /><br /><br />
Value Estimate if Refinancing<br /><input type="text" name="valueestimate" /><br /><br /><br />
<span class="contentblue">Owner Information</span><br /><br />
Owner(s)<br /><input type="text" name="owner" /><br /><br />
Home Phone<br /><input type="text" name="homephone" /><br /><br />
Alternate Phone<br /><input type="text" name="alternatephone" /><br /><br /><br />
<span class="contentblue">Borrower/Client</span><br /><br />
Borrower/Client<br /><input type="text" name="borrowerclient" /><br /><br />
Home Phone<br /><input type="text" name="homephone2" /><br /><br />
Alternate Phone<br /><input type="text" name="alternatephone2" /><br /><br /><br />
<span class="contentblue">Real Estate Broker Information</span><br /><br />
Home Phone<br /><input type="text" name="homephone3" /><br /><br />
Alternate Phone<br /><input type="text" name="alternatephone3" /><br /><br /><br />
<span class="contentblue">Comments/Requests</span><br /><br />
If you have any addtional comments, questions, special requests, or information please fill out the input box below. <br /><br />
<textarea name="comments" rows="7" cols="40"></textarea><br /><br />
Hit the "Submit" button and the information you have entered will be sent to us by e-mail. Hit the "Clear" button to reset the form and start from scratch.<br /><br />
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Reset" value="Clear Form">
</form>


Here is the php...

<?php

if (($companyname == "") || ($contactname == "") || ($contactphone == "") || ($contactemail == "") || ($contactaddress == "") || ($contactcity == "") || ($contactstate == "") || ($contactzip == "") || ($streetaddress == "") ($county == "") ($city == ""))
{
echo "<form name=form method=post action=contact.php>";
echo "Please fill out the fields you missed.";
}
if ($companyname == "")
{
echo "Your Company<br><input type=text name=companyname";
}
else
{
echo "<input type=hidden name=companyname value=$companyname>";
}


if ($contactname == "")
{
echo "Contact Name<br><input type=text name=contactname";
}
else
{
echo "<input type=hidden name=contactname value=$contactname>";
}


if ($contactphone == "")
{
echo "Contact Phone<br><input type=text name=contactphone";
}
else
{
echo "<input type=hidden name=contactphone value=$contactphone>";
}


if ($contactemail == "")
{
echo "Contact E-mail<br><input type=text name=contactemail";
}
else
{
echo "<input type=hidden name=contactemail value=$contactemail>";
}


if ($contactaddress == "")
{
echo "Contact Address<br><input type=text name=contactaddress";
}
else
{
echo "<input type=hidden name=contactaddress value=$contactaddress>";
}


if ($contactcity == "")
{
echo "Contact City<br><input type=text name=contactcity";
}
else
{
echo "<input type=hidden name=contactcity value=$contactcity>";
}


if ($contactstate == "")
{
echo "Contact State<br><input type=text name=contactstate";
}
else
{
echo "<input type=hidden name=contactstate value=$contactstate>";
}


if ($contactzip == "")
{
echo "Contact Zip<br><input type=text name=contactzip";
}
else
{
echo "<input type=hidden name=contactzip value=$contactzip>";
}


if ($streetaddress == "")
{
echo "Street Address<br><input type=text name=streetaddress";
}
else
{
echo "<input type=hidden name=streetaddress value=$streetaddress>";
}


if ($county == "")
{
echo "County<br><input type=text name=county";
}
else
{
echo "<input type=hidden name=county value=$county>";
}


if ($city == "")
{
echo "City<br><input type=text name=city";
}
else
{
echo "<input type=hidden name=city value=$city>";
}


if (($companyname == "") || ($contactname == "") || ($contactphone == "") || ($contactemail == "") || ($contactaddress == "") || ($contactcity == "") || ($contactstate == "") || ($contactzip == "") || ($streetaddress == "") ($county == "") ($city == ""))
{
echo "<input type=submit name=submit value=submit>";
echo "<input type=reset name=Reset value=Clear Form>";
echo "</form>";
}
else
{
$personalinfo = "Contact Name: $contactname\nContact Email: $contactemail\nContact Phone: $contactphone\nContact E-mail: $contacteamil\nContact Address: $contactaddress\nContact City: $contactcity\nContact State: $contactstate\nContact Zip $contactzip";
$propertyinfo = "Street Address: $streetaddress\nCounty: $county\nCity: $city\nZip Code: $zipcode\n Class: $singlefamily, $multifamily, $condo\nIf other please specify: $other\nSelling Price: $sellingprice\n Mortgage Amount: $mortgageamount\nValue Estimage If Refinancing: $valueestimate";
$ownerinfo = "Owner(s): $owner\nHome Phone: $homephone\nAlternate Phone: $alternatephone";
$borrowerinfo = "Borrower/Clinet: $borrowerclient\nHome Phone: $homephone2\nAlternate Phone: $alternatephone2";
$brokerinfo = "Home Phone: $homephone3\nAlternate Phone: $alternatephone3";
$comments = "Comments: $comments";

mail ("eric@sebagowebdesign.com", "Appraisal Request Email", $personalifo, $propertyinfo, $ownerinfo, $borrowerinfo, $brokerinfo, $comments);
echo "Thank you for choosing Jordan Bay Appraisal $contactname.";
echo "A response will be sent to $contactemail as soon as possible>";

?>

Thanks.
Reply With Quote

  #2 (permalink)  
Old Sep 1st, 2006, 03:22
Reputable Member
Join Date: Jul 2005
Location: Melksham, Wilts, UK
Posts: 293
Thanks: 0
Thanked 0 Times in 0 Posts
Re: PHP Troubles

Your best bet with a parse error is to look at the line number it grumbles about, as that tells you which area of your script to look at. Without that information, readers here can only guess where to look in a big piece of code. However, I couldn't help but notice that the last else { block in the code posted is missing its } which is certainly an error ... goodness only knows if it's the only error though!

It's generally a good idea to write / test a program section by section. If you have a piece of code that works at 50 lines long which then fails when you extend it to 60 lines, you know to look in the 10 lines just added.

When faced with a bigger bit of code to sort out, another useful trick is to use /* through to */ style comments to take out chunks and see if that changes / removes he problem. Such clues, once again, help you find your needle in your haystack.

One final comment If you find yourself repeating something, there's probably a much easier way of doing it. Your code as written is going to be hard to maintain and consistently debug, and you if statements are well ... not nice code. In fact, I think you have some missing || operators in them - I just spotted that. You have, as far as I can see, 4 corrections to make there. Nice code (easily readable, code not duplicated with minor variation!) can come in your next program, though - you have to start somewhere!
Reply With Quote
Reply

Tags
php, troubles

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
having some troubles luv2php PHP Forum 7 May 26th, 2008 05:40
IE Troubles motormaniac Web Page Design 0 May 11th, 2008 00:01
IE troubles and more, what else is new Maverick25r Web Page Design 4 Oct 18th, 2006 17:40
Link Troubles Maverick25r Web Page Design 12 Oct 3rd, 2006 18:39
IE troubles Maverick25r Web Page Design 2 Jul 24th, 2006 23:34


All times are GMT. The time now is 08:35.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43