Implemented userInfo submition but is don't work yet
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
function query_username($conn, $uid) {
|
||||
$sql = "Select * From account Where C_ID= ? ";
|
||||
$stmt = mysqli_stmt_init($conn);
|
||||
if (!mysqli_stmt_prepare($stmt, $sql)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
mysqli_stmt_bind_param($stmt, "s", $uid);
|
||||
mysqli_stmt_execute($stmt);
|
||||
|
||||
$resultData = mysqli_stmt_get_result($stmt);
|
||||
mysqli_stmt_close($stmt);
|
||||
return $resultData;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
function query_addUserInfo($conn, $uid) {
|
||||
$sql = "INSERT INTO userInfo(C_ID,C_EMAIL,C_PHONE,C_ADDRESS,C_UNIT,C_CITY,C_COUNTRY,C_ZIP) VALUES( ? , '' , '' , '' , '' , '' , '' , '')";
|
||||
$stmt = mysqli_stmt_init($conn);
|
||||
if (!mysqli_stmt_prepare($stmt, $sql)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
mysqli_stmt_bind_param($stmt, "s", $uid);
|
||||
mysqli_stmt_execute($stmt);
|
||||
|
||||
$error = mysqli_stmt_errno($stmt);
|
||||
mysqli_stmt_close($stmt);
|
||||
return $error;
|
||||
}
|
||||
|
||||
function qeury_updateUserInfo($conn, $uid, $email, $phone, $address, $unit, $city, $country, $zip) {
|
||||
$sql = "UPDATE userInfo SET C_EMAIL = ' ? ',C_PHONE = ' ? ',C_ADDRESS = ' ? ',C_UNIT = ' ? ',C_CITY = ' ? ',C_COUNTRY = ' ? ',C_ZIP = ' ? ' WHERE C_ID = ' ? '";
|
||||
$stmt = mysqli_stmt_init($conn);
|
||||
if (!mysqli_stmt_prepare($stmt, $sql)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
mysqli_stmt_bind_param($stmt, "ssssssss", $email, $phone, $address, $unit, $city, $country, $zip, $uid);
|
||||
mysqli_stmt_execute($stmt);
|
||||
|
||||
$error = mysqli_stmt_errno($stmt);
|
||||
mysqli_stmt_close($stmt);
|
||||
return $error;
|
||||
}
|
||||
?>
|
||||
+2
-16
@@ -1,25 +1,11 @@
|
||||
<?php
|
||||
include 'connection.php';
|
||||
require_once 'connection.php';
|
||||
require_once 'functions.php';
|
||||
$conn = connectMysql();
|
||||
session_start();
|
||||
$userName = $_POST['username'];
|
||||
$passWord_user = $_POST['password'];
|
||||
|
||||
function query_username($conn, $uid) {
|
||||
$sql = "Select * From account Where C_ID= ? ";
|
||||
$stmt = mysqli_stmt_init($conn);
|
||||
if (!mysqli_stmt_prepare($stmt, $sql)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
mysqli_stmt_bind_param($stmt, "s", $uid);
|
||||
mysqli_stmt_execute($stmt);
|
||||
|
||||
$resultData = mysqli_stmt_get_result($stmt);
|
||||
mysqli_stmt_close($stmt);
|
||||
return $resultData;
|
||||
}
|
||||
|
||||
$result = query_username($conn, $userName);
|
||||
|
||||
|
||||
|
||||
+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>";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
require_once 'connection.php';
|
||||
require_once 'functions.php';
|
||||
$conn = connectMysql();
|
||||
require_once 'logged_in_header.php';
|
||||
$userName = $_SESSION['username'];
|
||||
$email = $_POST['email'];
|
||||
$phone = $_POST['phone'];
|
||||
$address = $_POST['address'];
|
||||
$unit = $_POST['unit'];
|
||||
$city = $_POST['city'];
|
||||
$country = $_POST['country'];
|
||||
$zip = $_POST['zip'];
|
||||
$isChecked = $_POST['isChecked'];
|
||||
|
||||
if (isset($_POST['isChecked'])) {
|
||||
$error = qeury_updateUserInfo($conn, $userName, $email, $phone, $address, $unit, $city, $country, $zip);
|
||||
header("Location: ../shopping/userInfo.php?error=$error");
|
||||
} else {
|
||||
header("Location: ../shopping/userInfo.php?error=notChecked");
|
||||
exit();
|
||||
}
|
||||
$conn->close();
|
||||
?>
|
||||
Reference in New Issue
Block a user