CloudBreaker Posted July 7, 2015 Share Posted July 7, 2015 (edited) I'm trying to get my log-in script to work. I'm getting two undefined variables for $user_loginName and $user_pass. Plus, even with the correct log and pass I can't log in. My database connection is good and I didn't misspell the my user table. Can some see something that I'm unable to see. Is there an easy way to script this?...if so, got a link? Thanks, CB <!DOCTYPE html> <?php session_start(); $conn = mysqli_connect("localhost","root","","hsa_project_hub"); ?> <!--Project Hub index--> <html> <head> <title>Project Hub Login</title> <!-- Modernizr allows HTML5 elements to work in older browsers: http://modernizr.com/ --> <script src="js/modernizr.js"></script> </head> <style> img { display: block; margin-left: auto; margin-right: auto; box-shadow: 5px 5px 5px #888888; Float: left position: relative; } #container { background: #F0F0F0; width: 300px; display: block; margin-left: auto; margin-right: auto; border-style: solid; border-width: 1px; } h4 { font-family: "Avant Garde",Avantgarde,"Century Gothic",CenturyGothic,AppleGothic,sans-serif; font-size: 30px; color: #8F0000; float: left; position: relative; left: 70px; font-style:italic; } #copy_right { font-size: 12px; text-align: center; } </style> <body> <div id="container"> <img src="images/hsa-logo.jpg" align="middle" alt=HSA logo> <h4>Project Hub</h4> <!--Start of form--> <form action="index.php" method="post"> <table align="center" bgcolor="#F0F0F0" width="300" > <tr align="center"> </tr> <tr> <td align="right"><strong>Log-in:</strong></td> <td> <input type="text" name="user_loginName" placeholder="Enter your Log-in" required="required"/> </td> </tr> <tr> <td align="right"><strong>Password:</strong></td> <td> <input type="password" name="user_pass" placeholder="Enter your pass"required="required"/> </td> </tr> <tr align="center"> <td colspan="6"> <input type="submit" name="login" value="Login"/> </td> </tr> </table> </form> </div><!--End of Container--> <p id="copy_right">Heitkamp Swift Architects © 2015</p> <?php //Validate log-in and password if(isset($_POST['login'])) { $user_loginName = mysqli_real_escape_string($conn,$_post['user_loginName']); $user_pass = mysqli_real_escape_string($conn,$_post['user_pass']); $sel = "select * from hsa_users where user_loginName='$user_loginName' AND user_pass='$user_pass'"; $run = mysqli_query($conn, $sel); $check = mysqli_num_rows($run); if($check==0){ echo "<script>alert('Incorrect Log-in or Password. Try again.')</script>"; exit(); } else { $_SESSION['user_loginName']=$user_loginName; echo "<script>window.open('main.php','_self')</script>"; } } ?> </body> </html> Edited July 7, 2015 by CloudBreaker Quote Link to comment Share on other sites More sharing options...
Solution Ch0cu3r Posted July 7, 2015 Solution Share Posted July 7, 2015 Variables are case sensitive, so $_post is not the same as $_POST Quote Link to comment Share on other sites More sharing options...
CloudBreaker Posted July 7, 2015 Author Share Posted July 7, 2015 That was it...thanks. Sometime you just have to know when to step away from the computer. Quote Link to comment 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.