Initial commit
This commit is contained in:
38
login/RegisterByDB.php
Normal file
38
login/RegisterByDB.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
include "../indexes/ConnectDB.php";
|
||||
|
||||
//get posted messages
|
||||
$user = $_POST["user"]; // username from login form
|
||||
$pwd = $_POST["pwd"]; // password from login form
|
||||
$user_type = $_POST["user_type"]; // password from login form
|
||||
|
||||
// check if user is empty
|
||||
$sql_regname = "SELECT * FROM $user_type WHERE name = '$user'";
|
||||
$res = mysqli_query($conn, $sql_regname);
|
||||
$row = mysqli_num_rows($res);
|
||||
|
||||
if($row == 0){
|
||||
if($user){
|
||||
// prepare sql
|
||||
$sql_insert = "INSERT INTO `$user_type` (`name`, `pwd`) VALUES ('$user', '$pwd')";
|
||||
$result = mysqli_query($conn, $sql_insert); //if success, return 1
|
||||
// redirect to interfaces
|
||||
if($result > 0){
|
||||
echo "<script type='text/javascript'>
|
||||
window.location.href = './interfaces/register_success.php';
|
||||
</script>";
|
||||
}
|
||||
else {
|
||||
echo "<script type='text/javascript'>
|
||||
window.location.href = './interfaces/register_interrupted.php';
|
||||
</script>";
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
echo "<script type='text/javascript'>
|
||||
window.location.href = './interfaces/register_failed.php';
|
||||
</script>";
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user