Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // functions.php
- <?php include 'connect.php'; ?>
- function createData() {
- global $connection;
- $username = mysqli_real_escape_string($connection, $username);
- $password = mysqli_real_escape_string($connection, $password);
- $hashFormat = '$2y$07$';
- $salt = 'usesomesillystringforsalt$';
- $hashF_salt = $hashFormat . $salt;
- $password = crypt($password, $hashF_salt);
- $query = "INSERT INTO users(username, password) ";
- $query .= "VALUES('$username', '$password')";
- $result = mysqli_query($connection, $query);
- if(!$result) {
- die(mysql_error());
- } else {
- echo "Created";
- }
- }
- // create.php
- <?php include "functions.php"; ?>
- if(isset($_POST['submit'])) {
- $username = $_POST['username'];
- $password = $_POST['password'];
- if($username && $password) {
- createData();
- } else {
- echo "Input can not be blank";
- }
- }
Add Comment
Please, Sign In to add comment