Advertisement
Guest User

Untitled

a guest
Jun 6th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. <?php
  2. session_start();
  3. $host="xx.xx.x.xxx"; // Host name
  4. $user="xxxx"; // username
  5. $pass="xxx"; // password
  6. $dbname="xxx"; // Database name
  7.  
  8. // Connect to server and select databse.
  9. pg_connect("host=$host user=$user dbname=$dbname password=$pass")or die("cannot connect");
  10.  
  11. // username and password sent from form
  12. $myusername=$_POST['myusername'];
  13. $mypassword=$_POST['mypassword'];
  14. $vegpont_id=$_POST['vegpont_id'];
  15.  
  16. $sql="SELECT * FROM vegpont v, ugyfel u WHERE v.azonosito='$myusername' and u.pwd='$mypassword' and u.ugyfel_id=v.ugyfel_id";
  17. $result=pg_query($sql);
  18.  
  19. // pg_num_row is counting table row
  20. $count=pg_num_rows($result);
  21. // If result matched $myusername and $mypassword, table row must be 1 row
  22. $row = pg_fetch_array($result, PGSQL_ASSOC);
  23. if($count==1){
  24.  
  25. // Register $myusername, $mypassword, $vegpont_id and redirect to file "login_success.php"
  26. session_register("myusername");
  27. session_register("mypassword");
  28. session_register("vegpont_id");
  29.  
  30. header("location:login_success.php");
  31. }
  32. else {
  33. echo "Wrong Username or Password";
  34. }
  35. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement