Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- "register.php":
- <?php
- include 'config.php';
- $username = $_POST['username'];
- $password = $_POST['password'];
- $password2 = $_POST['password2'];
- $confirm = $_POST['1'];
- if($password&&$password2==true)
- {
- if($password!=$password2)
- {
- Die("Please make sure the passwords are the same.");
- }
- }
- if($username&&$password==true)
- {
- $md5 = md5($password);
- mysql_query("INSERT INTO user (username, password)
- VALUES ('$username', '$md5')");
- }
- Elseif($username==""&&$confirm==true)
- {
- Die("Error: Make sure you enter a username!");
- }
- Elseif($password==""&&$confirm==true)
- {
- Die("Error: Make sure you enter a password!");
- }
- ?>
- <html>
- <body>
- <form action="register.php" method="post">
- Username: <input type="text" name="username" /><br>
- Password: <input type="password" name="password" /><br>
- Password again: <input type="password" name="password2" /><br>
- <input type="submit" value="Register!" name="1" />
- </form>
- </body>
- </html>
- "login.php":
- <?php
- include 'config.php';
- $password = $_POST['password'];
- $username = $_POST['username'];
- $md5 = md5($password);
- $expire=time()+60*60*24;
- $query = mysql_query("SELECT password FROM user WHERE username='$username'");
- echo $query;
- echo $query[0];
- if ($query[0]==$md5)
- {
- setcookie("username", $username, $expire);
- setcookie("password", $md5, $expire);
- }
- ?>
- "index.php":
- <?php
- if(isset($_COOKIE['username']) && isset($_COOKIE['password']))
- {
- echo "test";
- }
- echo $_COOKIE['username'] . $_COOKIE['password'];
- ?>
- <html>
- <body>
- <form action="login.php" method="post">
- Username: <input type="text" name="username" /><br>
- Password: <input type="password" name="password" />
- <input type="submit" value="log in" />
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement