You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
2.1 KiB
74 lines
2.1 KiB
6 months ago
|
<?php
|
||
|
$db_server="localhost";
|
||
|
$db_user="root";
|
||
|
$db_pass="";
|
||
|
$db_name="foodshare";
|
||
|
|
||
|
$conn=mysqli_connect($db_server,$db_user,$db_pass,$db_name);
|
||
|
if(!$conn){
|
||
|
die("Connection failed:".mysqli_connect_error());
|
||
|
}
|
||
|
if($_SERVER['REQUEST_METHOD']==='POST'){
|
||
|
$user_type=$_POST['user_type'];
|
||
|
$name=$_POST['name'];
|
||
|
$email=$_POST['email'];
|
||
|
$password=$_POST['password'];
|
||
|
|
||
|
if($user_type=='donor'){
|
||
|
$table='donor';
|
||
|
}elseif ($user_type=='receiver') {
|
||
|
$table='receiver';
|
||
|
}else{
|
||
|
die("invalid user type selected.");
|
||
|
}
|
||
|
$query="INSERT INTO $table(name,email,password) VALUES(?,?,?)";
|
||
|
$stmt=mysqli_prepare($conn,$query);
|
||
|
if($stmt){
|
||
|
mysqli_stmt_bind_param($stmt,"sss",$name,$email,$password);
|
||
|
if(mysqli_stmt_execute($stmt)){
|
||
|
header("Location:login.php");
|
||
|
exit;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
?>
|
||
|
|
||
|
|
||
|
<!DOCTYPE html>
|
||
|
<html lang="en">
|
||
|
<head>
|
||
|
<meta charset="UTF-8">
|
||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
|
<link rel="stylesheet" href="signup.css">
|
||
|
<title>Signup page</title>
|
||
|
|
||
|
|
||
|
</head>
|
||
|
<body>
|
||
|
<div class="container">
|
||
|
<img src="logo.png" alt="" class="logo">
|
||
|
<h1> Sign Up </h1>
|
||
|
<form action="signup.php" method="post" id="signup-form">
|
||
|
<label for ="user-type">Select Your Role:</label>
|
||
|
<select id="user-type" name="user_type" required>
|
||
|
<option value="donor">Donor</option>
|
||
|
<option value="receiver">Receiver</option>
|
||
|
</select>
|
||
|
<label class="full" for="name">Full Name</label>
|
||
|
<input type="text" id="name" name="name" placeholder="Enter your full name"required>
|
||
|
|
||
|
<label class="email" for="email">Email</label>
|
||
|
<input type="email" id="email" name="email" placeholder="Enter your email"required>
|
||
|
|
||
|
<label class="pass" for="password">Password</label>
|
||
|
<input type="password" id="password" name="password" placeholder="Sign password"required><br><br>
|
||
|
|
||
|
<button type="submit">Sign Up</button><br>
|
||
|
<p class="iou"> Already have an account?<a href="login.php">Login</a></p>
|
||
|
|
||
|
</form>
|
||
|
</div>
|
||
|
<script src="signup.js"></script>
|
||
|
</body>
|
||
|
</html>
|