My php code doesn’t let him log in, (I think it’s because of the $_POST method)

Asked

Viewed 24 times

-2

Good evening, I’m making a code in php to confirm if the user exists in the database to enter another page Home, for that I remove the data by the $_POST method from the form, but from what I saw the POST did not work, so I tried in other ways but remains without effect, I’ll let it down like it was.

Login.php inserir a descrição da imagem aqui Index.php inserir a descrição da imagem aqui

db.php inserir a descrição da imagem aqui

In short, whenever I log in with the data in the database, it returns me to the index, someone can help me?

  • Do not post codes as image, the platform supports codes directly in question.

1 answer

0

Opa, by the looks of it, in your file 'Login.php' in line 8, vc is doing a validation isset($_POST['submit']), and this condition will always be true, because your form will always send this field with the name=value you assigned.

So the code is seeing that there is this value in the array $_POST and entering the if, forwarding access to your index.php, as defined =)

This condition does not make much sense, I believe it is to check if there is the method post on the page, so the correct for this would be if( !isset($_POST['sumbmit'] ), then forward back to index.

I hope I’ve helped!!

  • I do not know very well php, I work more with C#, but I was asked to do it in WEB format, and as I do not know well php I’m having some doubts, but I changed what referred and continues forwarding to index.php, I tried to continue the rest in order to see if I could get some help on that part, but on the part of the record it works excellently, but when trying to add data through separate fields it doesn’t work either. I will leave down my email and if you can help me more I would appreciate it because the time is short for what I need, would be very grateful

  • I forgot to send email [email protected]

Browser other questions tagged

You are not signed in. Login or sign up in order to post.