morocco-iceberg Posted March 17, 2010 Share Posted March 17, 2010 Ok, so I was going smoothly until all of a sudden I started getting parse errors on line 21. I have no clue what is wrong with my code, so any help is very muchly appreciated! <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>File Writing</title> </head> <body> <?php if(isset($_POST['submit'])){ $name=$_POST['name']; $email=$_POST['email']; $message=$_POST['message']; $to="info@klds.com.au"; $re=$_POST['subject']; $msg = "$message \r\n \r\n $name, \r\n $email"; if(!$name){ $errn="Please enter your name."; }else if(!$email){ $erre="Please enter an email."; }else if(!$re){ $errr="Please enter a subject."; }else if(!$message){ $errm="Please enter a message."; }else{ $email = trim($email); $_ename = "/^[-!#$%&\'*+\\.\/0-9=?A-Z^_'{|}~]+"; $_host = "([0-9A-Z]+\.)+"; $_tlds = "([0-9A-Z]){2,4}$/i"; if ( !preg_match($_ename."@".$_host.$_tlds,$email)){ echo "Sorry, it appears the e-mail address you have entered is not valid. Please enter a valid e-mail address."; }else{ mail($to, $re, $msg); echo "Message sent."; } } } ?> <form action="file.php" method="post"> <strong>Name</strong> <input type="input" name="name" value="<?php if(isset($_POST['submit'])){echo $name;} ?>" /><?php if(isset($_POST['submit'])){echo $errn;} ?><br/> <strong>E-Mail</strong> <input type="input" name="email" value="<?php if(isset($_POST['submit'])){echo $email;} ?>" /><br/><?php if(isset($_POST['submit'])){echo $erre;} ?> <strong>Subject</strong> <input type="input" name="subject" value="<?php if(isset($_POST['submit'])){echo $re;} ?>" /><br/><?php if(isset($_POST['submit'])){echo $errr;} ?> <strong>Message</strong> <input type="input" name="message" value="<?php if(isset($_POST['submit'])){echo $message;} ?>" /><br/><br/><?php if(isset($_POST['submit'])){echo $errm;} ?> <input type="submit" name="submit" value="Submit" /> </form> </body> </html> Quote Link to comment Share on other sites More sharing options...
MatthewJ Posted March 17, 2010 Share Posted March 17, 2010 Try combining the else if into one word (elseif). The way you have it should work okay since you're using curly braces but it appears that the first else if is the line it is failing on. Quote Link to comment Share on other sites More sharing options...
morocco-iceberg Posted March 17, 2010 Author Share Posted March 17, 2010 Haha, oh dear I am blonde... my code was fine, I was just linking to the wrong page via my form. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.