Skip to content

Instantly share code, notes, and snippets.

@pfieffer
Created November 4, 2018 13:51
Show Gist options
  • Save pfieffer/5fea7ddf18cc3a282ed53fe21f024688 to your computer and use it in GitHub Desktop.
Save pfieffer/5fea7ddf18cc3a282ed53fe21f024688 to your computer and use it in GitHub Desktop.
<?php
//For connecting the database
$link = mysqli_connect("localhost","root","", "practise");
if (!$link) {
echo "Error: Unable to connect to MySQL." . PHP_EOL;
echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
exit;
}
//session_start();
$username=$_POST['username'];
$fname=$_POST['fname'];
$lname=$_POST['lname'];
$email=$_POST['email'];
$password=$_POST['password'];
$salt=('nepal');
$hashed_password = crypt ( $password, $salt); //password hashing
$query= "INSERT INTO users (id, fname, lname, email, username, password) VALUES ('','$fname','$lname','$email','$username','$hashed_password')";
if(mysqli_query($link, $query) == TRUE)
{
echo "Successful";
}
else
{
echo "Error: " . $query . "<br>" . mysql_error();
}
mysqli_close($link);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment