kr3m3r Posted August 21, 2007 Share Posted August 21, 2007 Hi guys, I'm now trying to some stuff I've never tried before, going beyond the book exerciese to try to create my own application and at an early stage find myself fumbling about. I have an html page that lets the user select the type of item they wish to add to the library, a book, dvd, or cd. That page has a form which connects to this page, where the information should be entered, and I hope to have this page connect to another page where the items will actually be entered into the database. Any help on this would be very appreciated. My current error message is: Parse error: syntax error, unexpected '<' in /home/.titch/rwkremer/kr3m3r.com/preinsert_item.php on line 11 The code is: <html> <head> <title>Multimedia Library - New Item Entry</title> </head> <body> <h1>Multimedia Library - New Item Entry</h1> <?php <form action="insert_item.php" method="post"> $itemtype = $HTTP_POST_VARS['itemtype']; switch($itemtype) case '1'; { <table boder="0"> <tr> <td>UPC</td> <td><input type="text" name="UPC" maxlength="13" size="13"> <br /></td> </tr> <tr> <td>Title</td> <td><input type="text" name="Title" maxlength="100" size="25"><br /></td> </tr> <tr> <td>Author</td> <td><input type="text" name="MajorAttribute" maxlength="100" size="25"><br /></td> </tr> <tr> <td>Publisher</td> <td><input type="text" name="SecondaryAttribute" maxlength="100" size="25"><br /></td> </tr> <tr> <td colspan="2"><input type="submit" value="Register"></td> </tr> </table> </form> } break; case '2'; { <table boder="0"> <tr> <td>UPC</td> <td><input type="text" name="UPC" maxlength="13" size="13"> <br /></td> </tr> <tr> <td>Title</td> <td><input type="text" name="Title" maxlength="100" size="25"><br /></td> </tr> <tr> <td>Main Star</td> <td><input type="text" name="MajorAttribute" maxlength="100" size="25"><br /></td> </tr> <tr> <td>Director</td> <td><input type="text" name="SecondaryAttribute" maxlength="100" size="25"><br /></td> </tr> <tr> <td colspan="2"><input type="submit" value="Register"></td> </tr> </table> </form> } break; case '3'; { <table boder="0"> <tr> <td>UPC</td> <td><input type="text" name="UPC" maxlength="13" size="13"> <br /></td> </tr> <tr> <td>Title</td> <td><input type="text" name="Title" maxlength="100" size="25"><br /></td> </tr> <tr> <td>Band</td> <td><input type="text" name="MajorAttribute" maxlength="100" size="25"><br /></td> </tr> <tr> <td>Label</td> <td><input type="text" name="SecondaryAttribute" maxlength="100" size="25"><br /></td> </tr> <tr> <td colspan="2"><input type="submit" value="Register"></td> </tr> </table> </form> } break; ?> </body> </html> Thanks for your time and help. -Robb Quote Link to comment https://forums.phpfreaks.com/topic/65921-solved-switch-statement-help-please/ Share on other sites More sharing options...
trq Posted August 21, 2007 Share Posted August 21, 2007 You've got html sitting within your php. If you want... <form action="insert_item.php" method="post"> within php you need to echo it. eg; echo '<form action="insert_item.php" method="post">'; PS: Your still using $HTTP_POST_VARS, which as I told you in your last post has LONG been depricated/is no longer used. Quote Link to comment https://forums.phpfreaks.com/topic/65921-solved-switch-statement-help-please/#findComment-329524 Share on other sites More sharing options...
suma237 Posted August 21, 2007 Share Posted August 21, 2007 Try this <html> <head> <title>Multimedia Library - New Item Entry</title> </head> <body> <h1>Multimedia Library - New Item Entry</h1> <form action="insert_item.php" method="post"> <? $itemtype = $HTTP_POST_VARS['itemtype']; switch($itemtype): case '1': ?> <table boder="0"> <tr> <td>UPC</td> <td><input type="text" name="UPC" maxlength="13" size="13"> <br /></td> </tr> <tr> <td>Title</td> <td><input type="text" name="Title" maxlength="100" size="25"><br /></td> </tr> <tr> <td>Author</td> <td><input type="text" name="MajorAttribute" maxlength="100" size="25"><br /></td> </tr> <tr> <td>Publisher</td> <td><input type="text" name="SecondaryAttribute" maxlength="100" size="25"><br /></td> </tr> <tr> <td colspan="2"><input type="submit" value="Register"></td> </tr> </table> </form> <? break; case '2': ?> <table boder="0"> <tr> <td>UPC</td> <td><input type="text" name="UPC" maxlength="13" size="13"> <br /></td> </tr> <tr> <td>Title</td> <td><input type="text" name="Title" maxlength="100" size="25"><br /></td> </tr> <tr> <td>Main Star</td> <td><input type="text" name="MajorAttribute" maxlength="100" size="25"><br /></td> </tr> <tr> <td>Director</td> <td><input type="text" name="SecondaryAttribute" maxlength="100" size="25"><br /></td> </tr> <tr> <td colspan="2"><input type="submit" value="Register"></td> </tr> </table> </form> <? break; case '3': ?> <table boder="0"> <tr> <td>UPC</td> <td><input type="text" name="UPC" maxlength="13" size="13"> <br /></td> </tr> <tr> <td>Title</td> <td><input type="text" name="Title" maxlength="100" size="25"><br /></td> </tr> <tr> <td>Band</td> <td><input type="text" name="MajorAttribute" maxlength="100" size="25"><br /></td> </tr> <tr> <td>Label</td> <td><input type="text" name="SecondaryAttribute" maxlength="100" size="25"><br /></td> </tr> <tr> <td colspan="2"><input type="submit" value="Register"></td> </tr> </table> </form> <? break; endswitch; //end of switch ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/65921-solved-switch-statement-help-please/#findComment-329526 Share on other sites More sharing options...
kr3m3r Posted August 21, 2007 Author Share Posted August 21, 2007 OK changed the HTTP_POST_VARS to _POST, added the echo'xxxx'; wherever there was html, and am now getting this error: Parse error: syntax error, unexpected T_CASE, expecting ':' or '{' in /home/.titch/rwkremer/kr3m3r.com/preinsert_item.php on line 13 Here is the altered code: <html> <head> <title>Multimedia Library - New Item Entry</title> </head> <body> <h1>Multimedia Library - New Item Entry</h1> <?php $itemtype = $_POST['itemtype']; switch($itemtype) case '1'; echo '<form action="insert_item.php" method="post">'; echo '<table boder="0">'; echo '<tr>'; echo '<td>UPC</td>'; echo '<td><input type="text" name="UPC" maxlength="13" size="13"> <br /></td>'; echo '</tr>'; echo '<tr>'; echo '<td>Title</td>'; echo '<td><input type="text" name="Title" maxlength="100" size="25"><br /></td>'; echo '</tr>'; echo '<tr>'; echo '<td>Author</td>'; echo '<td><input type="text" name="MajorAttribute" maxlength="100" size="25"><br /></td>'; echo '</tr>'; echo '<tr>'; echo '<td>Publisher</td>'; echo '<td><input type="text" name="SecondaryAttribute" maxlength="100" size="25"><br /></td>'; echo '</tr>'; echo '<tr>'; echo '<td colspan="2"><input type="submit" value="Register"></td>'; echo '</tr>'; echo '</table>'; echo '</form>'; break; case '2'; echo '<form action="insert_item.php" method="post">'; echo '<table boder="0">'; echo '<tr>'; echo '<td>UPC</td>'; echo '<td><input type="text" name="UPC" maxlength="13" size="13"> <br /></td>'; echo '</tr>'; echo '<tr>'; echo '<td>Title</td>'; echo '<td><input type="text" name="Title" maxlength="100" size="25"><br /></td>'; echo '</tr>'; echo '<tr>'; echo '<td>Main Star</td>'; echo '<td><input type="text" name="MajorAttribute" maxlength="100" size="25"><br /></td>'; echo '</tr>'; echo '<tr>'; echo '<td>Director</td>'; echo '<td><input type="text" name="SecondaryAttribute" maxlength="100" size="25"><br /></td>'; echo '</tr>'; echo '<tr>'; echo '<td colspan="2"><input type="submit" value="Register"></td>'; echo '</tr>'; echo '</table>'; echo '</form>'; break; case '3'; echo '<form action="insert_item.php" method="post">'; echo '<table boder="0">'; echo '<tr>'; echo '<td>UPC</td>'; echo '<td><input type="text" name="UPC" maxlength="13" size="13"> <br /></td>'; echo '</tr>'; echo '<tr>'; echo '<td>Title</td>'; echo '<td><input type="text" name="Title" maxlength="100" size="25"><br /></td>'; echo '</tr>'; echo '<tr>'; echo '<td>Band</td>'; echo '<td><input type="text" name="MajorAttribute" maxlength="100" size="25"><br /></td>'; echo '</tr>'; echo '<tr>'; echo '<td>Label</td>'; echo '<td><input type="text" name="SecondaryAttribute" maxlength="100" size="25"><br /></td>'; echo '</tr>'; echo '<tr>'; echo '<td colspan="2"><input type="submit" value="Register"></td>'; echo '</tr>'; echo '</table>'; echo '</form>'; break; ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/65921-solved-switch-statement-help-please/#findComment-329539 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.