Getting the value of a combo-box using post method
I wanted to use php to get the value of a combo box, and I am using post method... can anyone tell me how.
<html>
<head>
<title>Virtual Library</title>
<link href="css/login.css" rel="stylesheet"/>
<link href="css/style.css" rel="stylesheet"/>
<script type="text/javascript" src="scripts/ajax_search.js"></script>
</head>
<body>
<div id="wrapper">
<div id="header" align="center">
<ul align="center">
<li><a href="index.php"><span>Home</span></a></li>
<li><a href="news.html"><span>Top 100 Downloads</span></a></li>
<li><a href="upload.php"><span>Upload</span></a></li>
<?php if(isset($_SESSION['login_user']))
{
$uname = $_SESSION['login_user'];
echo "<li><a href='profile.php'><span>$uname</span></a></li>";
echo "<li><a href='logout.php'><span>LogOut</span></a></li>";
}
else{
echo "<li><a href='login.php'><span>Member Login</span></a></li>";
echo "<li><a href='register.php'><span>Register</span></a></li>";
}
?>
<li><a href="downloads.html"><span>RSS <img src="images/rss.gif" id="rss"></span></a></li>
</ul>
</div>
<?php if(isset($_SESSION['login_user']))
{
echo "<div class='frmdiv'>
<form action='upload_file.php' method='post' enctype='multipart/form-data'>
<table width='38%' border='0' align='center' cellpadding='0' cellspacing='0'>
<tr>
<td colspan='2'><div align='center'><font size='2' face='verdana'>Upload File</font></div></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan='2'><hr></td>
</tr>
<tr>
<td height='26'><font size='2' face='verdana'>FileName</font></td>
开发者_StackOverflow中文版 <td><font size='2' face='verdana'>
<input type='file' name='file' ></font>
</td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td></td>
<td><select name='media_type' >
<option value='' selected>Select a media type...</option>
<option value='pdf'>PDF</option>
<option value='chm'>CHM</option>
<option value='epub'>EPUB</option>
<option value='html'>HTML</option>
<option value='djvu'>DJVU</option>
</select></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><font size='2' face='verdana'>
<input type='submit' name='Submit' value='Upload'></font>
</td>
</tr>
<tr>
<td colspan='2'><hr></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</table>
</form>
<div align='center'>";
}
else{
echo "<script type='text/javascript'>";
echo "alert('You Must Be Logged In To Upload');";
echo "location='login.php'";
echo "</script";
}
?>
</div>
</body>
</html>
this is the combo box.
Try:
if(isset($_POST['media_type']){
$value = $_POST['media_type'];
}
Update: Since that doesn't work for you, check to see if you are getting any post variables:
foreach ($_POST as $var => $value) {
echo "$var = $value<br>n";
}
精彩评论