supergrame Posted March 18, 2009 Share Posted March 18, 2009 im not really sure how to explane this so ill just post what i have so far here is the function i am using <?php function verifylogin() { $username=$_POST['username']; $password=$_POST['password']; $username = stripslashes($username); $password = stripslashes($password); $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); $sql="SELECT * FROM users WHERE username='$username' and password='$password'"; $result=mysql_query($sql); $count=mysql_num_rows($result); if($count==1){ session_register("username"); session_register("password"); header("location:../members/members.php"); } else { echo "Wrong Username or Password"; } } ?> it has there echo wrong user pass.. what i want to do is move that to the loginhtml.php here it is! <html> <head> </head> <body> <div id="login"> [color=pink]THIS IS WERE I WANT IT TO BE OUT PUT[/color] <form method="post" action="login/loginphp.php"> <table> <tr> <td><label for="username">Username:</label></td> <td><input type="text" name="username"/></td> </tr> <tr> <td><label for="password">Password:</label></td> <td><input type="password" name="password"/></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" id="submit" value="Login" name="submit" /></td> </tr> </table> </form> </div> </body> </html> oh and here is loginphp.php <?php require_once("../mysql/db_connect.php"); require_once("../includes/functions.php"); verifylogin(); ?> i was thinking put wrong username text into a var $var = "Wrong username or password"; then in the loginhtml.php have something like if (!isset($var)); echo $var; something like that anyway. but the problem is i cant seem to get my head around how to carry that variable back to the loginhtml.php to be displayed above the login form, like a permanent variable maybe superglobal Quote Link to comment https://forums.phpfreaks.com/topic/149925-echo-in-a-new-page-please-help/ Share on other sites More sharing options...
9three Posted March 18, 2009 Share Posted March 18, 2009 what? what is your question? Quote Link to comment https://forums.phpfreaks.com/topic/149925-echo-in-a-new-page-please-help/#findComment-787392 Share on other sites More sharing options...
imperium2335 Posted March 18, 2009 Share Posted March 18, 2009 on both pages put session_start() ; and $_SESSION['variableyouwantpassedbetween'] ; Is that what you mean? im a noob to so might be wrong. Quote Link to comment https://forums.phpfreaks.com/topic/149925-echo-in-a-new-page-please-help/#findComment-787394 Share on other sites More sharing options...
supergrame Posted March 18, 2009 Author Share Posted March 18, 2009 all i want to do is if the password and username does not match the database it will echo "wrong username or password but it will eco that at the top of the login table on page loginhtml.php i hope that makes a little more scenes so really i will put the echo "Wrongpassword and username"; into a $var and then keep that value so it can be outputed on the login form above the table. sorry about my explanation, Quote Link to comment https://forums.phpfreaks.com/topic/149925-echo-in-a-new-page-please-help/#findComment-787422 Share on other sites More sharing options...
tracivia Posted March 18, 2009 Share Posted March 18, 2009 <?php print $_SESSION['warning']; ?> Session variables are global too. You can define a session variable in any of your prehistoric scripts and use everywhere. You have to put session_start(); before the headers (php session is etc) are sent. This is the safe method. Quote Link to comment https://forums.phpfreaks.com/topic/149925-echo-in-a-new-page-please-help/#findComment-787431 Share on other sites More sharing options...
imperium2335 Posted March 18, 2009 Share Posted March 18, 2009 put this on your loginhtml.php youd do it with an if statment: if($enteredpassword != $dbpassword || $entereduser != $dbuser) { echo "$thesessionvarmessage" ; } Thats off top of my head, may be wrong Quote Link to comment https://forums.phpfreaks.com/topic/149925-echo-in-a-new-page-please-help/#findComment-787471 Share on other sites More sharing options...
rameshfaj Posted March 18, 2009 Share Posted March 18, 2009 First of all define the login form within html tables, allocationg one row for the error message that you want to display. On the data processing/comparing page, set some variable and redirect to the login page using header() method. On the login page compare the value of the variable you set in the data processing page.If its value is set then display the error message(can simply use the echo) else not. Ex: login.php <html> ... ... ..//define table here whose one row has $error_invalidUser=" "; //call function showErrorMsg() echo($error_invalidUser); .. .. function showErrorMsg(){ if($_GET('errorset')!="") $error_invalidUser="Invalid UserName or Password"; } </html> /////////data processing page .. .. .. if(rowcount<1){ $errorset="true" } else $errorset=""; I think this logic may help you. Quote Link to comment https://forums.phpfreaks.com/topic/149925-echo-in-a-new-page-please-help/#findComment-787480 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.