-
Notifications
You must be signed in to change notification settings - Fork 0
/
x.php
72 lines (61 loc) · 2.1 KB
/
x.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
$conn=mysqli_connect('mysqli','root','','assoc');
if(isset($_POST['submit'])){
$user_name = mysqli_real_escape_string($conn, $_POST['user_name']);
$user_email = mysqli_real_escape_string($conn, $_POST['user_email']);
$pass = md5($_POST['password']);
$cpass = md5($_POST['cpassword']);
$user_type = $_POST['user_type'];
$select = " SELECT * FROM users WHERE user_email = '$user_email' && user_password= '$pass' ";
$result = mysqli_query($conn, $select);
if(mysqli_num_rows($result) > 0){
$error[] = 'user already exist!';
}else{
if($pass != $cpass){
$error[] = 'password not matched!';
}else{
$insert = "INSERT INTO users(user_name, user_email, user_password, user_type) VALUES('$user_name','$user_email','$pass','$user_type')";
mysqli_query($conn, $insert);
# header('location:login_form.php');
}
}
};
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Log in</title>
<!-- custom css file link -->
<link rel="stylesheet" href="Admin/assets/css/style.css">
</head>
<body>
<div class="bc">
<div class="form-container">
<form action="" method="post">
<h3>Add user</h3>
<?php
if(isset($error)){
foreach($error as $error){
echo '<span class="error-msg">'.$error.'</span>';
};
};
?>
<input type="text" name="user_name" required placeholder="enter the user name">
<input type="email" name="user_email" required placeholder="enter the email">
<input type="password" name="password" required placeholder="enter your password">
<input type="password" name="cpassword" required placeholder="confirm your password">
<select name="user_type">
<option value="user">user</option>
<option value="admin">admin</option>
</select>
<input type="submit" name="submit" value="register now" class="form-btn">
<p>already have an account? <a href="login_form.php">login now</a></p>
<p>ouma</p>
</form>
</div>
</div>
</body>
</html>