mirror of
https://github.com/mudabbir-ahmad/web-project.git
synced 2026-10-07 20:20:20 +00:00
new file: .config/configstore/update-notifier-npm.json new file: .config/configstore/update-notifier-npm.json.2701252402 new file: .replit new file: .vscode/launch.json new file: Internet.html new file: about.html new file: case.html new file: cooling.html new file: cpu.html new file: css/about.css new file: css/home.css new file: css/log copy.css new file: css/log.css new file: css/parts.css new file: css/pc.css new file: css/profile.css new file: global.css new file: global.js new file: gpu.html new file: hdd.html new file: home.html new file: images/pc-case.png new file: images/sal.jpeg new file: includes/dbh.inc.php new file: includes/functions.inc.php new file: includes/login.inc.php new file: includes/signup.inc.php new file: index.html new file: js/log copy.js new file: js/log.js new file: keyb.html new file: log copy.html new file: log.html new file: monitor.html new file: mouse.html new file: pc.html new file: profile.html new file: psu.html new file: ram.html new file: register.html new file: replit.nix new file: ssd.html
89 lines
2.0 KiB
PHP
89 lines
2.0 KiB
PHP
<?php
|
|
|
|
function emptyInputSignup($name, $email, $username, $pwd, $pwdRepeat)
|
|
{
|
|
$result;
|
|
if (empty($name) || empty($email) || empty($username) || empty($pwd) || empty($pwdRepeat)) {
|
|
$result = true;
|
|
} else {
|
|
$result = false;
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
function invalidUid($username)
|
|
{
|
|
$result;
|
|
if (preg_match("/^[a-zA-Z0-9]*$/", $username)) {
|
|
$result = true;
|
|
} else {
|
|
$result = false;
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
function invalidEmail($email)
|
|
{
|
|
$result;
|
|
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
|
$result = true;
|
|
} else {
|
|
$result = false;
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
function pwdMatch($pwd, $pwdRepeat)
|
|
{
|
|
$result;
|
|
if ($pwd !== $pwdRepeat) {
|
|
$result = true;
|
|
} else {
|
|
$result = false;
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
|
|
function uidExists($conn, $username, $email)
|
|
{
|
|
$sql = "SELECT * FROM users WHERE usersUid = ? OR usersEmail = ?;";
|
|
$stmt = mysqli_stmt_init($conn);
|
|
if (!mysqli_stmt_prepare($stmt, $sql)) {
|
|
header("location: ../signup.html?error=stmtfailed");
|
|
exit();
|
|
}
|
|
|
|
mysqli_stmt_bind_param($stmt, "ss", $username, $email);
|
|
mysqli_stmt_execute($stmt);
|
|
|
|
$resultData = mysqli_stmt_get_result($stmt);
|
|
|
|
if ($row = mysqli_fetch_assoc($resultData)) {
|
|
return $row;
|
|
} else {
|
|
$result = false;
|
|
return $result;
|
|
}
|
|
mysqli_stmt_close($stmt);
|
|
}
|
|
|
|
function createUser($conn, $name, $username, $email, $pwd)
|
|
{
|
|
$sql = "INSERT INTO users (usersName, usersEmail, usersUid, UsersPwd) VALUES (?, ?, ?, ?);";
|
|
$stmt = mysqli_stmt_init($conn);
|
|
if (!mysqli_stmt_prepare($stmt, $sql)) {
|
|
header("location: ../register.html?error=stmtfailed");
|
|
exit();
|
|
}
|
|
|
|
$hashedPwd = password_hash($pwd, PASSWORD_DEFAULT);
|
|
|
|
mysqli_stmt_bind_param($stmt, "ssss", $name, $email, $username, $hashedPwd);
|
|
mysqli_stmt_execute($stmt);
|
|
mysqli_stmt_close($stmt);
|
|
header("location: ../register.html?error=none");
|
|
exit();
|
|
}
|
|
|