gpt4 book ai didi

php - 无法更新我的 mysql 数据库

转载 作者:行者123 更新时间:2023-11-30 22:09:08 24 4
gpt4 key购买 nike

<分区>

所以我的 mysql 查询有问题。当我尝试更改“电子邮件”列时,它会遍历所有 if 语句,它只显示我已成功更改我的电子邮件,但由于某些原因它没有。请告诉我错误在哪里......可能是一些愚蠢的事情,但由于某种原因我找不到它。

代码如下:

<?php
session_start();
include 'connection/db_connect.php';
$sessionname = $_SESSION['name'];
$sql = "SELECT * FROM registered WHERE userName='$sessionname'";
$result = mysqli_query($conn, $sql);
$currentprofile = "Your profile";
$selectedprofile = "<h1>Your profile</h1>";
while($row = mysqli_fetch_array($result, MYSQL_ASSOC)){
$username = $row['userName'];
$password = $row['password'];
$email = $row['email'];
$sessionid = $row['id'];
}
$erroremail = null;
$changeEmail = $_POST['changeEmail'];
$changeEmailValue = $_POST['changeEmailValue'];
$changePassword = $_POST['changePassword'];
$changePasswordNew = $_POST['changePasswordNew'];
$changePasswordRepeat = $_POST['changePasswordRepeat'];

if(isset($changeEmail)){
if(!empty($changeEmailValue)){
$sqlemail = "SELECT email FROM registered where email='$changeEmailValue'";
$resultemail = mysqli_query($conn, $sqlemail);
if(mysqli_num_rows($resultemail) >= 1){
$erroremail = "<p style='color:red;'>This email is already in use by another user!</p>";
} else {
$sqlemailtwo = "UPDATE registered SET email='$changeEmailValue' WHERE id='$sessionid'";
mysql_query($conn, $sqlemailtwo);
$erroremail = "<p style='color:green;'>You updated ypur email successfully!</p>";
}
} else {
$erroremail = "<p style='color:red;'>You didn't enter email!</p>";
}
}

if($sessionname == null){
header ('Location: index.php'); // proverka za login
}
?>
<html>
<head>
<title><?php echo $currentprofile; ?></title>
<style>
</style>
</head>
<body>
<div>
<?php echo "Hello, ".$username; ?> | <a href='logout.php'>Logout</a>
<div style='width: 230px; height: 100%;'>

<span><?php echo $selectedprofile; ?></span>
<br>
Email:
<?php echo $erroremail; ?>
<form method='post' action='?=changeEmail'>
<input type='email' name='changeEmailValue' value='<?php echo $email; ?>'>
<input type='submit' name='changeEmail' value='Change'>
</form>
<hr>
Password:
<form method='post' action='?=changePassword'>
<input type='password' name='changePasswordCurrent' value='' placeholder='Your current password'>
<input type='password' name='changePasswordNew' value='' placeholder='New password'>
<input type='password' name='changePasswordRepeat' value='' placeholder='Repeat new password'>
<input type='submit' name='changePassword' value='Change'>
</form><br>
<hr>
Your IP adress:
<?php ?>
</div>

</body>
</html>

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