Created
November 4, 2018 13:51
-
-
Save pfieffer/5fea7ddf18cc3a282ed53fe21f024688 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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