Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- = <?php
- $host="mysql14.000webhost.com";
- $username="a2512574_user";
- $password="123hello";
- $db_name="a2512574_users";
- $tbl_name="Persons";
- mysql_connect("$host", "$username", "$password")or die("cannot connect");
- mysql_select_db("$db_name")or die("cannot select DB");
- $myusername=$_POST['username'];
- $mypassword=$_POST['password'];
- $myusername = stripslashes($myusername);
- $mypassword = stripslashes($mypassword);
- $myusername = mysql_real_escape_string($myusername);
- $mypassword = mysql_real_escape_string($mypassword);
- $sql= mysql_query("SELECT * FROM $tbl_name WHERE username='".$myusername."'");
- $rows = mysql_fetch_array($sql);
- // you don't need this in a loop, only ONE row of data is returned per user
- if ($mypassword == $rows['password']) {
- //check to make sure the password is correct
- setcookie("username", $myusername, time()+216000);
- setcookie("password", $mypassword, time()+216000);
- //Set cookies with username and password
- $first_name = $rows['FirstName'];
- $last_name = $rows['LastName'];
- $email = $rows['Email'];
- $sex = $rows['Sex'];
- $age = $rows['Age'];
- $sex_or = $rows['Sex_Or'];
- echo "First Name: ", $first_name, "<br />";
- echo "Last Name: ", $last_name, "<br />";
- echo "Email: ", $email, "<br />";
- echo "Sex: ", $sex, "<br />";
- echo "Age: ", $age, "<br />";
- echo "Sexual Orientation: ", $sex_or;
- //Produce Information
- } ELSE {
- //Else produce an error.
- Echo "Error invalid username or password";
- }
- ?>
Add Comment
Please, Sign In to add comment