Having a little issue with a from and MYSQL.
I created a Job Interview form that takes certain criteria from the interviewer and places that information into a database so you can extract the information later.
What my problem is I'm getting no error messages or successful output. It's not even creating the database in myPHPAdmin in WAMP, and I don't see where I'm going wrong here. Been hashing this over for a few days now.
Here's the code :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Job Interview</title>
<meta http-equiv="content-type"
content="txt/html; charset=iso-8859-1" />
</head>
<body>
<?php
/* ==== Code to ensure interviewer fills out all required areas === */
if (empty($_GET['first_name']) ||
empty($_GET['last_name']) ||
empty($_GET['position']) ||
empty($_GET['cand_first']) ||
empty($_GET['cand_last']) ||
empty($_GET['cand_ID']) ||
empty($_GET['comments']))
die("<p>You must enter a value in every field for the interview! Click your
browser's Back button to return to the Interview form.</p>");
if (($_GET['month'] == "Month") ||
($_GET['date'] == "Day") ||
($_GET['year'] == "Year"))
die ("<p>You must enter the full date in the drop down menus! Click
your browser's Back button to return to the Interview form.</p>");
if ($_GET['recommendation'] == "--- --- ---")
die ("<p>You must enter a recommendation value in the drop down menu! Click
your browser's Back button to return to the Interview form.</p>");
if (($_GET['intellect'] == "--- --- ---") ||
($_GET['communication'] == "--- --- ---") ||
($_GET['business'] == "--- --- ---") ||
($_GET['computer'] == "--- --- ---"))
die ("<p>You must enter values for all of the Candidate's skills/presentation
from the drop down menues! Click your browser's Back button to return to
the Interview form.</p>");
/* ==== Code to connect to the database ==== */
$DBConnect = @mysqli_conntect("localhost", "root", "precision9")
Or die("<p>Unable to connect to the database server.</p>"
. "<p>Error code " . mysqli_connect_errno()
. ": " . mysqli_connect_error()) . "</p>";
/* ==== Code to create hit_counter database if it does not already exist ==== */
$DBName = "jobinterview";
if (!@mysqli_select_db($DBConnect, $DBname)) {
$SQLstring = "CREATE DATABASE $DBName";
$QueryResult = @mysqli_query($DBConnect, $SQLstring)
Or die("<p>Unable to execute the query.</p>"
. "<p>Error code " . mysqli_errno($DBConnect)
. ": " . mysqli_error($DBConnect)) . "</p>";
echo "<p>This is the first Candidate</p>";
echo "<p>Successfully created the database</p>";
mysqli_select_db($DBConnect, $DBName);
}
/* ==== Code to create a table to give countID === */
$TableName = "candidates";
$SQLstring = "SELECT * FROM $TableName";
$QueryResult = @mysqli_query($DBConnect, $SQLstring);
if (!$QueryResult) {
$SQLstring = "CREATE TABLE $TableName (countID SMALLINT
NOT NULL AUTO_INCREMENT PRIMARY KEY,
cand_last VARCHAR(40), cand_first VARCHAR(40))";
$QueryResult = @mysqli_query($DBConnect, $SQLstring)
Or die("<p>Unable to create the table.</p>"
. "<p>Error code " . mysqli_errno($DBConnect)
. ": " . mysqli_error($DBConnect)) . "</p>";
echo "<p>Successfully created the candidates table</p>";
}
/* ==== Adds the candidate to the database and closes the connection ==== */
$LastName = addslashes($_GET['cand_last']);
$FirstName = addslashes($_GET['cand_first']);
$SQLstring = "INSERT INTO $TableName VALUES(NULL, '$LastName',
'$FirstName')";
$QueryResult = @mysqli_query($DBConnect, $SQLstring)
Or die("<p>Unable to execute the query.</p>"
. "<p>Error code " . mysqli_errno($DBConnect)
. ": " . mysqli_error($DBConnect)) . "</p>";
echo "<strong>Interview Saved</strong>";
mysqli_close($DBConnect);
?>
</body>
</html>
Any help is much appreciated.