dean012 Posted November 30, 2013 Share Posted November 30, 2013 it should be directed to adminlogin.php but nothing happen <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR...l1-strict.dtd"> <!-- --> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="keywords" content="" /> <meta name="description" content="" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Yakity Yak</title> <link href='http://fonts.googlea...=Oswald:400,300' rel='stylesheet' type='text/css'> <link href='http://fonts.googlea...css?family=Abel|Satisfy' rel='stylesheet' type='text/css'> <link href="style.css" rel="stylesheet" type="text/css" media="screen" /> </head> <body> <div id="wrapper"> <p><!-- end #header --></p> <div id="header" class="container"> <div id="logo"> <h1><a href="#">Yakity Yak</a></h1> </div> <div id="menu"> <ul> <li class="current_page_item"><a href="homepage.php">Homepage</a></li> <li><a href="trip.php">Destinations</a></li> <li><a href="contact.php">contact </a></li> <li><a href="registration.php">Login</a></li> <li><a href="adminlogin.php">Leader</a></li> <li></li> <li></li> </ul> </div> </div> <blockquote> <blockquote> <p> <center><img src="sd.jpg" width="999" height="300" alt=""/></center> </p> </blockquote> </blockquote> <div id="page"> <div class="post"> <h2 class="title"><a href="#">Welcome Admin</a></h2> <form action="" method="post"> <table align="center" style="cellpadding: 10px; cellspacing: 10px;"> <tr><td>username:</td> <td><input type="text" name="username"/></td></tr> <tr><td>password:</td> <td><input type="password" name="password"/></td></tr> <tr><td> </td><td><input type="submit" name="submit"/></td></tr> </table> </form> </body> </html> <div class="entry"> </div> </div> </div> </body> </html> <?php session_start() ; if (!session_is_registered('pass')){ header('location:adminlogin.php'); } $username=$_POST['username']; $password=$_POST['password']; if ($username==('admin') & $password==('123') ) { $session_register['username']; $session_register['password']; ; } else echo 'something went wrong! Try again. Thanks.' ; ?> Quote Link to comment https://forums.phpfreaks.com/topic/284409-it-wont-go-to-that-page/ Share on other sites More sharing options...
dean012 Posted November 30, 2013 Author Share Posted November 30, 2013 "The page isn't redirecting properly" Quote Link to comment https://forums.phpfreaks.com/topic/284409-it-wont-go-to-that-page/#findComment-1460779 Share on other sites More sharing options...
aysiu Posted November 30, 2013 Share Posted November 30, 2013 This is your form action: <form action="" method="post"> Can you change that to <form action="adminlogin.php" method="post"> and try again? Quote Link to comment https://forums.phpfreaks.com/topic/284409-it-wont-go-to-that-page/#findComment-1460780 Share on other sites More sharing options...
dean012 Posted November 30, 2013 Author Share Posted November 30, 2013 nope didnt work Quote Link to comment https://forums.phpfreaks.com/topic/284409-it-wont-go-to-that-page/#findComment-1460781 Share on other sites More sharing options...
MDCode Posted November 30, 2013 Share Posted November 30, 2013 You can not use header() after any output is sent to the browser i.e. HTML. Turn on error reporting while debugging. Quote Link to comment https://forums.phpfreaks.com/topic/284409-it-wont-go-to-that-page/#findComment-1460786 Share on other sites More sharing options...
dean012 Posted December 1, 2013 Author Share Posted December 1, 2013 so what should i do? Quote Link to comment https://forums.phpfreaks.com/topic/284409-it-wont-go-to-that-page/#findComment-1460796 Share on other sites More sharing options...
MDCode Posted December 1, 2013 Share Posted December 1, 2013 (edited) Move the PHP code above the HTML...fix the syntax error being the extra semicolon, and realize you're using session register as a variable. Edit: And change the bit wise (&) to the operator symbolizing and (&&) Edited December 1, 2013 by SocialCloud Quote Link to comment https://forums.phpfreaks.com/topic/284409-it-wont-go-to-that-page/#findComment-1460800 Share on other sites More sharing options...
dean012 Posted December 1, 2013 Author Share Posted December 1, 2013 still nt working <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR...l1-strict.dtd"> <!-- --> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="keywords" content="" /> <meta name="description" content="" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Yakity Yak</title> <link href='http://fonts.googlea...=Oswald:400,300' rel='stylesheet' type='text/css'> <link href='http://fonts.googlea...css?family=Abel|Satisfy' rel='stylesheet' type='text/css'> <link href="style.css" rel="stylesheet" type="text/css" media="screen" /> </head> <body> <div id="wrapper"> <p><!-- end #header --></p> <div id="header" class="container"> <div id="logo"> <h1><a href="#">Yakity Yak</a></h1> </div> <div id="menu"> <ul> <li class="current_page_item"><a href="homepage.php">Homepage</a></li> <li><a href="trip.php">Destinations</a></li> <li><a href="contact.php">contact </a></li> <li><a href="registration.php">Login</a></li> <li><a href="adminlogin.php">Leader</a></li> <li></li> <li></li> </ul> </div> </div> <blockquote> <blockquote> <p> <center><img src="sd.jpg" width="999" height="300" alt=""/></center> </p> </blockquote> </blockquote> <div id="page"> <div class="post"> <h2 class="title"><a href="#">Welcome Admin</a></h2> <form action="adminlogin.php" method="post"> <table align="center" style="cellpadding: 10px; cellspacing: 10px;"> <tr><td>username:</td> <td><input type="text" name="username"/></td></tr> <tr><td>password:</td> <td><input type="password" name="password"/></td></tr> <tr><td> </td><td><input type="submit" name="submit"/></td></tr> </table> </form> </body> </html> <div class="entry"> </div> </div> </div> <?php session_start() ; if (!session_is_registered('pass')){ header('location:adminlogin.php'); } $username=$_POST['username']; $password=$_POST['password']; if ($username==('admin') && $password==('123') ) { $session_register['username']; $session_register['password']; } else echo 'something went wrong! Try again. Thanks.' ; ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/284409-it-wont-go-to-that-page/#findComment-1460802 Share on other sites More sharing options...
ignace Posted December 1, 2013 Share Posted December 1, 2013 (edited) Well perhaps you should put in some effort and actually do what SocialCloud told you to do. What he said is correct, but you have failed to apply it. You can not use session_start() after sending output to the browser. All the HTML above <?php is output. Turn on error_reporting with: error_reporting(-1); ini_set('display_errors', 1);And write your PHP first, your HTML second as in: <?php session_start(); error_reporting(-1); ini_set('display_errors', 1); // PHP code here ?> HTML code here (yes that is <!DOCTYPE ..><html> and everything)Do not use session_is_registered() or session_register() but instead use the global variable $_SESSION. Stop following the tutorial you are reading, it's outdated. To check if a session variable has been registered: if (isset($_SESSION['is-this-here'])) { // yes it is } // to create session variables $_SESSION['i-am-persisted'] = true; Edited December 1, 2013 by ignace Quote Link to comment https://forums.phpfreaks.com/topic/284409-it-wont-go-to-that-page/#findComment-1460826 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.