PHP Programming > Beginners - Learning PHP

if else statement help

(1/1)

jsprite:
I want to redirect the user to one URL when selecting "9th Grade", and redirect the user to another URL when selecting any of the other grades upon submitting the form. The HTML code below is found on a form within an HTML file. What should the PHP 'if/else' statement be in the configuration form handler, (the PHP form handler document)?


--- Code: ---<!--this code is in the form within my HTML file-->
<select name="Grade" id="Grade">
                <option> 6th Grade </option>
                <option> 7th Grade </option>
                <option> 8th Grade </option>
                <option> 9th Grade </option>
                <option selected="selected"> </option>
              </select>

--- End code ---


--- PHP Code: ---
//not sure what should be placed in the PHP form handler document. It's not in the same folder as the HTML file
if (){
$redirect_url="my url 1";}
else (){
$redirect_url="my url 2";}
//not sure what else I am missing

--- End code ---

Noodles:

--- Code: ---<!--this code is in the form within my HTML file-->
<select name="Grade" id="Grade">               
<option name='6th' value='6th Grade'> 6th Grade </option>               
<option name='7th' value='7th Grade'> 7th Grade </option>               
<option name='8th' value='8th Grade'> 8th Grade </option>               
<option name='9th' value='9th Grade'> 9th Grade </option>               
<option selected="selected">
</option>             
</select>
--- End code ---


--- PHP Code: ---
$value1 = $_POST['6th'];
$value2 = $_POST['7th'];
$grade  = $_POST['Grade']

if(isset$_POST['submit'] && isset( $_POST['Grade'] )){
if ($grade== $value1 ){
$redirect_url="my url 1";
}elseif ( $grade == $value2  ){
$redirect_url="my url 2";
}
}

--- End code ---

Navigation

[0] Message Index

Go to full version