SignGuestBook.php - /This checks for empty fields first...

This preview shows page 1 - 2 out of 2 pages.

//This checks for empty fields first and last name and returns text if both are empty if(empty($_POST['first_name']) || empty($_POST['last_name'])) { echo " You must enter your first and last name. CLICK your browser's back button to return to the Guest Book \n"; } else { //the fields are not empty, create variables for database. $user = "root"; $password = ""; $host = "localhost"; $DBConnect = mysqli_connect($host, $user, $password); if($DBConnect === FALSE) { //if the database does not connect it will display text. echo " Unable to connect to the database server. " . " Error Code" . mysqli_errno() . ":" . mysqli_error() . " "; } else { $DBName = "guestbook";// if true, dbname will be guestbook. if(! mysqli_select_db($DBConnect, $DBName)) {//if there isnt a database to select, sqlstring will create a database and will query. $SQLstring = "CREATE DATBASE $DBName"; $QueryResult = mysqli_query($DBConnect, $SQLstring); if($QueryResult === FALSE) { //if the query result is false, it iwll dsplay the error and mysqli error text echo " Unable to execute query.

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture