mirror of
https://github.com/mudabbir-ahmad/web-project.git
synced 2026-10-07 20:20:20 +00:00
new file: .cache/replit/nix/env.json
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
This commit is contained in:
commit
e5d4d5dfe3
43 files changed
+2680
No files matched your search
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
$servername= "localhost";
|
||||
$dBUserName= "root";
|
||||
$dBPassword= "";
|
||||
$dBName= "proto1";
|
||||
|
||||
$conn = mysqli_connect($servername, $dBUserName, $dBPassword, $dBName);
|
||||
|
||||
if (!$conn) {
|
||||
die("connection failed: ". mysqli_connect_error());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
<?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();
|
||||
}
|
||||
|
||||
Whitespace-only changes.
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
if (isset($_POST["submit"])) {
|
||||
|
||||
$name = $_POST["name"];
|
||||
$email = $_POST["email"];
|
||||
$username = $_POST["uid"];
|
||||
$pwd = $_POST["pwd"];
|
||||
$pwdRepeat = $_POST["pwdrepeat"];
|
||||
|
||||
require_once 'dbh.inc.php';
|
||||
require_once 'functions.inc.php';
|
||||
|
||||
if (emptyInputSignup($name, $email, $username, $pwd, $pwdRepeat) !==false) {
|
||||
header("location: ../register.html?error=emptyinput");
|
||||
exit();
|
||||
}
|
||||
|
||||
if (invalidUid($username) !==false) {
|
||||
header("location: ../register.html?error=invaliduid");
|
||||
exit();
|
||||
}
|
||||
if (invalidEmail($email) !==false) {
|
||||
header("location: ../register.html?error=invalidemail");
|
||||
exit();
|
||||
}
|
||||
if (pwdMatch($pwd, $pwdRepeat) !==false) {
|
||||
header("location: ../register.html?error=passwordsdontmatch");
|
||||
exit();
|
||||
}
|
||||
if (uidExists($conn, $username, $email) !==false) {
|
||||
header("location: ../register.html?error=usernametaken");
|
||||
exit();
|
||||
}
|
||||
|
||||
createUser($conn, $name, $username, $email, $pwd);
|
||||
}
|
||||
|
||||
else {
|
||||
header("location: ../register.html");
|
||||
exit();
|
||||
}
|
||||
Reference in new issue
Block a user