There is a blog. the php page already contains the cookie page. After submitting and logging in, I want $ _ COOKIE [& #039; username & #039;] to output this user name to the blog. what should I do with the location specified by php, such as a div? Should this div be written on the cookie page? Or other methods...
A blog. php page already contains a cookie page.
After submitting the login request, I want $ _ COOKIE ['username'] to output the user name to the specified position of blog. php, such as a p. How can this problem be solved? Should p be written on the cookie page? Or other methods?
In this way, I directly output data outside p.
This is the cookie page
This is the logon page
Prepare ("select id, username, password from user where username =? And password =? "); $ Stmt-> execute (array ($ _ POST ['username'], ($ _ POST ['Password']); if ($ stmt-> rowCount ()> 0) {list ($ id, $ username) = $ stmt-> fetch (PDO: FETCH_NUM); $ time = time () + 24*60*60; setCookie ("uid", $ id, $ time, "/"); setCookie ("username", $ username, $ time, "/"); setCookie ("isLogin", 1, $ time, "/"); echo 'script location = "blog. php "script" ';} else {echo "Logon Failed" ;}}?>
Reply content:
A blog. php page already contains a cookie page.
After submitting the login request, I want $ _ COOKIE ['username'] to output the user name to the specified position of blog. php, such as a p. How can this problem be solved? Should p be written on the cookie page? Or other methods?
In this way, I directly output data outside p.
This is the cookie page
This is the logon page
Prepare ("select id, username, password from user where username =? And password =? "); $ Stmt-> execute (array ($ _ POST ['username'], ($ _ POST ['Password']); if ($ stmt-> rowCount ()> 0) {list ($ id, $ username) = $ stmt-> fetch (PDO: FETCH_NUM); $ time = time () + 24*60*60; setCookie ("uid", $ id, $ time, "/"); setCookie ("username", $ username, $ time, "/"); setCookie ("isLogin", 1, $ time, "/"); echo 'script location = "blog. php "script" ';} else {echo "Logon Failed" ;}}?>
You can define an array, such as $ tplData, and set various values to be displayed in the html section in your code, for example, if you have a cookie, let $ tplData ['user'] = $ _ COOKIE ['user'] And then directly echo $ tplData ['At the position you want to output in the html section below you [' user '] so that it can be displayed? After a while, you can understand what the template engine is.
You write the php file echo in the p file you want to display.