douan6815 2019-03-23 14:48
浏览 122

如何让php登录页面真正起作用?

I am having some trouble making my php login page, you know, actually login. I have created a database using sql with some login info and I am trying to display the information grabbed once the user logs in.

For example once the user logs in I want it to say: "Welcome back [firstname][lastname] Our records show that your email address is: [email] and you last accessed our system: [date accessed]"

and if the user was not found in the database i want it to say "Login failed please try again"

So how to I get the code to actually login(it supposed to be self referring too...)

I have tried so many things, I have tried:

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if(isset($_POST['submit'])){
        $id = $_POST['id'];
$password = $_POST['password'];

$res = pg_query($cser,"select* from users where id='$id'and password='$password'");
$result=pg_fetch_array($res);
if($result)
{
    echo "You are login Successfully ";
    header("location:functions.php");   

}
else
{
    echo "failed ";
}
    }
}

Ive been watching youtube videos as well but none of them are helpful at all.

<center>
<h2>Please log in</h2>
<p>Enter your login ID and password to connect to this system<br/>
</p>
<form name="Input" method="post" action="<?php echo $_SERVER["PHP_SELF"];?>">
<table border="1" bgcolor="black" cellpadding="10" >
<tr>
<td><strong>Username:</strong></td>
<td><input type="text" name="login" value="" size="20" placeholder="Username"/></td>
</tr>
<tr>
<td><strong>Password:</strong></td>
<td><input type="password" name="pass" value="" size="20" placeholder="**********" /></td>
</tr>
</table>
<table border="0" cellspacing="15" >
<tr>
<td><input type="submit" value = "Login" /></td>
</tr>
</table>
</form>
<p>
Please wait after pressing <strong>Log in</strong>
while we retrieve your records from our database.<br/>
<em>(This may take a few moments)</em>
</p>
<hr/>
</center>
</body>
</html>

This is my actual form

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
    • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
    • ¥16 mybatis的代理对象无法通过@Autowired装填
    • ¥15 可见光定位matlab仿真
    • ¥15 arduino 四自由度机械臂
    • ¥15 wordpress 产品图片 GIF 没法显示
    • ¥15 求三国群英传pl国战时间的修改方法
    • ¥15 matlab代码代写,需写出详细代码,代价私
    • ¥15 ROS系统搭建请教(跨境电商用途)
    • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。