Advertisement
Guest User

Untitled

a guest
Jul 18th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. <?php
  2. $host="localhost";
  3. $db="pmartine_myapp";
  4. $user="pmartine_maynor";
  5. $password="eUZchUvC[wqb";
  6. $con = new mysqli($host,$db,$user,$password);
  7. ?>
  8.  
  9. <?php
  10.  
  11. if(!empty($_POST)){
  12. if(isset($_POST["username"]) &&isset($_POST["password"])){
  13. if($_POST["username"]!=""&&$_POST["password"]!=""){
  14. include "conexion.php";
  15.  
  16.  
  17.  
  18. $sql1= "select * from user where (username="$_POST[username]" or email="$_POST[username]") and password="$_POST[password]" ";
  19. $query = $con->query($sql1);
  20. while ($r=$query->fetch_array()) {
  21. $user_id=$r["id"];
  22. $user_name=$r['username'] ;
  23. $full_name=$r['fullname'] ;
  24. $carrera=$r['carrera'] ;
  25. $seccion=$r['seccion'] ;
  26. $password=$r['password'] ;
  27. $online=$r['online'];
  28.  
  29.  
  30. break;
  31. }
  32. if($user_id==$_POST["username"]){
  33. print "<script>alert("Acceso invalido.");window.location='../login.php';</script>";
  34. }else{
  35. session_start();
  36. $_SESSION["user_id"]=$user_id;
  37. $_SESSION["user_name"]=$user_name;
  38. $_SESSION["full_name"]=$full_name;
  39. $_SESSION["carrera"]=$carrera;
  40. $_SESSION["seccion"]=$seccion;
  41. $_SESSION["password"]=$password;
  42.  
  43.  
  44. $modificar = $con->query("UPDATE user SET online = '1' WHERE id = '".$_SESSION['user_id']."'");
  45. $_SESSION["online"]=$online;
  46.  
  47.  
  48.  
  49. print "<script>window.location='../home.php';</script>";
  50. }
  51. }
  52. }
  53. }
  54.  
  55. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement