Jump to content

Log in with mysql


xxreenaxx1

Recommended Posts

I was woking on these two codes belwo, when I try to enter the username and the password. It just shows me the same page again.

 

<?php

$username =$_POST['username'];
$password =$_POST['password'];
$login1 =$_GET['login1'];

setcookie("username","$username",time()+86400);

if($login=='yes'){
$con = mysql_connect("localhost","root","");

mysql_select_db("login");

$get = mysql_query("SELECT count(id) FROM login WHERE user='$username'
and pass='$password'");

$result = mysql_result($get, 0);

if($resut!=1){
echo "Invalid login";
}
else {
echo "Login Successful, Welcome back".$_COOKIE['username']."sir/madam";
$_SESSION['username']=$username;
}
}

 

 

 

<html>
<body>

<form action"login1.php?login=yes" method="POST">
Username:<input type="text" name="username" />
<br/>
<br/>
Password:<input type="password" name ="password"/>
<br />
<input type="submit" value="Submit" />

</form>

</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/194676-log-in-with-mysql/
Share on other sites

Yes, I did

 

<html>
<body>

<form action="login.php" method="POST">
Username:<input type="text" name="username" />
<br/>
<br/>
Password:<input type="password" name ="password"/>
<br />
<input type="submit" value="Submit" />

</form>

</body>
</html>

 

Why are you checking if login == 1 on login.php? There's no need for that. Take that out.

Link to comment
https://forums.phpfreaks.com/topic/194676-log-in-with-mysql/#findComment-1023832
Share on other sites

Do you mean login ==yes..

 

well, I have taken that out.. It keeps telling me Invalid login

 

<html>
<body>

<form action="login.php" method="POST">
Username:<input type="text" name="username" />
<br/>
<br/>
Password:<input type="password" name ="password"/>
<br />
<input type="submit" value="Submit" />

</form>

</body>
</html>

 

 

<?php

$username =$_POST['username'];
$password =$_POST['password'];
$login =$_GET['login'];

setcookie("username","$username",time()+86400);


$con = mysql_connect("localhost","root","");

mysql_select_db("login");

$get = mysql_query("SELECT count(id) FROM login WHERE user='$username'
and pass='$password'");

$result = mysql_result($get, 0);

if($resut!=1){
echo "Invalid login";
}
else {
echo "Login Successful, Welcome back".$_COOKIE['username']."sir/madam";
$_SESSION['username']=$username;
}



?>

 

 

these are my updated codes

Link to comment
https://forums.phpfreaks.com/topic/194676-log-in-with-mysql/#findComment-1023844
Share on other sites

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.