Need some help with PHP

Asked By 0 points N/A Posted on -
qa-featured

please read the code below,

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

my requirement is display  user name and password in the top of  “login.php” , can someone please provide PHP code

SHARE
Answered By 0 points N/A #93995

Need some help with PHP

qa-featured

For this case you got to make a login page as where the action is going to take place login.php and put the following code inside that page and link the database as required .(Remember this is a standard code and if you are a php programmer then you must atleast know the basics.)

<?php

$name=$_POST['name'];
$password=$_POST['password'];
$sql="SELECT * FROM user_info WHERE user_name='$name'and password='$password'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1)
{
    header("location:newpost.php");

}
else{
    echo "Wrong Username or Password";
}

?>

 

and you need to change the header with your desired page.php so that you can get the username..

 

Hope this helps

P.S. If you get any problem then free to ask

Login/Register to Answer

Related Questions