<?php
include ("../carter.inc");
$cxn = mysqli_connect($host,$user,$password,$database)
or die ("couldn't connect to server");
$query = "select email from students where email = '$_POST[email]'";
$result = mysqli_query($cxn, $query)
or die ("Couldn't execute query.");
$query_count = mysqli_num_rows($result);
if($query_count>0){
header("Location:student_duplicate.php");
exit();
}
$sentry_name ="student_insert_execute.php";
require_once('sentry_lock.php');
$page_title = "Student Insert Page";
$first_name = mysqli_real_escape_string($cxn, trim($_POST['first_name']));
$last_name = mysqli_real_escape_string($cxn, trim($_POST['last_name']));
$password = mysqli_real_escape_string($cxn, trim($_POST['password']));
$email = trim($_POST['email']);
$cell_phone = trim($_POST['cell_phone']);
$organization = mysqli_real_escape_string($cxn, trim($_POST['organization']));
$class = trim($_POST['class']);
$insert = "insert into students (first_name, last_name, email, password, cell_phone, organization, class)
values ('$first_name', '$last_name', '$email', '$password', '$cell_phone', '$organization', '$class')";
$insertexe = mysqli_query($cxn, $insert);
if(!$insertexe) {
$error = mysqli_errno($cxn).': '.mysqli_error($cxn);
die($error);
}
require_once('header.php');
?>
|