Skip to content

Instantly share code, notes, and snippets.

@CuzImBisonratte
Created December 17, 2021 17:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CuzImBisonratte/f69705db983df5df5262f8befd7acaf5 to your computer and use it in GitHub Desktop.
Save CuzImBisonratte/f69705db983df5df5262f8befd7acaf5 to your computer and use it in GitHub Desktop.
<?php
// Database credentials
$DATABASE_HOST = '';
$DATABASE_USER = '';
$DATABASE_PASS = '';
$DATABASE_NAME = '';
$DATABASE_TABLE = '';
// Connect with the Credentials
$con = mysqli_connect($DATABASE_HOST, $DATABASE_USER, $DATABASE_PASS, $DATABASE_NAME);
// check if the connection was successfull
if (mysqli_connect_errno()) {
// Log the error
error_log("Error(101)-".mysqli_connect_error(),0);
exit("Error(101)-".mysqli_connect_error());
// Display an error.
exit();
}
if ($stmt = $con->prepare('INSERT INTO '.$DATABASE_TABLE.' (wert1, wert2, wert3, wert4) VALUES (?, ?, ?, ?)')) {
// Get the data
$wert1 = $_POST['wert1'];
$wert2 = $_POST['wert2'];
$wert3 = $_POST['wert3'];
$wert4 = $_POST['wert4'];
$stmt->bind_param('ssss', $wert1, $wert2, $wert3, $wert4);
$stmt->execute();
exit();
// close the statement
$stmt->close();
} else {
// Log the error
exit("Error-".mysqli_error($con));
}
// close the database connection
$con->close();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment