Post 2 distinct values in 2 databases colums with selection of drop down menu 1
I am wanting to display a value in another column based on the selection in a menu drop-down. E.G. "If 'HE' is to select for the column, I want that he isert ' HE ' in the" Auth "column and also insert". " "/ member/indexXX.php" in the column "URL". Here is my form of addition. So far the form less works great as I have to go one manually add the url in my database. Any help would be great. Thanks in advance.
<? PHP
initialize the session
If (! isset {})
session_start();
}
* Log out the current user. **
$logoutAction = $_SERVER ['PHP_SELF']. » ? doLogout = true;
If ((isset & & ($_SERVER ['QUERY_STRING']! = "")) {})
$logoutAction. = '& '. htmlentities($_SERVER['QUERY_STRING']);
}
{If ((isset($_GET['doLogout'])) & & ($ {_GET ['doLogout'] == "true"))}
to completely disconnect a visitor, you must delete the session varialbles
$_SESSION ['MM_Username'] = NULL;
$_SESSION ['MM_UserGroup'] = NULL;
$_SESSION ['PrevUrl'] = NULL;
unset($_SESSION['MM_Username']);
unset($_SESSION['MM_UserGroup']);
unset($_SESSION['PrevUrl']);
$logoutGoTo = "... / index.htm";
If {($logoutGoTo)
Header ("Location: $logoutGoTo");
"exit";
}
}
? >
<? PHP
If (! isset {})
session_start();
}
$MM_authorizedUsers = "Webmaster";
$MM_donotCheckaccess = "false";
Restrict access to Page: grant or deny access to this page
Function isAuthorized ($strUsers, $UserGroup, $strGroups, $UserName) {}
For safety, first assuming that the visitor is NOT allowed.
$isValid = false;
When a visitor is connected to this site, the MM_Username of Session variable value equal to their username.
So, we know that a user is NOT logged if this Session variable is empty.
If (! empty ($UserName)) {}
In addition to being connected, you can restrict access to only certain users based on a created ID when they connect.
Analyze the channels in the tables.
$arrUsers = explode (",", $strUsers);
$arrGroups = explode (",", $strGroups);
If (in_array ($UserName, $arrUsers)) {}
$isValid = true;
}
Or, you can restrict access to only certain users based on their user name.
If (in_array ($UserGroup, $arrGroups)) {}
$isValid = true;
}
If (($strUsers == "") & & false) {}
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "... / admin/index.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 ($QUERY_STRING) & & strlen ($QUERY_STRING) > 0)
$MM_referrer. = « ? ». $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 = "")
{
$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 "set":
$theValue = ($theValue! = "")? $theDefinedValue: $theNotDefinedValue;
break;
}
Return $theValue;
}
}
$editFormAction = $_SERVER ['PHP_SELF'];
If (isset {}
$editFormAction. = « ? ». htmlentities($_SERVER['QUERY_STRING']);
}
If ((isset($_POST["MM_insert"])) & & ($_POST ["MM_insert"] == "form1")) {}
$insertSQL = sprintf ("INSERT INTO users (id, Fname Lname Uname, Pword, Email, Auth) VALUES (%s %s %s, %s, %s, %s, %s)',
GetSQLValueString ($_POST ['id'], "int").
GetSQLValueString ($_POST ['Fname'], "text").
GetSQLValueString ($_POST ["Lname"], "text").
GetSQLValueString ($_POST ['Uname'], "text").
GetSQLValueString ($_POST ["'Pword"], "text").
GetSQLValueString ($_POST ['Email'], "text").
GetSQLValueString ($_POST ["Auth"], "text"));
@mysql_select_db ($database_Users, $Users);
$Result1 = mysql_query ($insertSQL, $Users) or die (mysql_error ());
$insertGoTo = "... / admin/users.php";
If (isset {}
$insertGoTo. = (strpos ($insertGoTo, '?'))? « & » : « ? » ;
$insertGoTo. = $_SERVER ['QUERY_STRING'];
}
header (sprintf ("location: %s", $insertGoTo));
}
? >
< ! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional / / IN" " 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 > DD houses Admin < /title >
< style type = "text/css" >
<!--
. Style1 {color: #FF0000}
. Style7 {color: #000000}
->
< / style >
< link href = "ddh.css" rel = "stylesheet" type = "text/css" / > "
< / head >
< body > < div id = "adminbanner" > < / div >
< div id = "container" >
< a name = 'top' = 'top' id > < / a >
< td align = "center" valign = "top" > < table width = "100%" border = "0" cellspacing = "0" cellpadding = "10" >
< b >
< td width = "26%" align = "left" valign = "top" class = 'mission' > < table width = "174" border = "0" cellpadding = "0" cellspacing = "0" id = "mNavigation" >
< b >
< div id = "left" >
<? PHP include ('inc_navigation.php')? >
< / div > <! - end left - >
< /tr >
< /table >
"< a href ="... / admin/users.php "> < /a > < table >.
< td width = "74%" align = "left" class = 'mission' > < h3 align = "center" > < span class = "style7" > add users </span > < / h3 >
< h3 align = "center" >
< p > < / p >
< are method = "post" name = "form1" action = "<?" PHP echo $editFormAction;? > ">"
< table align = "center" >
< tr valign = 'of basic">
< td align = 'right' nowrap > first name: < table >
< td > < input type = "text" name = "Pnom" value = "" size = "32" > < table > "
< /tr >
< tr valign = 'of basic">
< td align = 'right' nowrap > first name: < table >
< td > < input type = "text" name = "Lname" value = "" size = "32" > < table > "
< /tr >
< tr valign = 'of basic">
< td align = 'right' nowrap > user name: < table >
< td > < input type = "text" name = "Uname" value = "" size = "32" > < table > "
< /tr >
< tr valign = 'of basic">
< td align = 'right' nowrap > password: < table >
< td > < input type = "text" name = "Pword" value = "" size = "32" > < table > "
< /tr >
< tr valign = 'of basic">
< td align = 'right' nowrap > Email: < table >
< td > < input type = "text" name = "Email" value = "" size = "32" > < table > "
< /tr >
< tr valign = 'of basic">
< td align = 'right' nowrap > status: < table >
< td > < select name = "Auth" >
< option value = 'HE' <? PHP if (!) strcmp () ("HE", ""))) {echo "SELECTED" ;}? > > HE < / option >
< option value = "IA" <? PHP if (!) strcmp () ("IA", ""))) {echo "SELECTED" ;}? > > HERE < / option >
< option value = "FL" <? PHP if (!) strcmp () ("FL", ""))) {echo "SELECTED" ;}? > > FL < / option >
< option value = "NV" <? PHP if (!) strcmp () ("NV", ""))) {echo "SELECTED" ;}? > > NV < / option >
< option value = "Webmaster" <? PHP if (!) strcmp () ("Webmaster", ""))) {echo "SELECTED" ;}? > > Webmaster < / option >
< / select > < table >
< /tr >
< tr valign = 'of basic">
< td align = 'right' nowrap > < table >
< td > < input type = "submit" value = "add a user" > < table >
< /tr >
< /table >
< input type = "hidden" name = "MM_insert" value = "form1" >
< / make >
< p > < / p >
< / h3 >
< table width = '500' border = "0" align = "center" cellpadding = "0" cellspacing = "0" >
< tr > < /tr >
< /table >
< b >
< td colspan = "2" align = "left" valign = "top" class = 'mission' > < table >
< /table >
< table width = "100%" border = "0" cellspacing = "0" cellpadding = "0" >
< b >
< td align = "center" valign = "top" > < table >
< /tr >
< / table > < table >
< /tr >
< /table >
< table >
< /tr >
< /table >
< p > < / p >
< / body >
< / html >
Working very well; Pass the 2 values to theTag:
value="Il:./Members/indexil.php".
update the code for existing as below:
If ((isset($_POST["MM_insert"])) & ($_POST ["MM_insert"] == "form1")) {}
$values = explode(':',$_POST['Auth']);
$insertSQL = sprintf ("INSERT INTO users (id, Fname Lname, Uname, Pword, Email, Auth, url) VALUES (%s %s %s, %s, %s, %s,'". ")") ($values [0]."',"«.$values[1]."')"