-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser.php
91 lines (90 loc) · 3.43 KB
/
user.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
$servername="localhost";
$username="id14456134_root";
$password="[email protected]";
$database="id14456134_users";
$conn= mysqli_connect($servername,$username,$password,$database);
$error="";
?>
<!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="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="user_style.css?v=<?php echo time(); ?>">
<title>Document</title>
</head>
<body>
<div id="top">
<div>
<form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="POST">
<p>SIGN-IN</p><br />
<label>
<i class="fa fa-user icon"></i>
<input type="text" placeholder="user-name" name="name" required>
</label><br />
<label>
<i class="fa fa-envelope icon"></i>
<input type="email" placeholder="email" name="email" required>
</label><br />
<label>
<i class="fa fa-key icon"></i>
<input type="password" placeholder="password" name="password" required>
</label><br />
<label>
<i class="fa fa-key icon"></i>
<input type="password" placeholder="re-type password" name="re-password" required><br />
</label><br />
<input type="radio" name="position" value="user">user <input type="radio" name="position" value="admin">admin<br />
<button><a href="login.php">back</a></button>
<input type="submit" value="register">
</form>
</div>
<?php
if($_SERVER['REQUEST_METHOD']=='POST')
{
//password length greater than 10
if(strlen($_POST['password'])>=10){
//if both the password are same
if($_POST['password']==$_POST['re-password'])
{
$password= $_POST['password'];
$name= $_POST['name'];
$email=$_POST['email'];
$position=$_POST['position'];
//validation of email
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$error="*enter the valid email address";
}
else
{
$sql= "INSERT INTO `login` VALUES('$name','$email','$password','$position');";
if(mysqli_query($conn,$sql))
{
session_start();
$_SESSION['mail']= $email;
$error="";
header("Location: topic.php");
}
else
{
$error="*try different email address";
}
}
}
else
{
$error="*password must match";
}
}
else
{
//error
$error="*password length must be >=10";
}
}?>
<p id="error"><?php echo $error; ?></p>
</div>
</body>
</html>