Hi,
What is the correct syntax to be used in line with red color?
<form method="post" action="sample.php?month=month.value">
<select name="month">
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
<option value="4">April</option>
</select>
Regards,
Sobha
passing element value as url
Moderator: General Moderators
Re: passing element value as url
Don't include it.
By defining <select name="month"> you are already including the value in the form submission. Access it in your PHP script with $_POST["month"].
By defining <select name="month"> you are already including the value in the form submission. Access it in your PHP script with $_POST["month"].
Re: passing element value as url
$_POST["month"] is retreiving value outside the if condition.But not retreiving value inside if condition.
if ($_POST['submit']) {
//....
}<form>
<input type="submit">
</form>
if ($_POST['submit']) {
//....
}<form>
<input type="submit">
</form>
Re: passing element value as url
I can't even tell what you're saying, but if it's not working then you're doing it wrong.
Code: Select all
<html>
<body>
<?php
if (isset($_POST["month"])) echo "<p>Month #", $_POST["month"], "</p>\n";
?>
<form method="post">
<p><select name="month">
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
<option value="4">April</option>
</select> <input type="submit">
</form>
</body>
</html>-
webmonkey88
- Forum Newbie
- Posts: 20
- Joined: Fri Aug 14, 2009 4:30 am
Re: passing element value as url
lol go to w3schools