何らかの理由で、これはデータベースを更新しません。データベース ログインの値は正しく、すべてのページで同じ inc ファイルを使用します。エラーはありません。データベースに更新がありません。私の人生でそれを理解することはできないようです。
<?
include("../../inc/config.inc.php");
session_start();
$loggeduser = $_SESSION['myusername'];
if(!session_is_registered(myusername)){
header("location:login/login.php");
}
?>
<?
$userpost = $_POST["username"];
if(is_null($userpost)) {
mysql_connect("$host", "$user", "$pwd") or die(mysql_error());
mysql_select_db("$database") or die(mysql_error());
$server_query_sql = ("SELECT * FROM $admin_tbl WHERE username = '$loggeduser'");
$getdata = mysql_query($server_query_sql) or die("Couldn't execute the query");
$row = mysql_fetch_array( $getdata );
$adminuser = $row['username'];
$adminpass = $row['password'];
$adminemail = $row['email'];
mysql_close();
}
else {
$postemail = $_POST["email"];
$postpass = $_POST["password"];
$encrypted_password = md5($postpass);
mysql_connect("$host", "$user", "$pwd") or die(mysql_error());
mysql_select_db("$database") or die(mysql_error());
$server_query_sql = ("SELECT * FROM $admin_tbl WHERE username = '$loggeduser'");
$getdata = mysql_query($server_query_sql) or die("Couldn't execute the query");
$row = mysql_fetch_array( $getdata );
$adminuser = $row['username'];
$adminpass = $row['password'];
$adminemail = $row['email'];
if ($encrypted_password = $adminpass){
$query = "UPDATE $admin_tbl SET email='$postemail' WHERE username='$loggeduser'";
mysql_query($query);
}
else {
$query = "UPDATE $admin_tbl SET email='$postemail', password='$encrypted_password' WHERE username='$loggeduser'";
mysql_query($query);
mysql_close();
}
}
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="../../inc/login.css" />
<style>
@import url(http://fonts.googleapis.com/css?family=Ubuntu:400,700);
body {
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
}
.container > header h1,
.container > header h2 {
color: #fff;
text-shadow: 0 1px 1px rgba(0,0,0,0.7);
}
</style>
</head>
<body><br><br>
<div align="center">Hi <strong><? echo $loggeduser; ?></strong>!</div>
<div class="container">
<section class="main">
<form class="form-3" method="post" action='<? $_SERVER['PHP_SELF']; ?>'>
<p class="clearfix">
<label for="login">Email</label>
<input type="text" name="email" id="email" placeholder="Username" value='<? echo $adminemail; ?>'>
</p>
<p class="clearfix">
<label for="password">Password</label>
<input type="password" name="password" id="password" placeholder="Password" value='<? echo $adminpass; ?>'>
</p>
<p class="clearfix">
<input type="submit" name="submit" value="Edit">
</p>
</form>
</section>
</div>
</body>
</html>