by nyabutijj » 25. August 2023 19:54
Where is the folder "doctorpatientsystem" located on your PC? is located in C:\xampp\htdocs\doctorpatientsystem
What did you enter into the browser? i created a login form, want capture the user's information. I will show you after the questions bellow.
How did you install that system? i installed xampp in my windows 11 OS and the icon is green. When i started installing xampp it gave me the warning to deactivate UAC with msconfig and i did it. But is my first time to link my php project with mysql database.
<?php
include_once 'header.php';
?>
<section class="signup-form">
<style type="text/css">
#text{
height: 25px;
border-radius: 5px;
padding: 4px;
border: solid thin #aaa;
width: 100%;
}
#button{
padding: 10px;
width: 100px;
color: white;
background-color: Lightblue;
border: none;
}
#box{
background-color: grey;
margin: auto;
width: 300px;
padding: 20px;
}
</style>
<div id="box">
<form action="includes/signup.inc.php" method="post">
<div style="font-size: 20px;margin: 10px;color: white"><h2>signup</h2></div>
<input id="text" type="text" name="first_name" placeholder="First name..."><br><br>
<input id="text" type="text" name="sir_name" placeholder="Sir name..."><br><br>
<input id="text" type="text" name="email" placeholder="Email.... "><br><br>
<input id="text" type="text" name="Uid" placeholder="Username..."><br><br>
<input id="text" type="password" name="pwd"placeholder="password..."><br><br>
<input id="text" type="password" name="pwdrepeat"placeholder="Repeat password..."><br><br>
Gender:
<input type="radio" name="gender"value="female">Female
<input type="radio" name="gender"value="male">Male<br><br>
Birthday:
<input type="date" name="bday"><br><br>
Age:
<input id="text" type="number" name="num"placeholder="Enter your age..."><br><br>
Mobile Number:
<input id="text" type="text" name="mobileno"placeholder="Enter phone number..."><br><br>
National id:
<input id="text" type="text" name="idnumber"placeholder="Enter you National id..."><br><br>
<button type="submit" name="submit">Sign Up</button><br><br>
</form>
</div>
</section>
<?php
include_once 'footer.php';
?>
<?php
include_once 'header.php';
?>
<section class="Login-form">
<style type="text/css">
#text{
height: 25px;
border-radius: 5px;
padding: 4px;
border: solid thin #aaa;
width: 100%;
}
#button{
padding: 10px;
width: 100px;
color: white;
background-color: Lightblue;
border: none;
}
#box{
background-color: grey;
margin: auto;
width: 300px;
padding: 20px;
}
</style>
<div id="box">
<form action="includes/login.inc.php" method="post">
<div style="font-size: 20px;margin: 10px;color: white"> Login </div>
<input id="text" type="text" name="name" placeholder="Username/Email..."><br><br>
<input id="text" type="password" name="pwd"placeholder="password..."><br><br>
<input id="button" type="submit" value="Log In"><br><br>
</form>
</div>
</section>
<?php
include_once 'footer.php';
?>
signup.inc.php
<?php
if (isset($_POST["submit"])){
$firstname = $_POST["first_name"];
$sirname = $_POST["sir_name"];
$email = $_POST["email"];
$username = $_POST["Uid"];
$pwd = $_POST["pwd"];
$pwdrepeat = $_POST["pwdrepeat"];
$gender = $_POST["gender"];
$date = $_POST["bday"];
$age = $_POST["num"];
$mobileno = $_POST["mobileno"];
$idnumber = $_POST["idnumber"];
require_once 'dbh.inc.php';
require_once 'functions.inc.php';
if (emptyInputSignup($firstname,$sirnam,$email,$username,$pwd,$pwdrepeat,$gender,$date,$age,$mobileno,$idnumber) !==false){
header("location:..../signup.php?error=emptyinputy");
exit();
}
if (invalideUid($username) !==false){
header("location:..../signup.php?error=invalideUid");
exit();
}
if (invalideEmail($email) !==false){
header("location:..../signup.php?error=invalideEmail");
exit();
}
if (pwMatch($pwd,$pwdrepeat) !==false){
header("location:..../signup.php?error=passworddontmatch");
exit();
}
if (uidExists($conn,$username,$email) !==false){
header("location:..../signup.php?error=usernametaken");
exit();
}
createuser($conn,$firstname,$sirname,$email,$username,$pwd,$gender,$date,$age,$mobileno,$idnumber);
}
else{
header("location:..../signup.php");
}
?>
login.inc.php
<?php
include_once 'header.php';
?>
<section class="login-form">
<h2>Login</h2>
<form action="login.inc.php" method="post">
</form>
</section>
<?php
include_once 'footer.php';
?>
functions.inc.php
<?php
function emptyInputsignup($firstname,$sirnam,$email,$username,$pwd,$pwdrepeat,$gender,$date,$age,$mobileno,$idnumber) {
$results;
if (empty($firstname) || empty($sirnam) || empty($email) || empty($username) || empty($pwd) || empty($pwdrepeat) || empty($gender) || empty($date) || empty($age) || empty($mobileno) || empty($idnumber)){
$result = true;
}
else{
$result = false;
}
return $result;
}
function invalideUid($username){
$results;
if (! preg_match("/^[a-zA-Z0-9]*$/", $username)){
$result = true;
}
else{
$result = false;
}
return $result;
}
function invalideEmail($email){
$results;
if (!filter_var($email, FILTER_VALDATE_EMAIL)){
$result = true;
}
else{
$result = false;
}
return $result;
}
function pwMatch($pwd,$pwdrepeat){
$results;
if ($pwd !== $pwdrepeat){
$result = true;
}
else{
$result = false;
}
return $result;
}
function uidExists($conn,$username,$email){
$sql = "SELECT * FROM register WHERE Uid = ? OR email_address = ?;";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql)) {
header("location: ../signup.php?error=stmtfailed");
exit();
}
mysqli_stmt_blind_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,$firstname,$sirname,$email,$username,$pwd,$gender,$date,$age,$mobileno,$idnumber){
$sql = "INSERT INTO register(first_name,sir_name,email_address,Uid,password,gender,birthday,age,phone_number,national_id) VALUES (?,?,?,?,?,?,?,?,?,?);";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql)) {
header("location: ../signup.php?error=stmtfailed");
exit();
}
$hashedpwd = password_hash($pwd, PASSWORD_DEFAULT);
mysqli_stmt_blind_param($stmt, "ssssssssss", $firstname,$sirname,$email,$username,$hashedpwd,$gender,$date,$age,$mobileno,$idnumber);
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
header("location: ../signup.php?error=none");
exit();
}
?>
dbh.inc.php
<?php
$serverName = "localhost";
$dBUsername = "root";
$dBPassword = "";
$dBName = "doctorpatientsystem";
$conn = mysqli_connect($serverName,$dBUsername,$dBPassword,$dBName);
if (!$conn){
die("connection failed: " .mysqli_connect_error());
}