Hi guys,
I want to know how to fill a list/menu box with the column: "id_utiliza dor" from table: "tbl_utilizador es" from database: "db_faq".
And when i select a id on that box i want it to fill the fields, which are ("utilizador ", "email", "password", "administrator" ).
This page is a update page for admin use only (that is taken care of).
This is the update page code (atualizar_regi sto.php):
There is an image attached with the page and where the box should be.
Any additional info needed just ask.
Thanks in advance.
Peace,
Slaxer13
PS: Some things may be in portuguese, if you don't understand just let me know...
I want to know how to fill a list/menu box with the column: "id_utiliza dor" from table: "tbl_utilizador es" from database: "db_faq".
And when i select a id on that box i want it to fill the fields, which are ("utilizador ", "email", "password", "administrator" ).
This page is a update page for admin use only (that is taken care of).
This is the update page code (atualizar_regi sto.php):
Code:
<?php require_once('Connections/FAQ.php'); ?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "1";
$MM_donotCheckaccess = "false";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && false) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "login_errado.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0)
$MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$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"] == "form1")) {
$updateSQL = sprintf("UPDATE tbl_utilizadores SET utilizador=%s, password=%s, email=%s WHERE id_utilizador=%s",
GetSQLValueString($_POST['utilizador'], "text"),
GetSQLValueString($_POST['password'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['id_utilizador'], "int"));
mysql_select_db($database_FAQ, $FAQ);
$Result1 = mysql_query($updateSQL, $FAQ) or die(mysql_error());
$updateGoTo = "login.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
$colname_Utilizadores = "-1";
if (isset($_GET['id_utilizador'])) {
$colname_Utilizadores = $_GET['id_utilizador'];
}
mysql_select_db($database_FAQ, $FAQ);
$query_Utilizadores = sprintf("SELECT * FROM tbl_utilizadores WHERE id_utilizador = %s", GetSQLValueString($colname_Utilizadores, "int"));
$Utilizadores = mysql_query($query_Utilizadores, $FAQ) or die(mysql_error());
$row_Utilizadores = mysql_fetch_assoc($Utilizadores);
$totalRows_Utilizadores = mysql_num_rows($Utilizadores);
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Atualizar Registo</title>
</head>
<body>
<h1>Atualizar Registo</h1>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">ID:</td>
<td></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Utilizador:</td>
<td><input type="text" name="utilizador" value="<?php echo htmlentities($row_Utilizadores['utilizador'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Password:</td>
<td><input type="text" name="password" value="<?php echo htmlentities($row_Utilizadores['password'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Email:</td>
<td><input type="text" name="email" value="<?php echo htmlentities($row_Utilizadores['email'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Admin:</td>
<td><input type="text" name="administrator" value="<?php echo htmlentities($row_Utilizadores['administrator'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td><input type="submit" value="Atualizar Registo"></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form1">
<input type="hidden" name="id_utilizador" value="<?php echo $row_Utilizadores['id_utilizador']; ?>">
</form>
<p> </p>
</body>
</html>
<?php
mysql_free_result($Utilizadores);
?>
Any additional info needed just ask.
Thanks in advance.
Peace,
Slaxer13
PS: Some things may be in portuguese, if you don't understand just let me know...
Comment