Why an I getting this message in PHP?
prepare($query); $stmt->bindValue(':firstname', $firstname); $stmt->bindValue(':lastname', $lastname); $stmt->bindValue(':username', $username); $stmt->bindValue(':password', $password); $stmt->bindValue(':username', $username); $stmt->bindValue(':role', $role); $stmt = execute(); $stmt->closeCursor; }
//Display Admin page include(admin_menu.php) ?>
add_user_form.php
// Initialize the session
session_start();
$firstname = $_SESSION["firstname"] = 'dale';
$lastname = $_SESSION["lastname"] = 'owens';
$username = $_SESSION["username"] = 'daleo';
$role = $_SESSION["role"] = 'A';
$adminuserid = $_SESSION["id"] = 'A';
// (Make sure the user is logged in as a valid administrator
if ($role != "A") {
header("Location: ." );
}
?>
Reservations
add_user.php
/* Database credentials. Assuming you are running MySQL
server with default setting (user 'root' with no password) */
define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'root');
define('DB_PASSWORD', 'BN8lnGpEY9dqWsAP');
define('DB_NAME', 'id15305974_reservations');
/* Attempt to connect to MySQL database */
$link = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
// Initialize the session
session_start();
//$firstname = $_SESSION["firstname"] = 'dale';
//$lastname = $_SESSION["lastname"] = 'owens';
//$username = $_SESSION["username"] = 'daleo';
$role = $_SESSION["role"] = 'A';
$adminuserid = $_SESSION["id"] = 'A';
// (Make sure the user is logged in as a valid administrator
if ($role != 'A') {
header("Location: ." );
}
// Get the product data
$firstname = filter_input(INPUT_POST, 'firstname');
$lastname = filter_input(INPUT_POST, 'lastname');
$username = filter_input(INPUT_POST, 'username');
$password = filter_input(INPUT_POST, 'password');
$role = filter_input(INPUT_POST, 'role');
echo 'Hello';
//Validate inputs
if ($firstname == null || $firstname == false || $lastname == null || $lastname == false ||
$username == null || $username == false || $password == null || $password == fasle ||
$role == null || $role == false) {
$error = "Invalid Booking ID. Check the Booking ID and try again.";
include ('error.php');
} else {
$link = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME); // require a database connection
// Get reservations by date for viewing
$query = 'INSERT INTO users (firstname, lastname, username, password, role)
VALUES (:firstname,:lastname,:username,:password,:role)';
$stmt = $link->prepare($query);
$stmt->bindValue(':firstname', $firstname);
$stmt->bindValue(':lastname', $lastname);
$stmt->bindValue(':username', $username);
$stmt->bindValue(':password', $password);
$stmt->bindValue(':username', $username);
$stmt->bindValue(':role', $role);
$stmt = execute();
$stmt->closeCursor;
}
//Display Admin page
include(admin_menu.php)
?>