1
mysqlクエリに問題があります。 「電子メール」列を変更しようとすると、すべてのif文が表示され、電子メールが正常に変更されたことが示されますが、何らかの理由でそれが表示されません。間違いがどこにあるのか教えてください...おそらくそれは愚かなものですが、何らかの理由でそれを見つけることができません。ここmysqlデータベースを更新できません
はコーディングです:
<?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)){
\t $username = $row['userName'];
\t $password = $row['password'];
\t $email = $row['email'];
\t $sessionid = $row['id'];
}
$erroremail = null;
$changeEmail = $_POST['changeEmail'];
$changeEmailValue = $_POST['changeEmailValue'];
$changePassword = $_POST['changePassword'];
$changePasswordNew = $_POST['changePasswordNew'];
$changePasswordRepeat = $_POST['changePasswordRepeat'];
if(isset($changeEmail)){
\t if(!empty($changeEmailValue)){
\t \t $sqlemail = "SELECT email FROM registered where email='$changeEmailValue'";
\t \t $resultemail = mysqli_query($conn, $sqlemail);
\t \t if(mysqli_num_rows($resultemail) >= 1){
\t \t \t $erroremail = "<p style='color:red;'>This email is already in use by another user!</p>";
\t \t } else {
\t \t \t $sqlemailtwo = "UPDATE registered SET email='$changeEmailValue' WHERE id='$sessionid'";
\t \t \t mysql_query($conn, $sqlemailtwo);
\t \t \t $erroremail = "<p style='color:green;'>You updated ypur email successfully!</p>";
\t \t }
\t } else {
\t \t $erroremail = "<p style='color:red;'>You didn't enter email!</p>";
\t }
}
if($sessionname == null){
\t header ('Location: index.php'); // proverka za login
}
?>
<html>
<head>
\t <title><?php echo $currentprofile; ?></title>
\t <style>
\t </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>
\t Email:
\t <?php echo $erroremail; ?>
\t <form method='post' action='?=changeEmail'>
\t \t <input type='email' name='changeEmailValue' value='<?php echo $email; ?>'>
\t \t <input type='submit' name='changeEmail' value='Change'>
\t </form>
<hr>
\t Password:
\t <form method='post' action='?=changePassword'>
\t \t <input type='password' name='changePasswordCurrent' value='' placeholder='Your current password'>
\t \t <input type='password' name='changePasswordNew' value='' placeholder='New password'>
\t \t <input type='password' name='changePasswordRepeat' value='' placeholder='Repeat new password'>
\t \t <input type='submit' name='changePassword' value='Change'>
\t </form><br>
<hr>
\t Your IP adress:
\t <?php ?>
</div>
</body>
</html>
それだけでなく、 'MYSQL_ASSOC'でもあります。 –