1:
2:
<?php
3:
4:
include 'db_conn.php';
5:
header('Content-Type:text/html; charset=UTF-8');
6:
7:
if(isset($_POST['doSave']))
8:
{
9:
// Filter POST data for harmful code (sanitize)
10:
foreach($_POST as $key => $value) {
11:
$data[$key] = filter($value);
12:
}
13:
14:
$first= $data[first_name];
15:
$last= $data[last_name] ;
16:
$full_name= $first .' '. $last ;
17:
18:
mysql_query("UPDATE users SET
19:
`first_name` = '$data[first_name]',
20:
`last_name` = '$data[last_name]',
21:
`full_name` = '$full_name'
22:
WHERE id='$_SESSION[user_id]'
23:
") or die(mysql_error());
24:
25:
}
26:
$rs_settings = mysql_query("select * from users where id='$_SESSION[user_id]'");
27:
28:
?>
29:
<html>
30:
<head>
31:
<title>Update Name</title>
32:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
33:
</head>
34:
35:
<body>
36:
37:
<?php while ($row_settings = mysql_fetch_array($rs_settings)) {?>
38:
<form action="user_update.php" method="post" name="myform" id="myform" >
39:
<table width="98%" border="0" align="center" cellpadding="7" cellspacing="3">
40:
41:
42:
<tr>
43:
<td><?php echo 'First Name' ?></td>
44:
<td>
45:
<input name="first_name" type="text" id="first_name" value="<?php echo $row_settings['first_name']; ?>">
46:
</td>
47:
</tr>
48:
49:
<tr>
50:
<td><?php echo 'Last Name' ?></td>
51:
<td>
52:
<input name="last_name" type="text" id="last_name" value="<?php echo $row_settings['last_name']; ?>">
53:
</td>
54:
</tr>
55:
56:
<tr>
57:
<td></td>
58:
<td>
59:
<input class="button" name="doSave" type="submit" id="doSave" value="<?php echo 'Save' ?>">
60:
</td>
61:
</tr>
62:
</table>
63:
64:
</form>
65:
<?php } ?>
66:
67:
</body>
68:
</html>
69:
70: