kaizer Posted March 10, 2007 Share Posted March 10, 2007 error message:Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ']' in C:\Apache2\htdocs\inputvalidation.php on line 19 this is an example I am using to learn PHP and I am getting the above error as a result of running this example. could you please tell me why I am getting this error. input validation code: <?php if (isset($_POST["submit"'])) { $firstname = $_POST["firstname"]; $lastname = $_POST["lastname"]; if (!empty($firstname) && !empty($lastname)) { Header("Location: inputsuccess.php"); } else {$error = true;} } ?> <!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> <title>This is (Recursive) Input Validation</title> </head> <body> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <?php if ( $error && empty($firstname) ) { echo '<span style="color:red">'; echo "Error! Please enter a first name.</span><br />"; } ?> First name: <input name="firstname" type="text" value="<?php echo $firstname; ?>" /> <br /> <?php if ($error && empty($lastname)) { echo '<span style="color:red">'; echo "Error! Please enter a last name.</span><br />"; } ?> Last name: <input name="lastname" type="text" value="<?php echo $lastname; ?>" /> <br /> <br /> <input type="submit" name="submit" value="Submit" /> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/42134-i-am-getting-the-following-errorparse-error-parse-error-unexpected-t_etc/ Share on other sites More sharing options...
per1os Posted March 10, 2007 Share Posted March 10, 2007 if (isset($_POST["submit"'])) { Removed the extra single quote, try this. <?php if (isset($_POST["submit"])) { $firstname = $_POST["firstname"]; $lastname = $_POST["lastname"]; if (!empty($firstname) && !empty($lastname)) { Header("Location: inputsuccess.php"); } else {$error = true;} } ?> <!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> <title>This is (Recursive) Input Validation</title> </head> <body> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <?php if ( $error && empty($firstname) ) { echo '<span style="color:red">'; echo "Error! Please enter a first name.</span> "; } ?> First name: <input name="firstname" type="text" value="<?php echo $firstname; ?>" /> <?php if ($error && empty($lastname)) { echo '<span style="color:red">'; echo "Error! Please enter a last name.</span> "; } ?> Last name: <input name="lastname" type="text" value="<?php echo $lastname; ?>" /> <input type="submit" name="submit" value="Submit" /> </form> </body> </html> --FrosT Quote Link to comment https://forums.phpfreaks.com/topic/42134-i-am-getting-the-following-errorparse-error-parse-error-unexpected-t_etc/#findComment-204360 Share on other sites More sharing options...
kaizer Posted March 10, 2007 Author Share Posted March 10, 2007 thank You FrosT It Worked! Quote Link to comment https://forums.phpfreaks.com/topic/42134-i-am-getting-the-following-errorparse-error-parse-error-unexpected-t_etc/#findComment-204371 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.