Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //check for required fields from the relevant table
- if ((!isset($_POST['username'])) || (!isset($_POST['member'])))
- {
- exit;
- }
- //connecting to the mysql server and selecting the database. First is host, then username,
- //then password, then database name
- //erase the :7777 part after localhost if it is there, as that is only to get it working on my laptop
- $mysqli = mysqli_connect("localhost", "root", "", "assignment")
- or die(mysql_error());
- //Have it get the names via the username and password that was entered
- $sql = ("SELECT * FROM member WHERE username ='{$_POST['username']}'
- and password = '{$_POST['password']}' LIMIT 1");
- $result = mysqli_query($mysqli, $sql)
- or die(mysqli_error($mysqli));
- if (mysqli_num_rows($result) == 1)
- {
- while ($info = mysqli_fetch_array($result))
- {
- $f_name = stripslashes($info['f_name']);
- $l_name = stripslashes($info['l_name']);
- }
- //set authorization cookie
- setcookie("auth", "1", 0, "/", "yourdomain.com", 0);
- header("Refresh: 3; auth.php");
- echo "<p><a href='auth.php'>Wait for 3sec, or click here if you're not directed</a></p>";
- }
- else
- {
- header("Refresh: 3; login.php");
- echo "<p><a href='login.php'>Wait for 3sec, or click here if you're not directed</a></p>";
- }
- mysqli_close($mysqli);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement