I have created a simple page which will be displayed after logging in. From that page, I print my html code in it with the SELECT option for the user to select the items they needed.
This is the code.
<?php //Start the Session
session_start();
require('connect.php');
if (isset($_POST['email']) and isset($_POST['password'])){
$username = $_POST['email'];
$password = $_POST['password'];
$query = "SELECT * FROM `user` WHERE email='$username' and password='$password'";
$result = mysql_query($query) or die(mysql_error());
$count = mysql_num_rows($result);
if ($count == 1){
$_SESSION['email'] = $username;
print '
<html>
<body>
<br>
<form action="" method="POST">
Shirt:
<select name="shirt_string">
<option value=" "> </option>
<option value="Long Sleeves">Long Sleeves</option>
<option value="Short Sleeves">Short Sleeves</option>
<option value="T-Shirt">T-Shirt</option>
<option value="Singlet">Singlet</option>
</select> </br>
<br>
Pants:
<select name="pants_string">
<option value=" "> </option>
<option value="Dress pants">Dress pants</option>
<option value="Shorts">Shorts</option>
<option value="Jeans">Jeans</option>
<option value="Chinos">Chinos</option>
</select> </br>
<br>
Shoes:
<select name="shoes_string">
<option value=" "> </option>
<option value="Dress shoes">Dress shoes</option>
<option value="Slipper">Slipper</option>
<option value="Sneakers">Sneakers</option>
<option value="Track shoes">Track shoes</option>
</select> </br>
<br>
<input type="submit">
<br/>
<br/>
<a href="login.php?action=logout">Log out</a>
</form>
</body>
</html>
';
echo $_POST['pants_string'];
}
else
{
echo "Invalid Login Credentials.";
}
}
if (isset($_SESSION['email'])){
$username = $_SESSION['email'];
}else{}
echo "<br />\n";
$now = new DateTime();
$Singapore = new DateTimeZone('Asia/Singapore');
$now->setTimezone($Singapore);
echo $now->format('F j, Y h:ia');
?>
From the above codes, how am I supposed to get the value from the SELECT option to php?
I tried calling something like $_POST['pants_strings']; but it does not work.
EDIT: This is the full code.