Mail Form Assistance

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


 Subscribe in a reader

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

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Nov 1st, 2006, 11:38
Reputable Member
Join Date: May 2006
Location: Warrington, UK
Posts: 428
Thanks: 0
Thanked 0 Times in 0 Posts
Mail Form Assistance

Ok its a simple webform thats meant to check that all the fields are filled in and then send the message to my email address.

However I'm getting the following error and it has me stumpied

Error :
Code: Select all

Parse error:  parse error, unexpected T_ELSE in /path/path/path/www/contactus.php on line 138
And here is the code that im using to display, check & send the form

Code: Select all
<?php
$errorMessage = ''; //initialize our error message

if(isset($_POST['submit'])){ //if the form has been submitted...
   if(!empty($_POST['company'])){ //if company isn't empty
      $company = $_POST['company']; //set the local variable to what's been posted
      $comp = TRUE; //set a boolean for future use
   }

   else{ //company IS empty
      $errorMessage .= "Please input your company name!<br />"; //add to our error message
      $comp = FALSE; //set a boolean for future use
   }

   if(!empty($_POST['name'])){
      $name = $_POST['name'];
      $n = TRUE;
   }

   else{
      $errorMessage .= "Please input your name!<br />";
      $n = FALSE;
   }

   if(!empty($_POST['email'])){
      $email = $_POST['email'];
      $e = TRUE;
   }

   else{
      $errorMessage .= "Please input your e-mail address!<br />";
      $e = FALSE;
   }

   if(!empty($_POST['contact'])){
      $contact = $_POST['contact'];
      $cont = TRUE;
   }

   else{
      $errorMessage .= "Please input your contact number!<br />";
      $cont = FALSE;
   }

   if(!empty($_POST['message'])){
      $message = $_POST['message'];
      $mess = TRUE;
   }

   else{
      $errorMessage .= "Please input your message!";
      $mess = FALSE;
   }

   if($comp && $n && $e && $cont && $mess){ //if everything's been filled out correctly, send the mail
      $ip = $_SERVER['REMOTE_ADDR'];
      $time = time();
      $date_message = date("r", $time);
      $subject="New Enquiry";
      $email="me@mine.com";

      //format the message
      $msg .= "IP: $ip\n";
      $msg .= "$date: $date_message\n";
      $msg .= "$subject\n";
      $msg .= "Company: $company\n";
      $msg .= "Name: $name\n";
      $msg .= "Email: $email\n";
      $msg .= "Message: $message\n";

      mail($email,$subject,$msg);
      echo "Your message has been sent.  We will contact you with a reply as soon as possible.";
   }

   else{ //something is wrong, so print our error message
      echo "<span style='color: red;'>Could not send e-mail for the following reasons:<br />$errorMessage";
   }

else{ //the form HASN'T been submitted yet
   ?>
      <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
         <div align="center">
                <table width="0%" height="0" border="0" align="center" cellpadding="0" cellspacing="0" class="contacttable">
                  <tr>
                    <td colspan="2"><p align="center"><strong>Fill in the form below to make an Enquiry</strong></p></td>
                  </tr>
                  <tr>
                    <td><p align="left"><b>Company name:</b></p></td>
                    <td><input name="company" type ="text" size="50" maxlength="30" />
                        <div align="center"></div></td>
                  </tr>
                  <tr>
                    <td><p align="left"><b>Your Name:</b></p></td>
                    <td><input name="name" type ="text" size="50" maxlength="30" />
                        <div align="center"></div></td>
                  </tr>
                  <tr>
                    <td><p align="left"><b>Your Email:</b></p></td>
                    <td><input name="email" type ="text" size="50" maxlength="50" /></td>
                  </tr>
                  <tr>
                    <td><p align="left"><b>Contact Number:</b></p></td>
                    <td><input name="contact" type ="text" size="50" maxlength="25" /></td>
                  </tr>
                  <tr>
                    <td width="150"><p align="left"><b>Your Messsage:</b></p></td>
                    <td><textarea name="message" cols="50" rows="8"></textarea></td>
                  </tr>
                  <tr>
                    <td class="bottomleft">&nbsp;</td>
                    <td><input name="submit" type="submit" value="Send Message" /></td>
                  </tr>
                </table>
                </p>
         </div>
      </form>

   <?php
} //ending bracket for our else-conditional
?>
Does anyone have any idea's why im getting this issue..... and how i might start to solve it ? .... cos im about to throw my pc out of the window eher lol
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Nov 1st, 2006, 12:53
Reputable Member
Join Date: May 2006
Location: Warrington, UK
Posts: 428
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Mail Form Assistance

sorted now, discovered i was missing a brace............ goddamnit its so annoying

thanks guys
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
else

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
Need assistance verifying that two emails match in a form - please help! Thank you! vanbot JavaScript Forum 1 Jun 12th, 2008 21:55
PHP Form Mail Maverick25r PHP Forum 2 Sep 22nd, 2006 21:59
Can someone help me with this e-mail form??? johnson8707 JavaScript Forum 9 Jul 5th, 2006 22:23
Can someone help me with this e-mail form??? johnson8707 PHP Forum 4 Jul 4th, 2006 17:51
visitors name not displayed in mail after filling in mail form made on earth PHP Forum 7 Nov 16th, 2005 23:43


All times are GMT. The time now is 10:23.


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