Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
50 lines (43 sloc) 1.73 KB
<!DOCTYPE html PUBLIC "-//W#C//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> PHP Code Blocks </title><meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /></head><body>
<h1>nothing to see here</h1>
<?php
$servername = "localhost";
$username = "root";
$password = "root";
$dbname = "interviews";
//main - no empty lines
if(empty($_POST['name']) || empty($_POST['position']) || empty($_POST['date']) || empty($_POST['communication']) ||
empty($_POST['look']) || empty($_POST['pclit']) || empty($_POST['knowledge']) || empty($_POST['comments'])){
echo "You must fill in all the fields!<br>\n";
}
else { if(!is_numeric($_POST['date'])){ echo "age/average feild must have a numeric value!";}
//add slashes for special chars... also variables
$name=addslashes($_POST['name'])
$position=addslashes($_POST['position'])
$communication=addslashes($_POST['communication'])
$look=addslashes($_POST['look'])
$pclit=addslashes($_POST['pclit'])
$knowledge=addslashes($_POST['knowledge'])
$comments=addslashes($_POST['comments'])
$date=$_POST['date'];
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
//arrange data
$sql = "INSERT INTO MyGuests (name, position, communication, look, pclit, knowledge, date, comment)
VALUES ('$name', '$position', '$communication', '$look', '$pclit', '$knowledge', '$date', '$comment')";
//try to write data
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
}
?>
</body></html>