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

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

yea but thanks tho,

 

You would think there would just be an easy way, maybe i should just have the php at the top of my html but then again that's not really the right way to set up your file structure, well for me anyway.

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>

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.