I created a index.php page that was made up of three pages with the following code:
I use Ajax for login verification in main.php to show the user name in the original location after successful verification. I encountered the problem is: when the user name verification success, jump page is main.php page, how can I make her jump to index.php page, and implement login verification, and after the login verification successful, on the index.php page display user name. I am a PHP novice, seeking guidance!!!
Reply to discussion (solution)
First, when the validation is successful PS: If no session is returned main.php
Second, do not know your login verification is written on which page, write in index.php, Ajax URL write index.php on the line
Third, the login verification success after the user name is written in the session, in the index can be displayed
There is no jump in AJAX applications.
Once you jump, the page will need to be re-used for the content.
So you lose the meaning of using AJAX.
Your original jump code is how to write, change to index.php not on the line.
My login Verification page is written on the login.php page, the verification is successful after the jump, the code is as follows:
echo "
Welcome to your ". $this->username;
Header ("location:index.php");
Exit
But the contents of the index.php have come back.
If you do not need to jump, verify success, skip to the main.php page.
How do I make the validation successful and let him go to the index.php page?
My login Verification page is written on the login.php page, the verification is successful after the jump, the code is as follows:
echo "
Welcome to your ". $this->username;
Header ("location:index.php");
Exit
But the contents of the index.php have come back.
If you do not need to jump, verify success, skip to the main.php page.
Why do you want to exit?
echo "
Welcome to your ". $this->username; This sentence is not to be written in index.php?
can put $_session[username] = $this->username
Then echo in index "
Welcome to ". $_session[username";
What is the content in index to come back, there is something that can not be re-come?