I am creating a form that enters data into the database however this is not happening. When I submit the form, no data is being entered into the database.
Here is what I have tried:
<!Doctype html>
<head>
<title>
Thankyou!
</title>
</head>
<body>
<?php
include "config2.php";
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$nationality = $_POST['nationality'];
$studentid = $_POST['stid'];
$department = $_POST['department'];
$course = $_POST['course'];
$email = $_POST['email'];
$address = $_POST['address'];
$number = $_POST['number'];
$gender = $_POST['gender'];
$ageonarrival = $_POST['age-on-arrival'];
$admissionstatus = $_POST['status'];
$reason = $_POST['reason'];
$change = $_POST['date'];
$first = $_POST['first'];
$progress = $_POST['progression'];
$intake = $_POST['intake-date'];
$progressto = $_POST['progress-to'];
#database connectivity
$insert = 'INSERT into student-contact (Forename, Surname, Nationality Name, Student id, FET Department, Course, Email, Address, Number, Gender, Age On Arrival, Admission Status, Enrolment Admission Status Reason, Enrolment Admission Status Date Of Change, First Course Booking Course, Progression Route, Progression Intake Date, Progressing to) VALUES ("'.$fname.'" , "'.$lname.'" , "'.$nationality.'" , "'.$studentid.'" , "'.$department.'" , "'.$course.'" ,"'.$email.'" , "'.$address.'" , "'.$number.'" , "'.$gender.'" , "'.$ageonarrival.'" , "'.$admissionstatus.'", "'.$reason.'" , "'.$change.'" , "'.$first.'" , "'.$progress.'" , "'.$intake.'" , "'.$progressto.'")';
$query = mysql_query("SELECT * FROM student-contact WHERE Forename='$fname'");
#insert data from mysql table
if(mysql_num_rows($query) != 0)
{
echo"<meta http-equiv='refresh' content='0;url=exists.php'>";
}
else
{
//proceed with code here
}
if (empty($studentid)) {
header("Location: exists.php");
}
#navigate the user to the exist page which tells the user that there has been a fault
mysql_query($insert);
echo("<h1>You have successfully added $fname to the student record system.</h1>");
echo("<p>The details which you have sent to us are the following:</p>");
echo("<p>Forename: $fname</p>");
echo("<p>Surname: $lname</p>");
echo("<p>Nationality: $nationality</p>");
echo("<p>Student ID: $studentid</p>");
echo("<p>Department: $department</p>");
echo("<p>Course: $course</p>");
echo("<p>Email: $email</p>");
echo("<p>Address: $address</p>");
echo("<p>Contact number: $number</p>");
echo("<p>Gender: $gender</p>");
echo("<p>Age on arrival: $ageonarrival</p>");
echo("<p>Admission Status: $admissionstatus</p>");
echo("<p>Enrolment Admission Status Reason: $reason</p>");
echo("<p>Enrolment Admission Status Date Of Change: $status</p>");
echo("<p>First Booking Course: $first</p>");
echo("<p>Progression route: $progress</p>");
echo("<p>Progression Intake Date: $intake</p>");
echo("<p>Progressing to: $progressto</p>");
?>
<!-- The users details are displayed to show what data the user has sent to the system -->
</body>
</html>

New Topic/Question
Reply



MultiQuote






|