Jump to content

[SOLVED] switch statement help please.


kr3m3r

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.