Jump to content

Recommended Posts

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?

Edited by requinix
fixed highlighting
Link to comment
https://forums.phpfreaks.com/topic/307744-php-session-variable-html-not-rendering/
Share on other sites

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.

Edited by benanamen

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.   

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.