[英]php set username and password
I've been trying to set up a login system, but can't set my username and password. 我一直在尝试设置登录系统,但是无法设置用户名和密码。
<?php
session_start();
$user = “u1”;
$password = “p1”;
if ($_POST[‘username’] == $user ) &&
($_POST[‘password’] == $password) {
echo welcome.php;
}
else echo you have entered the wrong credentials.
?>
This is only for illustrative purposes and to answer this question, but understand this is not a secure system and should not be used ANYWHERE EVER near a production environment! 这仅仅是用于说明目的,回答这个问题,但明白这不是一个安全的系统,不应该在任何地方使用过附近的生产环境!
I think it might be an issue with how you've set up your if
and else
statements, as well as you having a syntax error with the echo
statement. 我认为这可能与您如何设置
if
和else
语句以及echo
语句存在语法错误有关。 Try something like this: 尝试这样的事情:
<?php
session_start();
$user = 'u1';
$password = 'p1';
if ($_POST['username'] == $user && $_POST['password'] == $password) {
echo 'successfully logged in'; // changed to just show successful message
} else {
echo 'you have entered the wrong credentials.'; // Placed quotes around echo statement
}
?>
It seems to be quotation and bracket problem. 看来是引号和括号问题。 This should hopefully work for you:
希望这对您有用:
<?php
session_start();
$user = "u1";
$password = "p1";
if (($_POST['username'] == $user ) && ($_POST['password'] == $password)) {
echo welcome.php;
}
else echo "you have entered the wrong credentials".
?>
Replace 更换
if ($_POST[‘username’] == $user ) && ($_POST[‘password’] == $password) {
with 同
if (($_POST[‘username’] == $user ) && ($_POST[‘password’] == $password)) {
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.