php if isset _POST username isset _POST login connect mysql_connect lo

 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
<?php
if(isset($_POST['username']) && isset($_POST['login'])){
$connect= mysql_connect("localhost","root") or die(mysql_error());
mysql_select_db("register");
$username=$_POST['username'];
$login=$_POST['login'];
$password=$_POST['password'];
$r_password=$_POST['r_password'];
if($password==$r_password) {
die("<h1>Registration is successful<h1>");
$query=mysql_query("INSERT INTO users (`username`, `login`, `password`) VALUES('$username', '$login', '$password')")or die(mysql_error());
}
else{
die("<h1>Password must match<h1>");
}
}
if (isset($_POST['enter'])){
$e_login=$_POST['e_login'];
$e_password=$POST['e_password'];
$query=mysql_query("SELECT * FROM users WHERE login='$e_login");
$user_data=mysql_fetch_array($query);
if($user_data['password'] == $e_password){
echo "osdfgk";
}
else{
echo"wrong password or login";
}
}
?>
<form method="post" action ="register.php">
<input type="text"name="username" placeholder="Username" required /><br>
<input type="text"name="login"placeholder="Login" required /> <br>
<input type="password"name="password"placeholder="Password" required /> <br>
<input type="password"name="r_password"placeholder="Repeat password" required /> <br>
<input type="submit" name="submit" value="register"/>
</form>
<form method="post" action ="register.php">
<input type="text"name="e_login"placeholder="Login" required /> <br>
<input type="password"name="e_password"placeholder="Password" required /> <br>
<input type="submit" name="enter" value="Enter"/>
</form>