Location: PHPKode > projects > eCanteen > ecanteen/maintain/majorone.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

//Copyright David Byrne 2007

//This file is part of eCanteen.

//    eCanteen is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.

//    eCanteen is distributed in the hope that it will be useful
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    GNU General Public License for more details.

//    You should have received a copy of the GNU General Public License
//    along with eCanteen.  If not, see <http://www.gnu.org/licenses/>.


function connect()
  $conn = mysql_connect(DB_SERVER, DB_USER, DB_PASS);
  return $conn;
//echo count($_POST);

echo "<BR>";
if (count($_POST)>0)
	$xx=db_update('majorcustomer', 'CustomerID', $_POST["CustomerID"]);
// Function Name:	db_update()
// Accepts:  		varchar table, varchar pk, varchar pkval
// Returns:			Success or mysql_error()
// Author:			Andrew Deering
// Date:			12/10/04
// Purpose:
//	This function takes all of the posted form elements 
//	and updates $table WHERE $pk = $pkval with new values.
function db_update($table, $pk, $pkval){
	//$query = "UPDATE <table> SET
	$query = "UPDATE ".$table." SET ";
	$query =$query."`UserName_L2`='".$_POST["UserName_L2"]."', `FirstName`='".$_POST["FirstName"]."', `LastName`='".$_POST["LastName"]."', `MobileNumber`='".$_POST["MobileNumber"]."',`EmailAddress`='".$_POST["EmailAddress"]."' WHERE `CustomerID`=".$_SESSION['CustomerID'].";";
	//$query = "UPDATE <table> SET $fldnm1 = fldnm1, $fldnm2 = fldnm2, ... $fldnmN = fldnmN
	//$fldnmN = $fieldnameN //EXPLANATION//
	//$trigger = 0;
	//foreach($_POST as $field => $value){
		//echo $trigger." ".$field." = ".$value."<br><br>";
	  //if($trigger > 0) $query = $query . ", ";
	  //$query = $query . $field." = $value";
	//$query = "UPDATE <table> SET $fldnm1 = fldnm1, $fldnm2 = fldnm2, ... $fldnmN = fldnmN WHERE $pk = $pkval
	//$query = $query . " WHERE ".$pk." = ".$pkval;	
	//IF query runs, return.  else, tell me why
	//echo $query."<br><br>";
	if($result = mysql_query($query)) return(0);
	else echo(mysql_error());
//END db_update


<LINK REL="stylesheet" TYPE="text/css" HREF="maintain.css">
<button id="Return2Cal" onclick="window.location.href='../index.php?site=<?$_SESSION['SiteID']?>>';return true;" style="width: 190px">Return to Main Menu</button><br />
<form action="majorone.php" method="post">
$conn = connect();

$sqlstmt="SELECT m.`CustomerID`, m.`UserName_L2`, m.`FirstName`, m.`LastName`, m.`MobileNumber`,m.`EmailAddress`, m.`Password`, m.`UserLevel_L3`, m.`Credit_L2`, m.`Active_L2`, m.`~SiteID$` FROM majorcustomer m WHERE m.`CustomerID`=".$_SESSION['CustomerID'].";";

<table class="tbl" border="0" cellspacing="1" cellpadding="5" width="50%">
<td class="hr"><? echo htmlspecialchars("Customer ID:")."&nbsp;" ?></td>
<td class="dr"><input type="text" readonly name="CustomerID" value="<? echo mysql_result($objRecordset1,0,"CustomerID") ;?>"></td>
<td class="hr"><? echo htmlspecialchars("UserName")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="UserName_L2" maxlength="20" value="<?echo mysql_result($objRecordset1,0,"UserName_L2") ;?>"></td>
<td class="hr"><? echo htmlspecialchars("First Name")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="FirstName" maxlength="30" value="<? echo str_replace('"', '&quot;', trim(mysql_result($objRecordset1,0,"FirstName"))) ;?>"></td>
<td class="hr"><? echo htmlspecialchars("Last Name")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="LastName" maxlength="30" value="<?echo mysql_result($objRecordset1,0,"LastName");?>"></td>
<td class="hr"><? echo htmlspecialchars("Mobile Number")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="MobileNumber" maxlength="10" value="<? echo str_replace('"', '&quot;', trim(mysql_result($objRecordset1,0,"MobileNumber")));?>"></td>
<td class="hr"><? echo htmlspecialchars("Email Address")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="EmailAddress" maxlength="50" value="<? echo str_replace('"', '&quot;', trim(mysql_result($objRecordset1,0,"EmailAddress"))) ;?>"></td>

<td class="hr"><? echo htmlspecialchars("UserLevel")."&nbsp;" ?></td>
<td class="dr"><? echo mysql_result($objRecordset1,0,"UserLevel_L3");?></td>
<td class="hr"><? echo htmlspecialchars("Credit")."&nbsp;" ?></td>
<td class="dr"><? echo str_replace('"', '&quot;', trim(mysql_result($objRecordset1,0,"Credit_L2"))) ;?></td>


<p><input type="submit" name="action" value="Post"></p>


Return current item: eCanteen