Skip to content
Advertisement

Pass data from PHP to HTML

Edit: Thank you for your help and time. I will change all my extension to .php as recommended and check the link that was shared :)!

I’m a beginner at coding and I have been stuck for a few days on a problem. So, I have coded a html page with a login form. Once the user click the button login, the username and password will be checked in a php file and then if it’s correct, the user will be redirected to the successfully login html page. I get redirected to the success login html page but I just can’t pass the user data, I have tried to add a .htaccess so I can try to echo the session username but it doesn’t display the username.

How do I pass the data of the user session to the new html page? I have been looking on forum and online but didn’t really find an answer. If you guys have advices or suggestions, it would be helpful as I’m a beginner. Thanks for your answers and help!

Here is the php part of what should happen if the user successfully login:

check.php

The successfullogin.html code:

Advertisement

Answer

You can’t run PHP in .html files cause the server don’t recognize that extension as a valid one. To tell your server to understand html files as valid check this topic below

How do I add PHP code/file to HTML(.html) files?

Or change your successfullogin.html to successfullogin.php

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement