Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- // Get data from form
- $username = $_POST['username'];
- $password = $_POST['password'];
- // Connect to the database
- $dbhost = 'localhost'; // Database host
- $dbuser = 'dbusername'; //Database username
- $dbpass = 'dbpassword'; //Database password
- $dbname = 'dbname'; //database name
- // Run the data connection
- $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
- // Select which database you want to use
- mysql_select_db($dbname, $conn);
- // Look in database to see if there are any account with the chosen username and password
- $sql_uname_check = "SELECT * FROM people WHERE username='$username' AND password='$password';";
- // So this says have a look and see if there is an account in the people table with the selected username AND password
- // Run the query and put the results in a variable
- $result_name_check = mysql_query($sql_uname_check);
- // Count how many users were returned
- $peepsfound = mysql_num_rows($result_name_check);
- // there were 0 users found ( < 1)
- if ($peepsfound < 1) {
- // Error not found
- $error = "User $uname not found.";
- //If there was a user found
- } else {
- //Add their details to the session for use later
- $_SESSION['unamename'] = $uname;
- $_SESSION['encryptcode'] = $code;
- }
- }
- /* End of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement