从编辑配置文件将图像上传到数据库以替换旧图像


upload image to database from edit profil to replace the old one

这是我的项目,这是我的问题,我无法为更新Profil图片编写代码我希望用户可以上传他们的图片,并替换我在注册时自动设置的旧图片。谁能帮我修复我的代码?如果您发现"浏览"一词

<?php
include 'session.php';
if (!empty($_POST["action"])){
include 'connection.php';
if($_POST['tfname']!='' && $_POST['tpass1']!='' && $_POST['tpass2']!='' && $_POST['tpass1']==$_POST['tpass2']){
$sql="update user_login set email='".$_POST['temail']."', first_name='".$_POST['tfname']."', last_name='".$_POST['tlname']."', password='".$_POST['tpass1']."' where email='".$_POST['temail']."'";
$result=mysql_query($sql)or die(mysql_error());
header("location: general.php");
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Registration</title>
<link rel="stylesheet" type="text/css" href="all.css">
<body  background="image/background.jpg">
<?php include('header2.php'); ?>
<table border="1" bgcolor="#FBFBEF" width="100%">
    <tr>
<td align="left" width="90%"><b><a href="mainforum2.php" ><img src="image/homeicon.png" widht="40" height="40"></a>-&gt;<a href="general.php">General Discussion</a>-&gt; Edit Profile</b></td>
    </tr>
</table>
    <?php 
    include 'connection.php';
    $sql="select * from user_login where email='".$_SESSION['user_forum']."'";
    $result=mysql_query($sql);
    $row=mysql_fetch_array($result);
    ?>
<table border="1" width="80%" height="500" align="center" bgcolor="#FBFBEF" ><form id="form1" name="form1" method="post" action="">
        <tr>
            <td widht="20" align="center" valign="top" id="loginform"><strong><font size="10"> Register Form</font></strong>
                <table border="1" width="60%" height="150"  align="center"   >
                    <tr>
                    <td valign="top" colspan="3"><strong>Account Information</strong></td>
                    </tr>
                    <tr>
                    <td colspan="3" align="center"><img src="<?php echo $row['image'];?>"/></td>
                    </tr>
                    <tr>
                    <td colspan="3" align="center"><font color="green">Browse</font></td>
                    </tr>
                    <tr>
                    <td valign="top" width="50%">Email</td><td>:</td><td><input name="temail" type="text" id="temail" maxlength="50" size="29" readonly="true" value="<?php echo $row['email'];?>" /></td>
                    </tr>
                    <tr>
                    <td valign="top">Password</td><td>:</td><td><input name="tpass1" type="password" id="tpass1" size="29" value="<?php echo $row['password'];?>" /></td>
                    </tr>
                    <tr>
                    <td valign="top">Retype Password</td><td>:</td><td><input name="tpass2" type="password" id="tpass2" size="29" value="<?php echo $row['password'];?>" />
            <input name="action" type="hidden" id="action" value="edit" /></td>
                    </tr>
                    <tr>
                    <td valign="top" colspan="3"><strong>Personal Information</strong></td>
                    </tr>
                    <tr>
                    <td valign="top">First Name</td><td>:</td><td><input name="tfname" type="text" id="tfname"size="29" value="<?php echo $row['first_name'];?>" /></td>
                    </tr>
                    <tr>
                    <td valign="top">Last Name</td><td>:</td><td><input name="tlname" type="text" id="tlname"  size="29" value="<?php echo $row['last_name'];?>" /></td>
                    </tr>
                    <tr>
                    <td align="right" valign="top">Before Country</td><td>:</td><td><input type="text" name="country" readonly="true" size="29" value="<?php echo $row["country"];?>"/></td>
                    </tr>

                    <tr>
                    <td valign="top">Country</td><td>:</td>
                        <td width="65%" >
                        <select name="tcountry" id="tcountry">
                    <option value="">Country</option>
                    <option value="Afganistan">Afghanistan</option>
                    <option value="Albania">Albania</option>
                    <option value="Algeria">Algeria</option>
                    <option value="American Samoa">American Samoa</option>
                    <option value="Andorra">Andorra</option>
                    <option value="Angola">Angola</option>
                    <option value="Anguilla">Anguilla</option>
                </select>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="3" align="center"><input type="submit" name="Submit" value="Save" /></td>
                    </tr>
                </table>    
            </td>
        </tr>
    </form>
    </table>
</font>
</body>
<?php include('footer.php'); ?>
</head>
</html>

这是我的最后一个代码

嗨,

尝试添加 enctype="多部分/表单数据",如下所示并检查。

<form id="form1" name="form1" method="post" action="" enctype="multipart/form-data" >