I am new to php. I trying out this code and one part of the code does not work. Can some one please tell me why this dont work and why it works when I remove this.
Form page - index.php
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<?php
$option = $_GET['value'];
if($option == "Option"){
$display = "You need to select an option";
}else{
$display = "";
}
?>
<br>
<br>
<?php
print $display;
?>
<form action="inc/register.php" method="POST">
email:<input type="text" name="email" value="" />
<br>
password:<input type="text" name="password" value="" />
<br>
<select name="attribute">
Select
<option>Organization</option>
<option>Student</option>
</select>
<br>
<input type="SUBMIT" value="SUBMIT" />
</form>
</body>
</html>
Code: Select all
<?php
// Get email
$email = $_REQUEST['email'];
// Get password
$password = $_REQUEST['password'];
// Get attribute
$attribute = $_REQUEST['attribute'];
if($attribute == "Student"){
print "You selected Student";
}elseif($attribute == "Organization"){
print "You selectd Organization";
}else{
header("Location: ../index.php?value=Option");
}
?>
Code: Select all
<?php
if(ISSET($_POST['SUBMIT'])){
// Get email
$email = $_REQUEST['email'];
// Get password
$password = $_REQUEST['password'];
// Get attribute
$attribute = $_REQUEST['attribute'];
if($attribute == "Student"){
print "You selected Student";
}elseif($attribute == "Organization"){
print "You selectd Organization";
}else{
header("Location: ../index.php?value=Option");
}
}else{
header("Location: ../index.php");
}
?>