Jump to content

[SOLVED] the best way to echo a var on another page


supergrame

Recommended Posts

im not to good at explaining what i want but ill give it a go,

 

i have a login form called loginhtml.php and it posts to loginphp.php now if the user is in the DB it will go to members area if not it will output a wrong user name, the thing is it echo that on the loginphp.php, its just blank with wrong username and pass witch is what is meant to happen but i want that to redirect back to the login form and print it out there. i hope that makes scene, i could assign it to a global variable but im sure there is another way. i was thinking of redirecting back with header: loginhtml.php but it wont have a clue about that error, I am a newbie at this but slowly getting better.

 

phpfreaks is mean place to learn and get help:D

 

well i hope that makes scene to you all if not ill try to reexplain it

 

thank you

 

:P

Link to comment
Share on other sites

yea i no i can redirect back but the issue is the error generated via loginphp.php wont get posted to the loginhtml.php page witch is what i want. maybe im just not thinking outside of the squre this php stuff really messes up my brain i guess in time it will be easier to follow and a lot less of a headache, but so far PHP is awesome im getting so addicted

Link to comment
Share on other sites

I recommend you do not use javascript for this at all.

You should use a redirect when the user input is correct otherwise it should redirect to the form it self

 

<?php
//you should catch if the login was correct somehow if the login was correct then redirect
if(validlogin){
  header("Location: your_secured_page.php");
  exit();
}
?>
<form action="thisformname.php" method="post">
  <input type="text" name="username" value="<?php echo(isset($_POST['username']))?$_POST['username']:"";?>"/>
  <input type="password" name="password" />
</form>

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.