gpt4 book ai didi

PHP/MySQL : User Sign Up Page

转载 作者:行者123 更新时间:2023-11-29 05:11:53 25 4
gpt4 key购买 nike

最近我一直在创建一个 PHP/MySQL 用户注册页面,但我遇到了一个问题,当我调用该函数时它一直出错,它返回给我:

"Fatal error: Call to undefined function signUp() in /Users/Ronald/Desktop/PHP/Brighten/admin/signup-method.php on line 65"

我想知道为什么会这样。我敢肯定这个问题一定已经在某个地方得到了回答,但我不太擅长搜索它,所以感谢你的关注并提前致谢

错误信息: enter image description here

它应该是什么样子: enter image description here

<?php 
$dbhost = 'database_host';
$dbuser = 'database_user';
$dbpass = 'database_password';
$conn = mysqli_connect($dbhost, $dbuser, $dbpass, $dbuser);
if (!$conn){
die('cannot connect to mysql');
}


if(isset($_POST['username'])){
$username = $_POST['username'];
}
if(isset($_POST['password'])){
$password = $_POST['password'];
}
if(isset($_POST['cpassword'])){
$cpassword = $_POST['cpassword'];
}
if(isset($_POST['email'])){
$email = $_POST['email'];
}


function addUser(){
$query = "INSERT INTO websiteusers (user,password,email) VALUES ('$username','$password','$email')";
$data = mysql_query ($query)or die(mysql_error());
if($data) {
$result = '<div class="alert alert-success">Thank you, <strong>'.$_POST['name'].'</strong>! You are successfully registered</div>';
}

function signUp(){
$query = "SELECT * FROM users WHERE user = '$username' AND pass = '$password'";

$result = mysqli_query($conn, $query);
if(!$row = mysqli_fetch_array($result)){
addUser();
}else{
die(" <div class='alert alert-warning'>
<strong>Warning!</strong> You're already an registered user!
</div>");
}
}
}




if ($_POST["submit"]) {
if (!$_POST['username']) {
$error="<br />Please enter your name";
}
if (!$_POST['password']) {
$error.="<br />Please enter your password";
}
if (!$_POST['email']) {
$error.="<br />Please enter your email";
}
if ($password != $cpassword){
$error.= "<br/> Please confirm password is the same";
}
if ($error) {
$result='<div class="alert alert-danger"> There were error(s)in your form: '.$error.'</div>';
}
signUp();
}


?>

最佳答案

您在添加用户功能中犯了一个错误。两个 { 已打开,但只有一个 } 已关闭。这就是 signUp 未定义的原因,因为它现在是 adduser 函数的一部分。

关于PHP/MySQL : User Sign Up Page,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38299754/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com