Php登录表单不起作用 [英] Php login form does not work
问题描述
我正在尝试创建用户输入其设备制造商和序列号的表单,如果它是正确的,他已登录。我还设置了一个会话变量和cookie,持续24小时。但是表单在表单上显示以下消息提交:
致命错误:未捕获错误:函数名称必须是/ Applications / XAMPP / xamppfiles / htdocs中的字符串/form/index.php:15堆栈跟踪:第15行的/Applications/XAMPP/xamppfiles/htdocs/form/index.php中抛出#0 {main}
PHP代码是:
<?php
session_start();
$ error = ;
if (array_key_exists( id,$ _SESSION)或array_key_exists( id,$ _COOKIE)){
header( welcome.php);
}
if (array_key_exists( 提交,$ _POST)){
$ link = mysqli_connect( localhost, root , root, 形式跨度>);
if (mysqli_connect_error()){
die( 数据库连接错误);
}
其他 {
$ query = SELECT制造商,序列来自`users` WHERE manufacturer =' .mysqli_real_escape_string($ link,$ _POST (' manufacturer'))。 'AND serial =' .mysqli_real_escape_string($ link,$ _POST(' serial'))。 ';
$ result = mysqli_query($ link,$ query);
$ row = mysqli_fetch_array($ result);
if(isset($ row)){
$ _SESSION [' id'] = $ row [' id'];
setcookie( id,$ row [' id'],时间+ 60 * 60 * 24);
header( 位置:welcome.php);
}
其他 {
$ error = 输入的数据无效。不是Pro会员?;
}
}
}
?>
任何想法我做错了什么或我该怎么办?
我尝试过的事情:
我在google上搜索过,也询问了stackoverflow,他们没有帮助。我是新手,所以我不知道足够的方法来修复它。
错误 = ;
if (array_key_exists( id,
_SESSION)或array_key_exists( id,
_COOKIE)){
header( welcome。 PHP跨度>);
}
if (array_key_exists( 提交跨度>,
I am trying to make form where a user enters his device manufacturer and serial number and if it is right he is logged in. I have also set a session variable and cookie which lasts for 24 hours. But the form shows following messages on form submit:
Fatal error: Uncaught Error: Function name must be a string in /Applications/XAMPP/xamppfiles/htdocs/form/index.php:15 Stack trace: #0 {main} thrown in /Applications/XAMPP/xamppfiles/htdocs/form/index.php on line 15
The PHP code is:
<?php
session_start();
$error ="";
if (array_key_exists("id", $_SESSION) OR array_key_exists("id", $_COOKIE)) {
header("welcome.php");
}
if (array_key_exists("submit", $_POST)) {
$link = mysqli_connect("localhost", "root", "root", "form");
if (mysqli_connect_error()) {
die ("Database Connection Error");
}
else {
$query = "SELECT manufacturer, serial FROM `users` WHERE manufacturer = '".mysqli_real_escape_string($link, $_POST('manufacturer'))."' AND serial = '".mysqli_real_escape_string($link, $_POST('serial'))."'";
$result = mysqli_query($link, $query);
$row = mysqli_fetch_array($result);
if(isset($row)) {
$_SESSION['id'] = $row['id'];
setcookie("id", $row['id'], time + 60*60*24);
header("Location: welcome.php");
}
else {
$error = "Invalid data entered. Not a Pro member?";
}
}
}
?>
Any ideas what I am doing wrong or what should I do?
What I have tried:
I have searched on google and also asked on stackoverflow and they didn't help. I am a newbie so I don't know enough methods to fix it.
error =""; if (array_key_exists("id",
_SESSION) OR array_key_exists("id",
_COOKIE)) { header("welcome.php"); } if (array_key_exists("submit",
这篇关于Php登录表单不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!