嘿,伙计们,所以我有这个错误,这个特定的代码只,这是错误。除了doEditAccount.php,我所有其他的网站代码都可以工作,这给了我这个错误。
服务器遇到内部错误或配置错误,无法完成您的请求。
此错误的根本原因取决于处理该错误的是哪一个模块以及出现此错误时工作进程中出现了何种情况。
有关此错误的详细信息,请参阅服务器错误日志。
Apache/2.4.54(Win 64)OpenSSL/1.1.1p PHP/8.2.0服务器at localhost Port 80
下面是我的代码:Account.php:
//User can choose to edit or delete their account here
session_start();
include_once("linkConnection.php");
include_once("navbar.php");
include_once("session.php");
if(isset($_SESSION['userId'])){
$userId=$_SESSION['userId'];
$query="SELECT * FROM users WHERE userId = $userId";
$Result=mysqli_fetch_assoc(mysqli_query($link,$query));
echo " <br><b>Username</b> : ".$_SESSION['username'];
echo "<br><b>Password</b> : ".$Result['password'];
echo "<br><b>Name</b> : ".$Result['name'];
echo "<br><b>Date of Birth</b> : " .$Result['dob'];
echo "<br><b>Email</b> : " .$Result['email'];
?>
<form action="editAccount.php" method="post">
<input type="submit" value="Edit Account" name="edit1"/>
</form>
<br>
<form action="deleteAccount.php" method="post">
<input type="submit" value="Delete Account"/>
</form>
<br><br>
<?php
}
else{
echo "Please Login to View Account Information.";
}
?>
<html>
<head>
</head>
<body>
<h3>Account Customization</h3>
<?php
$Points_needed=100-$Result['points'];
?>
<p>Current Level : <?php echo $Result['level']?> (You need <?php echo $Points_needed?> more points to level up!)</p>
<div class="w3-light-grey">
<div id="myBar" class="w3-container w3-green w3-center" style="width:<?php echo $Result['points']?>%"><?php echo $Result['points']?></div>
</div>
<?php if (isset($_SESSION['userId'])){?>
<form action="doEditAccount.php" method="post">
<br/><br/>
<div class="level-container">
<label>Level 1 :</label>
<br>
<br>
<input type="radio" name="color" value="lightgrey" />Light Grey
<input type="radio" name="color" value="lightyellow"/>Light Yellow
<input type="radio" name="color" value="beige"/>Beige
<input type="radio" name="color" value="lightpink"/>Light Pink
<input type="radio" name="color" value="darkseagreen"/>Dark Sea Green
<input type="radio" name="color" value="lightblue"/>Light Blue
</div>
<?php
?>
<?php
if ($Result['level']>=5){ ?>
<div class="level-container">
<label>Level 5 :</label>
<br>
<br>
<input type="radio" name="lv5BG" value="background.jpg" />Mystical Background
<input type="radio" name="lv5BG" value="hellokitty.jpg" />Hello Kitty Background
<input type="radio" name="lv5BG" value="yellow.jpg" />Flowery Background
</div>
<?php
}else{
?>
<div class="level-container">
<label>Level 5 :</label>
<br>
<br>
<input type="radio" name="lv5BG" value="background.jpg" disabled/>Mystical Background
<input type="radio" name="lv5BG" value="hellokitty.jpg" disabled/>Hello Kitty Background
<input type="radio" name="lv5BG" value="yellow.jpg" disabled/>Flowery Background
</div>
<?php
}
if ($Result['level']>=10){?>
<div class="level-container">
<label>Level 10 :</label>
<br><br>
<input type="radio" name="lv10BG" value="lv10 - movable rainbow.gif" />Movable rainbow gif
<input type="radio" name="lv10BG" value="lv10 - lightbugs.gif" />Mystical Movable Firebugs
</div>
<?php
}else{?>
<div class="level-container">
<label>Level 10 :</label>
<br><br>
<input type="radio" name="lv10BG" value="lv10 - movable rainbow.gif" disabled/>Movable rainbow gif
<input type="radio" name="lv10BG" value="lv10 - lightbugs.gif" disabled/>Mystical Movable Firebugs
</div>
<?php
}
?>
<input type="submit" value="Confirm Change" name="edit2"/>
</form>
<?php
}
?>
</body>
</html>
字符串
php表单输入转到doEditAccount.php,下面是代码。
error_reporting(E_ALL);
ini_set('display_errors', '1');
include_once("linkConnection.php");
include_once("navbar.php");
include_once("session.php");
if(isset($_POST['edit1'])){
}else{
}
// $_SESSION['Cmsg'] = Customization Message
if (isset($_POST['edit2'])) {
if (isset($_POST['color'])) {
$plaincolor = $_POST['color'];
setcookie("lv5BG", "", time() - 3600); // Remove lv5BG cookie if it exists
setcookie("lv10BG", "", time() - 3600); // Remove lv10BG cookie if it exists
setcookie("plaincolor", $plaincolor, time() + 60 * 60 * 24 * 365 * 10);
$_SESSION['Cmsg'] = "You have successfully changed background to $plaincolor.";
} elseif (isset($_POST['lv5BG'])) {
$lv5BG = $_POST['lv5BG'];
setcookie("plaincolor", "", time() - 3600); // Remove plaincolor cookie if it exists
setcookie("lv10BG", "", time() - 3600); // Remove lv10BG cookie if it exists
setcookie("lv5BG", $lv5BG, time() + 60 * 60 * 24 * 365 * 10);
$_SESSION['Cmsg'] = "You have successfully changed background to $lv5BG.";
} elseif (isset($_POST['lv10BG'])) {
$lv10BG = $_POST['lv10BG'];
setcookie("plaincolor", "", time() - 3600); // Remove plaincolor cookie if it exists
setcookie("lv5BG", "", time() - 3600); // Remove lv5BG cookie if it exists
setcookie("lv10BG", $lv10BG, time() + 60 * 60 * 24 * 365 * 10);
$_SESSION['msg'] = "You have successfully changed background to $lv10BG.";
} else {
$_SESSION['Cmsg'] = "You have submitted nothing. No change to customizations.";
}
header('Location : Login.php');
}
?>
型
Login.php:
<?php
session_start();
include_once("navbar.php");
include_once("session.php");
$backgroundStyle = "";
if (isset($_COOKIE['plaincolor'])) {
$backgroundStyle = "background-color: " . $_COOKIE['plaincolor'] . ";";
} elseif (isset($_COOKIE['lv5BG'])) {
$backgroundStyle = "background-image: url(images/".$_COOKIE['lv5BG'].")";
}elseif (isset($_COOKIE['lv10BG'])) {
$backgroundStyle = "background-image: url(images/".$_COOKIE['lv10BG'].")";
echo $_COOKIE['lv10BG'];
}
echo $backgroundStyle;
?>
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body style="<?php echo $backgroundStyle?>; background-size: cover; background-repeat: no-repeat;">
<!--
form
-->
<?php
if (isset($_SESSION['msg'])){
?>
<div class="alert alert-success">
<h5><?php echo $_SESSION['msg'];?></h5>
</div>
<?php
}
unset($_SESSION['msg']);
?>
<form name="Login" method="post" action="doLogin.php" class="ReviewEdit">
<h1>Login Page :</h1>
<?php if(isset($_COOKIE['username'])){?>
Your Username: <br>
<input style="border:2px solid black;" id="idName" type="text" name="Uname" placeholder="Enter your username" value="<?php echo $_COOKIE['username']?>"/>
<br><br>
<?php
}else{?>
Your Username: <br>
<input style="border:2px solid black;" id="idName" type="text" name="Uname" placeholder="Enter your username" />
<?php
}
?>
Your Password: <br>
<input style="border:2px solid black;" id="idEmail" type="password" name="pw" placeholder="Enter your password"/>
<br><br>
<input type="checkbox" value="Remember me" name="Remember">Remember Me
<a href="forget-password.php">Forget Password</a>
<input type="submit" value="Login">
<br><br>
</form>
<h5 class="notImportant forlogin"> Not a member yet? Register <a href="Register.php" style="color: darkslategray">here</a> </h5>
</body>
</html>
型
然后我重定向到Login.php,让用户看到他们更新的背景.问题是当我点击“确认更改”按钮,它给我tnhat错误如前所述在网站doEditAccount.php,除此之外我的其他网站都工作.你知道是什么问题吗?
我认为这是重定向的问题,所以我试图删除标题(“Location:Login.php”),但同样的问题仍然存在。这个网站以前工作,突然当我试图再次运行它,它只是有这个错误,不会让步
1条答案
按热度按时间lhcgjxsq1#
尝试删除
header('Location : Login.php');
到header('Location: Login.php');
中Location后面的空格,并在函数头下添加exit,以防止在发送重定向头后执行任何进一步的代码,这被认为是使用header()进行重定向时的良好实践像这样:
字符串