this is my register code:
<?php
session_start(); //Must Start a session.
require "config.php"; //Connection Script, include in every file!
//Check to see if the user is logged in.
//'isset' check to see if a variables has been 'set'
if(isset($_SESSION['username'])){
header("location: members.php");
}
//Check to see if the user click the button
if(isset($_POST['submit']))
{
//Variables from the table
$user = $_POST['user'];
$pass = $_POST['pass'];
$rpass = $_POST['rpass'];
$email = $_POST['email'];
//Prevent MySQL Injections
$user = stripslashes($user);
$pass = stripslashes($pass);
$rpass = stripslashes($rpass);
$email = stripslashes($email);
$user = mysqli_real_escape_string($con, $user);
$pass = mysqli_real_escape_string($con, $pass);
$rpass = mysqli_real_escape_string($con, $rpass);
$email = mysqli_real_escape_string($con, $email);
//Check to see if the user left any space empty!
if($user == "" | $pass == "" | $rpass == "" | $email == "")
{
echo "Alstublieft, vul alle vakjes in!";
}
else
{
//Check too see if the user's Passwords Matches!
if($pass != $rpass)
{
echo "Passworden komen niet overeen! Probeer het opnieuw";
}
//CHECK TO SEE IF THE USERNAME IS TAKEN, IF NOT THEN ADD USERNAME AND PASSWORD INTOT HE DB
else
{
//Query the DB
$query = mysqli_query($con,"SELECT * FROM users WHERE username = '$user'") or die("Kan het niet in de tabel zetten!");
//Count the number of rows. If a row exist, then the username exist!
$row = mysqli_num_rows($query);
if($row == 1)
{
echo "Sorry, maar die username is al in gebruik! Probeer het opnieuw.";
}
//ADD THE USERNAME TO THE DB
else
{
$add = mysqli_query($con,"INSERT INTO users (id, username, password, email) VALUES (null, '$user' , '$pass', '$email') ") or die("Kan niet toevoegen!");
echo "Gelukt! <a href='login.php'> Klik hier </a>om in te loggen!";
}
}
}
}
?>
But how do I use salt in it? I know it's an extra security but I don't know how to use it. I looked on the internet and tried some code but every time it doesn't work.