我想用名字和姓氏更新我的数据库表,其中电子邮件等于会话电子邮件,但我无法更新电子邮件等于用户登录电子邮件的表,请帮助我。
<?php
session_start();
if(!session_is_registered(email)){
header("location: login.html");
}?>
<?php
echo"<a href = logout.php> Logout </a>";
?>
<?php
include('config.php');
session_start();
if(isset($_SESSION['email'])) {
echo "Welcome ".$_SESSION['email']."";
}
?>
<?php
$dbhost = 'localhost';
$dbuser = 'user';
$dbpass = 'password';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
$sql="UPDATE nametable SET fname='$fname', lname='$lname' WHERE email='" . $_SESSION ['email'] . "'";
echo $row['fname']." - ".$row['lname']. "<br />";
if($result) {
echo "success";
} else {
echo "no success";
}
mysql_select_db('db');
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
die('Could not update data: ' . mysql_error());
}
echo "Updated data successfully\n";
mysql_close($conn);
?>
这个 id 将要提交的数据取决于将要更新的名字和姓氏 不要担心其他标签 我只是将它们放在一起以了解将要更新的内容上面的代码请告诉我我做错了什么
<html>
<head>
<title>Update a Record in MySQL Database</title>
</head>
<body>
<form method="post" action="update1.php">
<table width="400" border="0" cellspacing="1" cellpadding="2">
<tr>
<td width="100"> first name</td>
<td><input name="fname" type="text" id="fname"></td>
</tr>
<tr>
<td width="100">last name</td>
<td><input name="lname" type="text" id="lname"></td>
</tr>
<tr>
<td width="100"> </td>
<td> </td>
</tr>
<tr>
<td width="100"> </td>
<td>
<input name="submit" type="submit" id="submit" value="submit">
</td>
</tr>
</table>
</form>
</body>
</html>