timmykins02 Posted March 27, 2012 Share Posted March 27, 2012 So I'm doing a project and I need to make a successful login form, where it checks in MS Access if the username and password are correct, and if they are the user is taken to a new page. If they are wrong, a message comes up and they stay on the same page. The user should first just see a blank form, but after submit is pressed, it should check if the username and password are correct. IF they are should be taken to a new page. It's been a while since I used php last, so I wasn't quite sure how to tackle this issue. I was wondering if someone could please help me? here is my code. <html> <head> <style type="text/css"> </style> </head> <body style="text-align:center"> <div id='title'> </div> <?php print_r ($_POST) ; if (isset($_POST['submit'])) { if(isset($_POST['username'])){ $username= $_POST['username'] ; } if(isset($_POST['password'])){ $TABLE= $_POST['password'] ; } $username = null ; $password = null ; $connection = odbc_connect('Olympics', '', ''); if (!$connection) {exit("Conection Failed: " . $connection);} $username = stripslashes($username); $password = stripslashes($password); $sql = "select * from users where users = '$username' and passwords = '$password'"; $rs=odbc_exec($connection,$sql); $count=odbc_num_rows($rs); if ($count == 1) { $_SESSION['loggedIn'] = "true"; header("Location: searchpage.php"); } else { $_SESSION['loggedIn'] = "false"; header("Location: index.php"); echo "Login failed" ; } } echo "<form action='index.php' method='post'> \n" ; echo" Please enter your username and password if you wish. <br/> \n" ; echo "Username: <input type='text' name='username' > \n " ; echo "Password: <input type='password' name='password' > \n" ; echo "<input type='submit' value='Login' name='submit'> <br/> \n" ; echo "<input type='submit' value='You may also continue you as a guest.'> \n" ; ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/259790-php-login-form-with-odbc-connection-toms-access/ Share on other sites More sharing options...
grim1208 Posted March 27, 2012 Share Posted March 27, 2012 It would be helpful to us if you could point out what issues you are having. Quote Link to comment https://forums.phpfreaks.com/topic/259790-php-login-form-with-odbc-connection-toms-access/#findComment-1331486 Share on other sites More sharing options...
timmykins02 Posted March 27, 2012 Author Share Posted March 27, 2012 yeah sorry. Well after I press submit nothing happens. It doesnt take me the next page or anything. Quote Link to comment https://forums.phpfreaks.com/topic/259790-php-login-form-with-odbc-connection-toms-access/#findComment-1331615 Share on other sites More sharing options...
grim1208 Posted March 27, 2012 Share Posted March 27, 2012 yeah sorry. Well after I press submit nothing happens. It doesnt take me the next page or anything. you don't have your <form> tag closed. see if that helps out Quote Link to comment https://forums.phpfreaks.com/topic/259790-php-login-form-with-odbc-connection-toms-access/#findComment-1331644 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.