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"> </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
