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

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.