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 Reservations Reservations Add User First Name: Last Name: Username:    Password:    Role:   © Reservations   add_user.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) ?>

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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

<?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: ." );
}

?>
<!DOCTYPE html>
<html>

<!-- the head section -->
<head>
<title>Reservations</title>
<link rel="stylesheet" type="text/css" href="main.css">
</head>

<!-- the body section -->
<body>
<header><h1>Reservations</h1></header>

<main>
<form action="add_user.php" method="post"
id="add_user_form">
<h1> Add User </h1>

<label>First Name:</label>
<input type="text" name="firstname"><br>

<label>Last Name:</label>
<input type="text" name="lastname"><br>

<label>Username:</label>
<input type="text" name="username"><br>
  
<label>Password:</label>
<input type="text" name="password"><br>
  
<label>Role:</label>
<input type="text" name="role"><br>

<label>&nbsp;</label>
<input type="submit" value="Add User"><br>
</form>
</main>

<footer>
<p>&copy; <?php echo date("Y"); ?> Reservations</p>
</footer>
</body>
</html>

 

add_user.php

<?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)
?>

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Form and its Elements
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education