1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
| <?php session_start();
require_once('Connections/connection.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form2")) {
$updateSQL = sprintf("UPDATE Users SET password=%s, email=%s, firstName=%s, lastName=%s, getNotified=%s WHERE userName=%s",
GetSQLValueString($_POST['password'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['firstName'], "text"),
GetSQLValueString($_POST['lastName'], "text"),
GetSQLValueString(isset($_POST['getNotified']) ? "true" : "", "defined","1","0"),
GetSQLValueString($_POST['userName'], "text"));
mysql_select_db($database_connection, $connection);
$Result1 = mysql_query($updateSQL, $connection) or die(mysql_error());
$updateGoTo = "index.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
mysql_select_db($database_connection, $connection);
$query_rst = "SELECT * FROM Users WHERE username = '". $_SESSION['MM_Username'] . "'";
$rst = mysql_query($query_rst, $connection) or die(mysql_error());
$row_rst = mysql_fetch_assoc($rst);
$totalRows_rst = mysql_num_rows($rst);
?>
<form method="post" name="form2" action="<?php echo $editFormAction; ?>">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">UserName:</td>
<td><?php echo $row_rst['userName']; ?></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Password:</td>
<td><input type="text" name="password" value="<?php echo htmlentities($row_rst['password'], ENT_COMPAT, ''); ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Email:</td>
<td><input type="text" name="email" value="<?php echo htmlentities($row_rst['email'], ENT_COMPAT, ''); ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">FirstName:</td>
<td><input type="text" name="firstName" value="<?php echo htmlentities($row_rst['firstName'], ENT_COMPAT, ''); ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">LastName:</td>
<td><input type="text" name="lastName" value="<?php echo htmlentities($row_rst['lastName'], ENT_COMPAT, ''); ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">GetNotified:</td>
<td><input type="checkbox" name="getNotified" value="" <?php if (!(strcmp(htmlentities($row_rst['getNotified'], ENT_COMPAT, ''),""))) {echo "checked=\"checked\"";} ?>></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td><input type="submit" value="Update record"></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form2">
<input type="hidden" name="userName" value="<?php echo $row_rst['userName']; ?>">
</form>
<p> </p>
<?php
mysql_free_result($rst);
?> |
Partager