Meg_Griffin Posted December 13, 2012 Share Posted December 13, 2012 That's my code: <form method='POST' action='<?php echo $_SERVER['PHP_SELF'] ?>'> <p>Name <input name="name" /></p> <p>E-mail <input name="email" /></p> <button type="submit">Save</button></form> The output shows: Parse error: syntax error, unexpected '<' in C:\xampp\htdocs\exercise_01\templates\students\register.php on line 5 When I got rid of this "<" nothing happened. Link to comment Share on other sites More sharing options...
Don E Posted December 13, 2012 Share Posted December 13, 2012 Try puting a semicolon after: echo $_SERVER['PHP_SELF']; Link to comment Share on other sites More sharing options...
Meg_Griffin Posted December 13, 2012 Author Share Posted December 13, 2012 Don_EIt's not working. Link to comment Share on other sites More sharing options...
Don E Posted December 13, 2012 Share Posted December 13, 2012 Everything seems to be okay. Is there more to the code than just that? What exactly is on line 5? Link to comment Share on other sites More sharing options...
Meg_Griffin Posted December 13, 2012 Author Share Posted December 13, 2012 Well,that is part of file register.php on my project. It's a small system using a DB. I don't know why specifically this file is not working properly. The others are working perfectly.on line 5 is <form method='POST' action='<?php echo $_SERVER['PHP_SELF'] ?>'> Link to comment Share on other sites More sharing options...
justsomeguy Posted December 14, 2012 Share Posted December 14, 2012 It's probably talking about the < which starts the form tag, there is a probably an error on the previous lines. Maybe a problem with a quoted string, or maybe you stuck HTML code right in the middle of a PHP block. Link to comment Share on other sites More sharing options...
satishpoul Posted December 14, 2012 Share Posted December 14, 2012 problem is here action='<?php echo $_SERVER['PHP_SELF'] ?>'> with "" and 'so in action either write "" out side and '' inside or viceversaaction = "<?php echo $_SERVER['PHP_SELF']; ?>"oraction = '<?php echo $_SERVER["PHP_SELF"]; ?>' Link to comment Share on other sites More sharing options...
rahultailwal Posted December 14, 2012 Share Posted December 14, 2012 Code is fine. We need to see the code before the line no 5. Can u write 4 lines before that. Link to comment Share on other sites More sharing options...
Meg_Griffin Posted December 14, 2012 Author Share Posted December 14, 2012 (edited) rahultailwalmy full code: <h2>Register Student</h2> <?php //code to register student<form method='POST' action='<?php echo $_SERVER['PHP_SELF']; ?>'> <p>Name <input name="name" /></p> <p>E-mail <input name="email" /></p> <button type="submit">Save</button></form> <?php if (count($_POST) > 0){ insert($_POST, 'students'); ob_clean(); header('LOCATION: '.ROOT.'/students/list.php'); }?> ?> Edited December 14, 2012 by Meg_Griffin Link to comment Share on other sites More sharing options...
Don E Posted December 14, 2012 Share Posted December 14, 2012 Remove the following in red and see if you still get the error:<?php//code to register student<form method='POST' action='<?php echo $_SERVER['PHP_SELF']; ?>'><p>Name <input name="name" /></p><p>E-mail <input name="email" /></p><button type="submit">Save</button></form> <?phpif (count($_POST) > 0){insert($_POST, 'students');ob_clean();header('LOCATION: '.ROOT.'/students/list.php');}?> ?> Link to comment Share on other sites More sharing options...
Meg_Griffin Posted December 14, 2012 Author Share Posted December 14, 2012 (edited) Don EIt works. thanks. Edited December 14, 2012 by Meg_Griffin Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now