I have tried creating a cookie but my value is not being saved. Here is my code. I have tried checking my connection details but it looks alright. Please help since i cannot find a solution to this problem.
<form method="POST">
<hr>
<div class="accounttype">
<input type="radio" value="Teacher" id="radioOne" name="account" checked/>
<label for="radioOne" class="radio" chec><span style="font-size: 23px;">Teacher</span></label>
<input type="radio" value="Student" id="radioTwo" name="account" />
<label for="radioTwo" class="radio"><span style="font-size: 23px;">Student</span></label>
</div>
<hr>
<label id="icon" for="name"><i class="icon-envelope "></i></label>
<input type="text" name="logid" id="logid" placeholder="Email" required/>
<label id="icon" for="name"><i class="icon-user"></i></label>
<input type="text" name="logName" id="logName" placeholder="Name" required/>
<label id="icon" for="name"><i class="icon-shield"></i></label>
<input type="password" name="logPassword" id="logPassword" placeholder="Password" required/>
<center><table>
<tr>
<td><center>
<input type="submit" name="Login" id="Login" value="Login" style="background-color: #3a57af; color: #ffffff; width: 105px; height: 40px;-webkit-border-radius: 20px;-moz-border-radius: 20px;border-radius: 20px;border: 0px;">
</center>
</td>
<?php
$userId = $_POST['logid'];
//$userName = $_POST['logName'];
$password = $_POST['logPassword'];
$account = $_POST['account'];
$teacher = "Teacher";
$student = "Student";
if ($account == $teacher) {
# code...
$sql = "SELECT * FROM teacherRecord WHERE email = '$userId' AND password='$password'";
$result = mysqli_query($con,$sql);
$check = mysqli_fetch_array($result);
if(isset($check)){
setcookie("email", $userId, time() + (86400 * 30), "/");
echo $_COOKIE['email'];
//echo "<script>window.location='profile.php'</script>";
}
}
?>