-1
我有一個上傳電子簽名圖像到用戶配置文件的問題,雖然我找不到我出錯的地方:(我確實在所有其他文件中包含了「簽名」規定......我思念的東西?表單不會更新用戶配置文件
<?php
if (isset($_GET['success']) === true && empty($_GET['success']) === true) {
echo 'Your details have been updated!';
}
else {
if (empty($_POST) === false && empty($errors) === true) {
$update_data = array(
'username' => $_POST['username'],
'fullname' => $_POST['fullname'],
'email' => $_POST['email'],
'contact1' => $_POST['contact1'],
'contact2' => $_POST['contact2'],
'businessaddress' => $_POST['businessaddress'],
'businessprovince' => $_POST['businessprovince'],
'businesstown' => $_POST['businesstown'],
'businesszip' => $_POST['businesszip'],
'businessnumber' => $_POST['businessnumber'],
'businessfax' => $_POST['businessfax'],
'hrnumber' => $_POST['hrnumber'],
'hremail' => $_POST['hremail'],
'hrperson' => $_POST['hrperson'],
'signature' => $_POST['signature'],
'allow_email' => ($_POST['allow_email'] == 'on') ? 1 : 0
);
update_user($session_user_id, $update_data);
header('Location: settings.php?success');
exit();
}
else if (empty($errors) === false) {
echo output_errors($errors);
}
function update_user($user_id, $update_data)
{
$update = array();
array_walk($update_data, 'array_sanitize');
foreach ($update_data as $field => $data) {
$update[] = '`' . $field . '` = \'' . $data . '\'';
}
mysql_query("UPDATE `users` SET " . implode(', ', $update) . " WHERE `user_id` = $user_id");
}
}
?>
<form action="" method="post" enctype="multipart/form-data">
<table cellpadding="5" cellspacing="5" width="600px">
<tr>
<td></td>
<td></td>
</tr>
</table>
<table cellpadding="5" cellspacing="5" width="600px">
<tr>
<td valign="top">
<table cellpadding="5" cellspacing="5" width="100%">
<tr>
<td>UserName*:</p></td>
<td><input type="text" name="username" value="<?php echo $user_data['username']; ?>" /></td>
</tr>
<tr>
<td>Full Name*:</td>
<td><input type="text" name="fullname" value="<?php echo $user_data['fullname']; ?>" /></td>
</tr>
<tr>
<td>Emial Address*:</td>
<td><input type="text" name="email" value="<?php echo $user_data['email']; ?>" /></td>
</tr>
<tr>
<td>Contact Number 1*:</td>
<td><input type="text" name="contact1" value="<?php echo $user_data['contact1']; ?>" /></td>
</tr>
<tr>
<td>Work Number:</td>
<td><input type="text" name="contact2" value="<?php echo $user_data['contact2']; ?>" /></td>
</tr>
<tr>
<td>
<input type="checkbox" name="allow_email" <?php if ($user_data['allow_email'] == 1) { echo 'checked="checked"'; } ?>> Would you like to receive email from us?</td>
</tr>
<tr>
<td>Your Electronic Signature</td>
<td><input type="file" name="signature" value="signature"></td>
</tr>
</table>
</td>
<td>
<table cellpadding="5" cellspacing="5" width="100%">
<tr>
<td>Business Address*:</td>
<td><input type="text" name="businessaddress" value="<?php echo $user_data['businessaddress']; ?>" /></td>
</tr>
<tr>
<td>Business Province*:</td>
<td><input type="text" name="businessprovince" value="<?php echo $user_data['businessprovince']; ?>" /></td>
</tr>
<tr>
<td>Business Town*:</td>
<td><input type="text" name="businesstown" value="<?php echo $user_data['businesstown']; ?>" /></td>
</tr>
<tr>
<td>Business Address Zip*:</td>
<td><input type="text" name="businesszip" value="<?php echo $user_data['businesszip']; ?>" /></td>
</tr>
<tr>
<td>Office Tel Number*:</td>
<td><input type="text" name="businessnumber" value="<?php echo $user_data['businessnumber']; ?>" /></td>
</tr>
<tr>
<td valign="top">Office Fax Number:</td>
<td valign="top"><input type="text" name="businessfax" value="<?php echo $user_data['businessfax']; ?>" /></td>
</tr>
</table>
</td>
</tr>
</table>
<h3>Human Resources Department Details</h3>
<table cellpadding="5" cellspacing="5" width="600px">
<tr>
<td>HR Contact Number:<br /><input type="text" name="hrnumber" value="<?php echo $user_data['hrnumber']; ?>" /></td>
<td>HR Email Address:<br /><input type="text" name="hremail" value="<?php echo $user_data['hremail']; ?>" /></td>
<td>HR Contact person:<br /><input type="text" name="hrperson" value="<?php echo $user_data['hrperson']; ?>" /></td>
</tr>
<tr>
<td></td>
<td></td>
<td><input type="submit" value="Update all"></td>
</tr>
</table>
</form>
什麼是不工作?你會得到什麼錯誤?你做了什麼來解決這個問題? –
你可以添加你的'update_user()'函數的代碼嗎?或者代碼甚至沒有那麼遠? – andrewsi
這是功能。它沒有上傳簽名圖片。仍然是新的PHP。感謝您抽出時間 //更新用戶 函數update_user($ user_id,$ update_data){ \t $ update = array(); \t array_walk($ update_data,'array_sanitize'); \t \t foreach($ update_data as $ field => $ data){ \t \t $ update [] ='''。 $字段。 ''= \''。 $數據。 '\''; \t} \t \t 的mysql_query( 「UPDATE'users' SET」 內爆( '',$更新) 「WHERE'user_id' = $ USER_ID」。); } –