Bramdon3000 Posted May 9, 2022 Share Posted May 9, 2022 When I get to my login system I get the errors: Warning: Undefined array key "txt_email" in C:\Users\brand\OneDrive\Desktop\XAMAPP\htdocs\Water Tower 2000\index.php on line 70 Warning: Undefined array key "txt_password" in C:\Users\brand\OneDrive\Desktop\XAMAPP\htdocs\Water Tower 2000\index.php on line 72 Warning: Undefined array key "txt_role" in C:\Users\brand\OneDrive\Desktop\XAMAPP\htdocs\Water Tower 2000\index.php on line 74 So I changed the $email = $_REQUEST ["txt_email"]; to $email = $_COOKIE ["txt_email"]; And this got rid of the error, but when I tried to log on it didn't go to the next page, instead get stayed in the login page. Basically, my multi user login system doesn't work. What can I do? Full Code: Quote Link to comment Share on other sites More sharing options...
requinix Posted May 9, 2022 Share Posted May 9, 2022 That's not your full code. That's a series of screenshots of your editor showing one screenful after another of one particular file that has PHP code in it. 5 minutes ago, Bramdon3000 said: So I changed the $email = $_REQUEST ["txt_email"]; to $email = $_COOKIE ["txt_email"]; I don't know why you thought that was an appropriate change because my educated guess is that the "txt_email" comes from a form and not a cookie. Then again, if educated guesses were enough to go on, these forums wouldn't serve much of a purpose. Stop using $_REQUEST and switch to $_GET (for query parameters) or $_POST (for submitted forms) or, yes, $_COOKIE (for cookies). Only one of those should ever be the correct source to use. Quote Link to comment Share on other sites More sharing options...
Barand Posted May 9, 2022 Share Posted May 9, 2022 Thanks for the pictures - I'll hang them on my lavatory wall. It's all they are useful for. 1 Quote Link to comment Share on other sites More sharing options...
ginerjm Posted May 9, 2022 Share Posted May 9, 2022 Obviously it is telling you that you are using an array that does NOT have any element named txt_email or txt_password or txt_role. So - how is your code being developed to be looking for those items? Study your pictures and see if you can make out a solution. Or you could look at the actual code, which you didn't want to share with us. Quote Link to comment Share on other sites More sharing options...
Bramdon3000 Posted May 9, 2022 Author Share Posted May 9, 2022 Deepest apologies, Going from REQUEST TO GET solved the problem with the warning so thank you. Furthermore, I think I might have a better understanding of where my issue of the login system not working comes from. But I will like to confilm is there anything wrong here? The code I'm trying to set up is $select_stmt=$db->prepare("SELECT username,email FROM masterlogin WHERE username=:uname OR email=:uemail"); Finally I will give you guys the full code. Sorry for not showing you it and I send more in enough comment (run out of space) Quote Link to comment Share on other sites More sharing options...
Bramdon3000 Posted May 9, 2022 Author Share Posted May 9, 2022 Quote Link to comment Share on other sites More sharing options...
Bramdon3000 Posted May 9, 2022 Author Share Posted May 9, 2022 Quote Link to comment Share on other sites More sharing options...
Barand Posted May 9, 2022 Share Posted May 9, 2022 Too pictorial, didn't read. But if you were too explain how I can load those images into my code editor to check your code.... Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted May 9, 2022 Share Posted May 9, 2022 in your previous thread on this forum, you were given a detailed list of practices that will greatly simplify and fix issues in this code. I recommend that you go back and read that information before wasting any more time trying to make this current code work. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted May 9, 2022 Share Posted May 9, 2022 People here LIKE TO READ actual code, not look at hard to makeout pictures. Take the hint. And try and limit the code to what you think is the problem area. We don't need to see all your html or all of your css or even your js if it doesn't pertain. 1 Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted May 10, 2022 Share Posted May 10, 2022 22 hours ago, Bramdon3000 said: Going from REQUEST TO GET solved the problem with the warning so thank you. all that did was stop the code from being executed, since the form(s) are post method forms and the submitted data will be in $_POST, not $_GET. if you haven't studied (class, book, online tutorial) any fundamentals of php programing, you won't be able to debug any problems in code, nor will you be able to understand and make use of any replies in help forums. what learning resources are you using to come up with this code? 1 Quote Link to comment Share on other sites More sharing options...
Bramdon3000 Posted May 10, 2022 Author Share Posted May 10, 2022 (edited) I was inspired by this tutorial: https://www.onlyxcodes.com/2018/12/multi-user-role-based-login-in-php-with-mysql-pdo.html Edited May 10, 2022 by Bramdon3000 Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted May 10, 2022 Share Posted May 10, 2022 this is nonsense code. it contains lines of code that do nothing. the author didn't even know that a header() statement doesn't stop php code execution. 1 Quote Link to comment Share on other sites More sharing options...
Bramdon3000 Posted May 10, 2022 Author Share Posted May 10, 2022 Just out of curiosity could you tell me a few problems with the code? Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted May 10, 2022 Share Posted May 10, 2022 you were given a detailed list here - Quote Link to comment Share on other sites More sharing options...
Bramdon3000 Posted May 11, 2022 Author Share Posted May 11, 2022 Thanks 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.