Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Staff Added</title>
- <link type="text/css" rel="stylesheet" href="style.css">
- </head>
- <body>
- <div class="floatlow">
- <h3>
- <?php
- date_default_timezone_set("Europe/London");
- $dobstring = $_POST['staff_dob'];
- $dob = strtotime($dobstring);
- $now = time();
- printf("%s <> %s ?\n", $strtotime, $dob);
- if( $dob >= $now ) {
- print "$dobstring is later than now.\n";
- } else {
- print "$dobstring is earlier than now.\n";
- if(isset($_POST['submit'])){
- $data_missing = array();
- if(empty($_POST['staff_first_name'])){
- $data_missing[] = 'staff_first_name';
- } else{
- $f_name = trim($_POST['staff_first_name']);
- }
- if(empty($_POST['staff_last_name'])){
- $data_missing[] = 'staff_last_name';
- } else {
- $l_name = trim($_POST['staff_last_name']);
- }
- if(empty($_POST['staff_tel'])){
- $data_missing[] = 'staff_tel';
- } else{
- $tel = trim($_POST['staff_tel']);
- }
- if(empty($_POST['staff_nin'])){
- $data_missing[] = 'staff_nin';
- } else{
- $nin = trim($_POST['staff_nin']);
- }
- if(empty($_POST['staff_position'])){
- $data_missing[] = 'staff_position';
- } else{
- $pos = trim($_POST['staff_position']);
- }
- if(empty($_POST['staff_salary'])){
- $data_missing[] = 'staff_salary';
- } else{
- $sal = trim($_POST['staff_salary']);
- }
- if(empty($_POST['staff_salary_scale'])){
- $data_missing[] = 'staff_salary_scale';
- } else{
- $sal_scale = trim($_POST['staff_salary_scale']);
- }
- if(empty($_POST['allocated_ward'])){
- $data_missing[] = 'allocated_ward';
- } else{
- $ward = trim($_POST['allocated_ward']);
- }
- if(empty($_POST['staff_hours'])){
- $data_missing[] = 'staff_hours';
- } else{
- $hours = trim($_POST['staff_hours']);
- }
- if(empty($_POST['staff_perm_temp'])){
- $data_missing[] = 'staff_perm_temp';
- } else{
- $s_p_t = trim($_POST['staff_perm_temp']);
- }
- if(empty($_POST['staff_dob'])){
- $data_missing[] = 'staff_dob';
- } else{
- $dob = trim($_POST['staff_dob']);
- }
- if(empty($_POST['sex'])){
- $data_missing[] = 'sex';
- } else {
- $sex = trim($_POST['sex']);
- }
- if(empty($_POST['staff_add_line_1'])){
- $data_missing[] = 'staff_add_line_1';
- } else{
- $s_a_l_1 = trim($_POST['staff_add_line_1']);
- }
- if(empty($_POST['staff_add_line_2'])){
- $data_missing[] = 'staff_add_line_2';
- } else{
- $s_a_l_2 = trim($_POST['staff_add_line_2']);
- }
- if(empty($_POST['city'])){
- $data_missing[] = 'city';
- } else {
- $city = trim($_POST['city']);
- }
- if(empty($_POST['postcode'])){
- $data_missing[] = 'postcode';
- } else {
- $p_code = trim($_POST['postcode']);
- }
- }
- if(empty($data_missing)){
- require_once('../sqli_connect.php');
- $query = "INSERT INTO Staff (staffid, staff_first_name, staff_last_name,
- staff_dob, sex, staff_tel, staff_nin, staff_position, staff_salary,
- staff_salary_scale, staff_hours, staff_perm_temp, allocated_ward,
- staff_add_line_1, staff_add_line_2, city, postcode)VALUES (NULL, ?, ?,
- ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
- $stmt = mysqli_prepare($dbc, $query);
- mysqli_stmt_bind_param($stmt,"ssssssssssssssss",
- $f_name, $l_name, $dob, $sex, $tel, $nin,
- $pos, $sal, $sal_scale, $hours, $s_p_t, $ward,
- $s_a_l_1, $s_a_l_2, $city, $p_code);
- mysqli_stmt_execute($stmt);
- $affected_rows = mysqli_stmt_affected_rows($stmt);
- if($affected_rows == 1){
- echo '<h3>Staff Entered</h3>';
- mysqli_stmt_close($stmt);
- mysqli_close($dbc);
- } else {
- echo '<h3>Error Occurred<br /></h3>';
- echo mysqli_error($dbc);
- mysqli_stmt_close($stmt);
- mysqli_close($dbc);
- }
- }
- else {
- echo '<h3>You need to enter or adjust the following data:<br /></h3>';
- foreach($data_missing as $missing){
- echo "$missing<br />";
- }
- }
- }
- ?>
- </div>
- <?php include("addstaff.php");?>
- </h3>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement