Page 1 of 1

passing element value as url

Posted: Sat Aug 15, 2009 1:20 am
by sobha
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

Re: passing element value as url

Posted: Sat Aug 15, 2009 2:05 am
by requinix
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"].

Re: passing element value as url

Posted: Sat Aug 15, 2009 2:15 am
by sobha
$_POST["month"] is retreiving value outside the if condition.But not retreiving value inside if condition.
if ($_POST['submit']) {
//....
}
<form>
<input type="submit">
</form>

Re: passing element value as url

Posted: Sat Aug 15, 2009 3:12 am
by requinix
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>

Re: passing element value as url

Posted: Sat Aug 15, 2009 4:26 am
by webmonkey88
lol go to w3schools