sicklermd Posted October 1, 2018 Share Posted October 1, 2018 i have a couple test functions that i set up to make this easier to explain. function setmsg() does just that, sets a message in a session variable. fuction viewmsg() is called on the redirected page and displays the message and then unsets the variable. the message shows up just fine, but when i view the source of the page, the html is not there. make sense? function setmsg(){ //set message to user to display $_SESSION['type'] = "noError"; $_SESSION['userMsg'] = "client status changed"; redirect("second.php"); exit; } function viewmsg() { echo '<div id="'.$_SESSION['type'].'">'.$_SESSION['userMsg'].'</div>'; unset($_SESSION['userMsg']); } view the source of the "second.php" page and this is what i get..... <div id="noError"></div> the mesage "Client status was changed" clearly displays just fine. is this normal? Link to comment Share on other sites More sharing options...
benanamen Posted October 1, 2018 Share Posted October 1, 2018 Problem is single quotes vs double quotes. $_SESSION['type'] is echo'd with single quotes and therefore will not interpolate the variable. Link to comment Share on other sites More sharing options...
requinix Posted October 1, 2018 Share Posted October 1, 2018 1 minute ago, benanamen said: problem is single quotes vs double quotes. Nope. Try again. Link to comment Share on other sites More sharing options...
benanamen Posted October 1, 2018 Share Posted October 1, 2018 I think I misread the post. The redirect is obviously not right, but what html is not showing up? You mean your not seeing the usrMsg in the source? You have already unset the variable so it's not going to be in the source. Link to comment Share on other sites More sharing options...
requinix Posted October 1, 2018 Share Posted October 1, 2018 The stuff inside the <div> from the "userMsg". The "type" is still working fine. Link to comment Share on other sites More sharing options...
benanamen Posted October 1, 2018 Share Posted October 1, 2018 Yeah, I finally figured out what the op was trying to say. Post was not worded very well. I edited my post as you were posting. Link to comment Share on other sites More sharing options...
requinix Posted October 1, 2018 Share Posted October 1, 2018 I fixed the highlighting so it should look better. Should show that there's no interpolation happening. Link to comment Share on other sites More sharing options...
sicklermd Posted October 1, 2018 Author Share Posted October 1, 2018 i'm not sure i understand, change my single quotes to double? if i unset the $_session['type'] after echoing it, it has the same issue. it will be visible on the screen, but gone when you view source. also the redirect is another function, sorry i didn't say that. Link to comment Share on other sites More sharing options...
requinix Posted October 1, 2018 Share Posted October 1, 2018 When you're pulling up the source for the page, the browser is requesting the page a second time. It's not showing you the original source that it was presenting. If you just want to browse the markup and don't mind seeing the current state of the DOM (as opposed to the original markup that the server returned) then use your browser's Inspect feature, whatever it may be called. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.