Commit 9492f58a authored by Jonathan Poalses's avatar Jonathan Poalses

Added php

parent 28304e6a
<?php
/* Attempt MySQL server connection. Assuming you are running MySQL
server with default setting (user 'root' with no password) */
define( 'DB_SERVER', 'localhost' );
define( 'DB_staffNo', 'jonathan.poalses' );
define( 'DB_PASSWORD', '8YlReLMlNknGQzZq' );
define( 'DB_NAME', 'jonathanpoalses' );
/* Attempt to connect to MySQL database */
$link = mysqli_connect( DB_SERVER, DB_staffNo, DB_PASSWORD, DB_NAME );
// Check connection
if ( $link === false ) {
die( "ERROR: Could not connect. " . mysqli_connect_error() );
}
// Prepare a select statement
$sql = "INSERT INTO HCI VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
if ( $stmt = mysqli_prepare( $link, $sql ) ) {
// Bind variables to the prepared statement as parameters
mysqli_stmt_bind_param( $stmt, "iiiiiiiiiiiii", $Clean, $Story1, $Story2, $Story3, $Story4, $Story5, $Story6, $Story7, $Story8, $Story9, $Story10, $Story11, $Story12 );
//Retrive all the data, making sure to trim and filter
$Clean = 1;
$Story1 = filter_var( trim( $_POST[ "Story1" ] ), FILTER_SANITIZE_NUMBER_INT );
$Story2 = filter_var( trim( $_POST[ "Story2" ] ), FILTER_SANITIZE_NUMBER_INT );
$Story3 = filter_var( trim( $_POST[ "Story3" ] ), FILTER_SANITIZE_NUMBER_INT );
$Story4 = filter_var( trim( $_POST[ "Story4" ] ), FILTER_SANITIZE_NUMBER_INT );
$Story5 = filter_var( trim( $_POST[ "Story5" ] ), FILTER_SANITIZE_NUMBER_INT );
$Story6 = filter_var( trim( $_POST[ "Story6" ] ), FILTER_SANITIZE_NUMBER_INT );
$Story7 = filter_var( trim( $_POST[ "Story7" ] ), FILTER_SANITIZE_NUMBER_INT );
$Story8 = filter_var( trim( $_POST[ "Story8" ] ), FILTER_SANITIZE_NUMBER_INT );
$Story9 = filter_var( trim( $_POST[ "Story9" ] ), FILTER_SANITIZE_NUMBER_INT );
$Story10 = filter_var( trim( $_POST[ "Story10" ] ), FILTER_SANITIZE_NUMBER_INT );
$Story11 = filter_var( trim( $_POST[ "Story11" ] ), FILTER_SANITIZE_NUMBER_INT );
$Story12 = filter_var( trim( $_POST[ "Story12" ] ), FILTER_SANITIZE_NUMBER_INT );
// Attempt to execute the prepared statement
if ( mysqli_stmt_execute( $stmt ) ) {
// Redirect to main menu
header("location: ../thanks.html");
} else {
echo "ERROR: Could not execute $sql. " . mysqli_error( $link );
}
}
// Close statement
mysqli_stmt_close( $stmt );
// close connection
mysqli_close( $link );
?>
\ No newline at end of file
<?php
/* Attempt MySQL server connection. Assuming you are running MySQL
server with default setting (user 'root' with no password) */
define( 'DB_SERVER', 'localhost' );
define( 'DB_staffNo', 'jonathan.poalses' );
define( 'DB_PASSWORD', '8YlReLMlNknGQzZq' );
define( 'DB_NAME', 'jonathanpoalses' );
/* Attempt to connect to MySQL database */
$link = mysqli_connect( DB_SERVER, DB_staffNo, DB_PASSWORD, DB_NAME );
// Check connection
if ( $link === false ) {
die( "ERROR: Could not connect. " . mysqli_connect_error() );
}
// Prepare a select statement
$sql = "INSERT INTO HCI VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
if ( $stmt = mysqli_prepare( $link, $sql ) ) {
// Bind variables to the prepared statement as parameters
mysqli_stmt_bind_param( $stmt, "iiiiiiiiiiiii", $Clean, $Story1, $Story2, $Story3, $Story4, $Story5, $Story6, $Story7, $Story8, $Story9, $Story10, $Story11, $Story12 );
//Retrive all the data, making sure to trim and filter
$Clean = 0;
$Story1 = filter_var( trim( $_POST[ "Story1" ] ), FILTER_SANITIZE_NUMBER_INT );
$Story2 = filter_var( trim( $_POST[ "Story2" ] ), FILTER_SANITIZE_NUMBER_INT );
$Story3 = filter_var( trim( $_POST[ "Story3" ] ), FILTER_SANITIZE_NUMBER_INT );
$Story4 = filter_var( trim( $_POST[ "Story4" ] ), FILTER_SANITIZE_NUMBER_INT );
$Story5 = filter_var( trim( $_POST[ "Story5" ] ), FILTER_SANITIZE_NUMBER_INT );
$Story6 = filter_var( trim( $_POST[ "Story6" ] ), FILTER_SANITIZE_NUMBER_INT );
$Story7 = filter_var( trim( $_POST[ "Story7" ] ), FILTER_SANITIZE_NUMBER_INT );
$Story8 = filter_var( trim( $_POST[ "Story8" ] ), FILTER_SANITIZE_NUMBER_INT );
$Story9 = filter_var( trim( $_POST[ "Story9" ] ), FILTER_SANITIZE_NUMBER_INT );
$Story10 = filter_var( trim( $_POST[ "Story10" ] ), FILTER_SANITIZE_NUMBER_INT );
$Story11 = filter_var( trim( $_POST[ "Story11" ] ), FILTER_SANITIZE_NUMBER_INT );
$Story12 = filter_var( trim( $_POST[ "Story12" ] ), FILTER_SANITIZE_NUMBER_INT );
// Attempt to execute the prepared statement
if ( mysqli_stmt_execute( $stmt ) ) {
// Redirect to main menu
header("location: ../thanks.html");
} else {
echo "ERROR: Could not execute $sql. " . mysqli_error( $link );
}
}
// Close statement
mysqli_stmt_close( $stmt );
// close connection
mysqli_close( $link );
?>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment