Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- echo("Hello Lewis");
- session_start();
- //convert the field values to simple variables
- //add slashes to the username and md5() the password
- $user = addslashes($_POST['username']);
- $pass = md5($_POST['password']);
- echo $pass;
- //set the database connection variables
- $dbHost = "localhost";
- $dbUser = "root";
- $dbPass = "pqqmsb";
- $dbDatabase = "danpilch";
- //connect to the database
- $db = mysql_connect("$dbHost", "$dbUser", "$dbPass") or die ("Error connecting to database.");
- mysql_select_db("$dbDatabase", $db) or die ("Couldn't select the database.");
- $result = mysql_query("select * from registration where username='$user' AND password='$pass'", $db);
- //check that at least one row was returned
- $rowCheck = mysql_num_rows($result);
- $row = mysql_fetch_array($result);
- if($rowCheck > 0){
- //start the session and register a variable
- $_SESSION['username']= $row['username'];
- // redirect to home page
- header("location:usersettings.php?username=" . $row['username']);
- }
- else {
- header("location:incorrect-password.php");
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement