katsuowota Posted February 10, 2015 Share Posted February 10, 2015 (edited) hey guys, can somebody help me with this problem? sorry in advance if the problem is way too easy to figure out, I'm really new at php... I try to get a dropdown list with content grabbed from a database. I then want to have it able to submit the value to another page (next_page.php), but when I try to run the website, it just shows up blank. the php error checker came up with this error: PHP Syntax Check: Parse error: syntax error, unexpected '<' in your code on line 16 <form action="next_page.php" method="post"> my code is: <!DOCTYPE html> <html> <head> <title>The Film Directory</title> <link href="site.css" rel="stylesheet"> </head> <body> <div> <h1>Film Directory</h1> <h2>Choose your poison</h2> <?php require "login.php"; <form action="next_page.php" method="post"> $sql="SELECT Name,FilmID FROM Films order by Name"; print "<select Name=Film_selection value=''>Film Name</option>"; foreach ($dbo->query($sql) as $row){ print "<option value=$row[id]>$row[Name]</option>"; } print "</select>"; print '<input type="submit" value="Submit">'; </form> $dbh = null; ?> </div> </body> </html> Edited February 10, 2015 by katsuowota Quote Link to comment https://forums.phpfreaks.com/topic/294509-php-forms-error/ Share on other sites More sharing options...
CroNiX Posted February 10, 2015 Share Posted February 10, 2015 because you have pure html in your PHP code. Move <form action="next_page.php" method="post"> to above your php open tag 1 Quote Link to comment https://forums.phpfreaks.com/topic/294509-php-forms-error/#findComment-1505355 Share on other sites More sharing options...
cyberRobot Posted February 10, 2015 Share Posted February 10, 2015 The same goes for the </form> tag. As CroNiX suggested, pure HTML tags need to be outside of your PHP tags...or enclosed in a PHP string. Quote Link to comment https://forums.phpfreaks.com/topic/294509-php-forms-error/#findComment-1505357 Share on other sites More sharing options...
Tom10 Posted February 12, 2015 Share Posted February 12, 2015 Make the form in HTML and process it in PHP, sanitize data, check a value has been entered etc. Quote Link to comment https://forums.phpfreaks.com/topic/294509-php-forms-error/#findComment-1505574 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.