Jump to content

Quickie, appending a php variable into some javascript..


spenceddd

Recommended Posts

Hi,

 

I cannot work out how to append my php variable ($username) onto the following code:

 


if (($_POST['username'] == $usernameCheck) && ($_POST['password'] == $passwordCheck)){
	session_start(); 
  		session_register('username'); 
	//load simpleForm.php page using javascript
	echo ("<script>
	<!--
	location.replace(\"DevelopmentFiles/JobAdmin/JobAdmin.php\");
	-->
	</script>");
	$failureMessage="";
}

 

I am just trying to pass a username to the next page using the url (the  location replace bit) so I can retrieve using a get command on the target page. Struggling really to get the exact syntax right...

 

 

Sorry I am still a php novice!

 

Thanks for any help on this.

 

Spencer

 

if (($_POST['username'] == $usernameCheck) && ($_POST['password'] == $passwordCheck)){
  session_start(); 
  session_register('username'); 
  //load simpleForm.php page using javascript
  echo ("<script>
  <!--
    location.replace(\"DevelopmentFiles/JobAdmin/JobAdmin.php?username={$_POST['username']}\");
  -->
  </script>");
  $failureMessage="";
}

Not entirely sure why your using JavaScript to redirect, but something like that should work.

Thanks a lot for that cags.

 

The reason by the way is simply because I haven't got a clue what I'm doing (well not much anyway!).

 

Whenever I try to use the headers thing it always errors.

 

Spencer

 

That would likely be because you are sending output before redirecting. The idea sounds silly... why would you send data to the client if all you are going to do is redirect them? All you need do is organise your code so that it only sends data to the client when it is needed.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.