Advertisement
Guest User

[PHP] Redirect solution

a guest
May 15th, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.00 KB | None | 0 0
  1. <!doctype html>
  2. <?php
  3. if(isset($_POST['submit'])){
  4. $user = $_POST['username'];
  5. $pass = $_POST['password'];
  6. if($user=="admin" && $pass=="admin"){
  7. /* Redirect to a different page in the current directory that was requested
  8. $host  = $_SERVER['HTTP_HOST'];
  9. $uri   = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
  10. $extra = 'mypage.php';
  11. header("Location: http://$host$uri/$extra");
  12. */
  13. header("Location: www.google.com"); //This will redirect you to google
  14. }else{
  15. echo("error ! please enter correct data!");
  16. }
  17. }
  18. ?>
  19. <html>
  20. <head>
  21. <meta charset="utf-8">
  22. <title>Untitled Document</title>
  23. </head>
  24.  
  25. <body>
  26. <form action="" method="post">
  27. <table align="center">
  28. <tr>
  29. <td>username:</td>
  30. <td><input type="text" name="username" placeholder="enter your username"></td>
  31. </tr>
  32. <tr>
  33. <td>Password:</td>
  34. <td><input type="password" name ="password" placeholder="enter your password"></td>
  35. </tr>
  36. <tr>
  37. <td></td>
  38. <td><input type="submit" name="submit" value="submit"</td>
  39. </tr>
  40. </table>
  41. </form>
  42. </body>
  43. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement