<Sarcasm> The Wonders' of being a Newbie </Sarcasm>.
So, not only am I trying to teach myself possibly one of the hardest web programming languages web has to offer, I'm getting incredibly frustrated with trying to get my FormMail to work. I've done a bit of researching particularly on this forum, and see it is a common topic - so I'm sure some of you guru's can shed some light on it for me.
I'm getting this error:
Parse error: syntax error, unexpected T_BOOLEAN_OR in /home/USERNAME/public_html/formmail.php on line 21
My Form HTML Code is this:
<form name="contactform" method="post" action="formmail.php">
<label for="first_name">First Name *</label>
<input type="text" name="first_name" maxlength="50" size="30"/>
<label for="last_name">Last Name *</label>
<input type="text" name="last_name" maxlength="50" size="30"/>
<label for="email">Email Address *</label>
<input type="text" name="email" maxlength="80" size="30"/>
<input type="submit" value="Submit"/>
</form
And the PHP File Scripting is this:
<?php
if(isset($_POST['email'])) {
$email_to = "MYEMAIL@MYDOMAIN.COM";
$email_subject = "MY SUBJECT";
function died($error) {
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
if(!isset($_POST['first_name']) ||
!isset($_POST['last_name']) ||
!isset($_POST['email'])) || {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email_from = $_POST['email'];
$error_message = "";
$email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";
if(!eregi($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "^[a-z .'-]+$";
if(!eregi($string_exp,$first_name)) {
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
}
if(!eregi($string_exp,$last_name)) {
$error_message .= 'The Last Name you entered does not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Information via FormMail.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "First Name: ".clean_string($first_name)."\n";
$email_message .= "Last Name: ".clean_string($last_name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>
Thanks, We'll be in touch shortly.
<?
}
?>
Where am I going wrong! I just don't understand why it keeps given me this god damn error.
Also, any additional advice on how to put a hyperlink in there would be HIGHLY appreciated. I tried adding this
<?php echo( '<a href="MYDOMAIN">Click Here To Continue</a>' );
In the success message bit - but didn't have any luck; nor did I using Print rather than Echo.
Some of the values used in the scripting I think is deprecated(?). And, I'm not sure of any alternatives. I don't have access to the php.ini file, and don't have an .htaccess file - so any help on that would be FANTASTIC 🙂
Thanks guys, looking forward to your answers - you're saving me a lot of hair! (Well, what's left of it!)