Reputation: 1
I am new in coding. I started learn PHP and I got into a problem that I tried to catch the data from dropdown menu and print it inside the same code via PHP. But the problem is when I try to select it doesn't show anything. Please help!
<?php
if (isset($_POST['submit'])) {
$code = $_POST['coder'];
echo "You are ".$code." coder";
}
?>
<form action="" method="post" name="myForm" id="myForm">
<table>
<tr>
<td>Languages: </td>
<td>
<select name="coder">
<option>Select One</option>
<option value="JAVA">JAVA</option>
<option value="PHP">PHP</option>
<option value="C#">C#</option>
<option value="C++">C++</option>
</select>
</td>
</tr>
<tr>
<td></td>
<td><input type="submit" value ="Submit">
<input type="reset" value="Clear">
</td>
</tr>
</table>
</form>
Upvotes: 0
Views: 36
Reputation: 477
isset($_POST['submit'])
becoming false
because there is no any element with name "submit"
. Try setting name to submit button as.
<input type="submit" value ="Submit" name="submit">
Upvotes: 2