Jump to content

Recommended Posts

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

 

Link to comment
https://forums.phpfreaks.com/topic/149925-echo-in-a-new-page-please-help/
Share on other sites

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,

<?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.

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.

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.