嗨,这是我在这里的第一篇文章,我迫切需要帮助。我正在为基于会员的旅游和度假公司开发一个网站,在用户成功登录后重定向到 search-flights.php,我想使用登录详细信息在 my-account.php 中显示用户详细信息以检索特定的mysql行。我该怎么做呢?我对此进行了很长时间的研究,但没有找到任何与我需要做的事情相近的解决方案这是我的一些代码,请记住,我对 php 和 mysql 还很陌生
<form method="POST" id="login-form" action="./Scripts/checklogin.php">
<fieldset class="userdata">
<p id="form-login-username">
<label for="modlgn-username">User Name</label>
<input id="modlgn-username" name="myusername" class="inputbox" size="18" type="text">
<p id="form-login-password">
<label for="modlgn-passwd">Password</label>
<input id="modlgn-passwd" name="mypassword" class="inputbox" size="18" type="password">
</p>
<p id="form-login-remember">
<label for="modlgn-remember">Remember Me</label>
<input id="modlgn-remember" name="remember" class="inputbox" value="yes" type="checkbox">
</p>
<input type="image" class="move" value="Login" src="images/Login.png" alt="Log in Button" title="Log in" />
<input name="option" value="com_users" type="hidden">
<input name="task" value="user.login" type="hidden">
<input name="return" value="aW5kZXgucGhwP0l0ZW1pZD00MzU=" type="hidden">
<input name="e4b8befc8354bc2ee27d826c9dcc850f" value="1" type="hidden"> </fieldset>
</form>
<?php
// check-login.php
$host="localhost"; // Host name
$username="********"; // Mysql username
$password="********"; // Mysql password
$db_name="choliday_members"; // Database name
$tbl_name="members"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// username and password sent from form
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword");
header("location:../members/search-flights.php");
}
else {
echo "Wrong Username or Password";
}
?>