Implemented userInfo submition but is don't work yet
This commit is contained in:
+9
-17
@@ -1,26 +1,11 @@
|
||||
<?php
|
||||
include 'connection.php';
|
||||
require_once 'functions.php';
|
||||
$conn = connectMysql();
|
||||
$userName = $_POST['username'];
|
||||
$passWord = $_POST['password'];
|
||||
$passWord_hashed = password_hash($passWord, PASSWORD_DEFAULT);
|
||||
|
||||
function query_addUser($conn, $uid, $upass) {
|
||||
$sql = "INSERT INTO account(C_ID,C_Password) VALUES( ? , ? )";
|
||||
$stmt = mysqli_stmt_init($conn);
|
||||
if (!mysqli_stmt_prepare($stmt, $sql)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
mysqli_stmt_bind_param($stmt, "ss", $uid, $upass);
|
||||
mysqli_stmt_execute($stmt);
|
||||
|
||||
$error = mysqli_stmt_errno($stmt);
|
||||
mysqli_stmt_close($stmt);
|
||||
return $error;
|
||||
}
|
||||
|
||||
|
||||
// $query = "INSERT INTO account(C_ID,C_Password) VALUES('$userName','$passWord')";
|
||||
if (isset($_POST['g-recaptcha-response']) && !empty($_POST['g-recaptcha-response'])) {
|
||||
|
||||
@@ -35,7 +20,14 @@ if (isset($_POST['g-recaptcha-response']) && !empty($_POST['g-recaptcha-response
|
||||
echo "Verification success.";
|
||||
$error = query_addUser($conn, $userName, $passWord_hashed);
|
||||
if ($error === 0) {
|
||||
echo "<script> alert('New account created successfully!');location.href='../index.php'; </script>";
|
||||
|
||||
$error = query_addUserInfo($conn, $userName);
|
||||
if ($error === 0) {
|
||||
echo "<script> alert('New account created successfully!');location.href='../index.php'; </script>";
|
||||
} else {
|
||||
echo "<script> alert('Error creating userInfo.');location.href='../index.php'; </script>";
|
||||
}
|
||||
|
||||
} else {
|
||||
echo "<script> alert('Username already exists.');location.href='../index.php'; </script>";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user