Advertisement
Guest User

Untitled

a guest
Feb 6th, 2017
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. <?php
  2. if(!empty($_POST)){
  3. if(isset($_POST["username"]) &&isset($_POST["password"])){
  4. if($_POST["username"]!=""&&$_POST["password"]!=""){
  5. include "conexion.php";
  6. $nombre_usuario=null;
  7. $user_id=null;
  8. $sql1= "select * from user where (username=\"$_POST[username]\" or email=\"$_POST[username]\") and password=\"$_POST[password]\" ";
  9. $query = $con->query($sql1);
  10. while ($r=$query->fetch_array()) {
  11. $user_id=$r["id"];
  12. $nombre_usuario=$r["username"];
  13. break;
  14. }
  15. if($user_id==null){
  16. print "<script>alert(\"Acceso invalido.\");window.location='../login.php';</script>";
  17. }else{
  18. session_start();
  19. $_SESSION["nombre_usuario"]=$nombre_usuario;
  20. $_SESSION["user_id"]=$user_id;
  21. print "<script>window.location='../home.php';</script>";
  22. }
  23. }
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement