开发者

How To Retrieve password From HTML Form and Then Print It

Well, I am working on a new project which has a login page. The Error: I am unable to retrieve password from the form using $_POST method. The Form Code:

<form action="loginsub.php" method="post">
<input type="password" name="pass" id="pass"/><br/>
<input type="submit" value="Go!"/>
</form>

The Code in loginsub.php

<? echo $_POST['pass']; ?>

I have als开发者_开发技巧o tried this method using text in place of password and it works. But what is the problem with the password? When I fill in the form and then submit it, the next page displays nothing!

Okay, Now, It's working! Thank you all, The Real Problem was: I want to take in password from a login form and then using mysql_query (php) want to find out if the username and password combination is there or not. If I am not wrong, the code for it is:

require_once('dbconfig.php');
$username = $_POST['username'];
$pass = $_POST['pass'];
$dbc = mysql_connect($dbserver,$dbuser,$dbpassword);
mysql_select_db('hello');
$query = "SELECT * FROM users WHERE username = '$username' AND password = PASSWORD('$pass')";
$result = mysql_query($query);
$row = mysql_num_rows($result);
if ($row == 1)
{ echo "User Name and Password are Correct"; }
else
{ echo "Error! Username and Password is Wrong!"; }

Is the code right? When I execute it, enter correct username and password (which exists in the database, I get the InCorrect Message, but again when I enter wrong username and password, I still get InCorrect message. Why?


I take you don't really want to print the password in your application? Anyway, it should be in your $_POST array - could you paste the output of putting

var_dump( $_POST );

in the page your submitting to?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜