Jump to content

I'm dealing with the error Warning: Undefined array key and a login system that won't work


Bramdon3000

Recommended Posts

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: 

 

TO1.png

TO2.png

TO3.png

TO4.png

TO5.png

TO6.png

TO7.png

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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)

 

 

woah.png

Another 1.png

b1.png

b3.png

b4.png

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

  • Great Answer 1
Link to comment
Share on other sites

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?

  • Great Answer 1
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.