Guest User

Untitled

a guest
Feb 28th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. <?php
  2. ob_start();
  3. //Step 1: create database connection
  4. $connection = mysql_connect("localhost", "joenna", "joenna"); //name of host, username, password
  5. if (!$connection)
  6. { die("Database Connection Failed" . mysql_error());
  7. }
  8.  
  9. //step 2: select database to use
  10. $db = mysql_select_db("joenna",$connection); //name of database and connection
  11. if (!$db)
  12. {
  13. die("Database selection failed" . mysql_error());
  14. }
  15.  
  16. // Define $myusername and $mypassword
  17. global $myusername;
  18. $myusername =$_POST['Username'];
  19. $mypassword =$_POST['Password'];
  20.  
  21. $sql="SELECT * FROM information WHERE username='$myusername' and password='$mypassword'";
  22. $result=mysql_query($sql);
  23.  
  24.  
  25.  
  26. $count=mysql_num_rows($result);
  27.  
  28. if($count==1){
  29.  
  30. session_register("myusername");
  31. session_register("mypassword");
  32. header("location:products2.php");
  33. }
  34. else {
  35. header("location:invalidpass.php");
  36.  
  37. }
  38. ob_end_flush();
  39. ?>
Add Comment
Please, Sign In to add comment