- Messages
- 250
- Reaction score
- 1
- Points
- 28
Pa help naman po kung tama ginawa ko gusto ko kasi mangyari bago ako maka pag Insert sa table na Student_enrolled ay mag match yung email nya dun sa account nya sa table ng Useraccount,, bali di sya makakapag insert pag di nag match yung account email nya sa Useraccount
<?php
if(isset($_POST['enrollstudent'])) {
$studentid = $_POST['studentid'];
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$myemail = $_POST['email'];
}else{
header("location:./");
}
include '../db_config/connection.php';
$sql = "SELECT * FROM admin_info where email LIKE '$myemail'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$student = $row['first_name'];
header("location:my_class.php?msg=Email $myemail does not match any account in database");
}
}
else {
include '../db_config/connection.php';
$class_id = $_GET['ref'];
$sql = "INSERT INTO student_enrolled (userid, student_id, firstname, lastname, email, class_id)
VALUES ('$userid', '$studentid', '$firstname', '$lastname', '$myemail', '$class_id')";
if ($conn->query($sql) === TRUE) {
header("location:my_class.php?ref=$class_id&?message= have been successfully registered");
} else {
$error = $conn->error;
header("location:my_class.php?err=$error");
}
$conn->close();
}
$conn->close();
?>