コード例 #1
0
function save_receptionist($sincard, $date_birth, $address, $city, $postal, $phone_num, $last_name, $first_name, $gender, $username, $password)
{
    /*stripslashes is a function that remvoes any slashes
    	in the given input, used to prevent SQL injection*/
    $sincard = stripslashes($sincard);
    $date_birth = stripslashes($date_birth);
    $city = stripslashes($city);
    $postal = stripslashes($postal);
    $phone_num = stripslashes($phone_num);
    $last_name = stripslashes($last_name);
    $first_name = stripslashes($first_name);
    $gender = stripslashes($gender);
    $username = stripslashes($username);
    $password = stripslashes($password);
    /*call save_people function declared above that inserts
    	the given data into people table*/
    save_people($sincard, $date_birth, $address, $city, $postal, $phone_num, $last_name, $first_name, $gender);
    /*include connect file that configures the 
    	connection to the database */
    include 'includes/connect.php';
    /*a insertion query in the receptionist table*/
    $sc = mysqli_query($dbhandle, "INSERT INTO `receptionist`(`sincard`, `username`, `password`) VALUES ('{$sincard}','{$username}','{$password}')");
    /*checks if query insertion is successful
    	if not display error*/
    if (!$sc) {
        ?>
		<div class="gagal">
			Error: Sorry, We cant't create a new Receptionist at this moment !
		</div><?php 
    } else {
        ?>
		<div class="informasi">
			Success: New Receptionist information has been created
		</div><?php 
        header("Refresh: 3; url=employee.php");
    }
}
コード例 #2
0
<?php

include_once "config.php";
include_once "libs.php";
if (isset($_POST['submit_people'])) {
    $unit = $_POST['people_info'];
    $citizen_name = $_POST['people'];
    $people_info = explode('|', $unit);
    $country_id = $people_info[0];
    $city_id = $people_info[1];
    save_people($citizen_name, $city_id, $country_id);
    header("Location: ../index.php");
}