Location: PHPKode > projects > eCanteen > ecanteen/maintain/siteone.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
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    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/>.

session_start(); 

if ($_SESSION['userlevel']>=3)
{

include("../include/constants.php");

mysql_free_result();


$recid=$_SESSION['CustomerID'];
$siteid=$_SESSION['SiteID'];






////////////////////////////////////////////////////////////
// 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.
///////////////////////////////////////////////////////////
if (count($_POST)>0){
	//$query = "UPDATE <table> SET
	
	
	
	if ($_POST["Sunday"]=="on")
	{
		$Sunday=1;
	}else{
		$Sunday=0;
	}
	if ($_POST["Monday"]=="on")
	{
		$Monday=1;
	}else{
		$Monday=0;
	}
	if ($_POST["Tuesday"]=="on")
	{
		$Tuesday=1;
	}else{
		$Tuesday=0;
	}
	if ($_POST["Wednesday"]=="on")
	{
		$Wednesday=1;
	}else{
		$Wednesday=0;
	}
	if ($_POST["Thursday"]=="on")
	{
		$Thursday=1;
	}else{
		$Thursday=0;
	}
	if ($_POST["Friday"]=="on")
	{
		$Friday=1;
	}else{
		$Friday=0;
	}
	if ($_POST["Saturday"]=="on")
	{
		$Saturday=1;
	}else{
		$Saturday=0;
	}
	
	$query = "UPDATE siteid SET ";
	
	$query =$query."`Site`='".$_POST["Site"]."', `Site Number`='".$_POST["SiteNumber"]."', `WelcomeMessage`='".$_POST["WelcomeMessage"]."', `WebMasterContact`='".$_POST["WebMasterContact"]."', `WebMasterEmail`='".$_POST["WebMasterEmail"]."', `AdminContact`='".$_POST["AdminContact"]."', `AdminEmail`='".$_POST["AdminEmail"]."', `PostalAddress`='".$_POST["PostalAddress"]."', `Postcode`='".$_POST["Postcode"]."', `ChequeTo`='".$_POST["ChequeTo"]."', `CashPayment`='".$_POST["CashPayment"]."', `PayPalDetails`='".$_POST["PayPalDetails"]."', `Phone`='".$_POST["Phone"]."', `Fax`='".$_POST["Fax"]."', `Sunday`='".$Sunday."', `Monday`='".$Monday."', `Tuesday`='".$Tuesday."', `Wednesday`='".$Wednesday."', `Thursday`='".$Thursday."', `Friday`='".$Friday."', `Saturday`='".$Saturday."' WHERE `SiteID`=".$_SESSION['SiteID'].";";
	
	
	
	//$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";
	  //$trigger++;
	//}
	
	
	//$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>";
	mysql_connect(DB_SERVER, DB_USER, DB_PASS);
  mysql_select_db(DB_NAME);
	mysql_query($query);
	echo mysql_error();
	
	//$recid=$_SESSION['CustomerID'];
}
//END db_update

 ?>

<html>
<head>
<LINK REL="stylesheet" TYPE="text/css" HREF="maintain.css">
<body>
<h2>Site Details</h2>&nbsp<button id="Return2Cal" onclick="window.location.href='../index.php';return true;" style="width: 190px">Return to Main Menu</button>
<form action="siteone.php" method="post">
<?
	mysql_connect(DB_SERVER, DB_USER, DB_PASS);
  mysql_select_db(DB_NAME);

$sqlstmt="SELECT `SiteID`, `Site`, `Site Number`, `WelcomeMessage`, `WebMasterContact`, `WebMasterEmail`, `AdminContact`, `AdminEmail`, `PostalAddress`, `Postcode`, `ChequeTo`, `CashPayment`, `PayPalDetails`, `Phone`, `Fax`,`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday` FROM siteid WHERE `SiteID`=".$_SESSION['SiteID'].";";

$objRecordset1=mysql_query($sqlstmt);
?>
<table class="tbl" border="0" cellspacing="1" cellpadding="5"width="50%">
<tr>
<td class="hr"><? echo htmlspecialchars("SiteID")."&nbsp;" ?></td>
<td class="dr">

<input type="text" size="10"  readonly name="SiteID" value="<? echo mysql_result($objRecordset1,0,"SiteID") ;?>"></td>
</tr>

<tr>
<td class="hr"><? echo htmlspecialchars("Site")."&nbsp;" ?></td>
<td class="dr"><input type="text" size="35"  name="Site" maxlength="20" value="<?echo mysql_result($objRecordset1,0,"Site") ;?>"></td>
</tr>


<tr>
<td class="hr"><? echo htmlspecialchars("Site Number")."&nbsp;" ?></td>
<td class="dr"><input type="text" size="20"  name="SiteNumber" maxlength="20" value="<?echo mysql_result($objRecordset1,0,"Site Number") ;?>"></td>
</tr>

<tr>
<td class="hr"><? echo htmlspecialchars("WelcomeMessage")."&nbsp;" ?></td>
<td class="dr">
<textarea name="WelcomeMessage" cols="35" rows="5"><? echo str_replace('"', '&quot;', trim(mysql_result($objRecordset1,0,"WelcomeMessage"))) ;?></textarea>




</td>
</tr>

<tr>
<td class="hr"><? echo htmlspecialchars("WebMasterContact")."&nbsp;" ?></td>
<td class="dr"><input type="text" size="50"  name="WebMasterContact" maxlength="75" value="<?echo mysql_result($objRecordset1,0,"WebMasterContact");?>"></td>
</tr>

<tr>
<td class="hr"><? echo htmlspecialchars("WebMasterEmail")."&nbsp;" ?></td>
<td class="dr"><input type="text" size="50"  name="WebMasterEmail" maxlength="75" value="<? echo str_replace('"', '&quot;', trim(mysql_result($objRecordset1,0,"WebMasterEmail")));?>"></td>
</tr>

<tr>
<td class="hr"><? echo htmlspecialchars("AdminContact")."&nbsp;" ?></td>
<td class="dr"><input type="text" size="50"  name="AdminContact" maxlength="50" value="<? echo str_replace('"', '&quot;', trim(mysql_result($objRecordset1,0,"AdminContact"))) ;?>"></td>
</tr>

<tr>
<td class="hr"><? echo htmlspecialchars("AdminEmail")."&nbsp;" ?></td>
<td class="dr"><input type="text"  size="50"  name="AdminEmail" value="<? echo mysql_result($objRecordset1,0,"AdminEmail") ;?>"></td>
</tr>

<tr>
<td class="hr"><? echo htmlspecialchars("PostalAddress")."&nbsp;" ?></td>
<td class="dr"><input type="text" size="50"  name="PostalAddress" value="<? echo mysql_result($objRecordset1,0,"PostalAddress") ;?>"></td>
</tr>

<tr>
<td class="hr"><? echo htmlspecialchars("Postcode")."&nbsp;" ?></td>
<td class="dr"><input type="text" size="20"  name="Postcode" value="<? echo str_replace('"', '&quot;', trim(mysql_result($objRecordset1,0,"Postcode"))) ;?>"></td>
</tr>

<tr>
<td class="hr"><? echo htmlspecialchars("ChequeTo")."&nbsp;" ?></td>
<td class="dr"><input type="text" size="50"  name="ChequeTo" value="<? echo mysql_result($objRecordset1,0,"ChequeTo") ;?>"></td>
</tr>

<tr>
<td class="hr"><? echo htmlspecialchars("CashPayment")."&nbsp;" ?></td>
<td class="dr"><input type="text" size="50"  name="CashPayment" value="<? echo mysql_result($objRecordset1,0,"CashPayment") ;?>"></td>
</tr>

<tr>
<td class="hr"><? echo htmlspecialchars("PayPalDetails")."&nbsp;" ?></td>
<td class="dr"><input type="text" size="50"  name="PayPalDetails" value="<? echo mysql_result($objRecordset1,0,"PayPalDetails") ;?>"></td>
</tr>

<tr>
<td class="hr"><? echo htmlspecialchars("Phone")."&nbsp;" ?></td>
<td class="dr"><input type="text" size="20"  name="Phone" value="<? echo mysql_result($objRecordset1,0,"Phone") ;?>"></td>
</tr>

<tr>
<td class="hr"><? echo htmlspecialchars("Fax")."&nbsp;" ?></td>
<td class="dr"><input type="text" size="20"  name="Fax" value="<? echo mysql_result($objRecordset1,0,"Fax") ;?>"></td>
</tr>
</table>

<table>
<tr>
<td>Sun</td><td>Mon</td><td>Tue</td><td>Wed</td><td>Thu</td><td>Fri</td><td>Sat</td>

</tr>
<tr>
<td>
<?

if (mysql_result($objRecordset1,0,"Sunday")==True)
{
print "<input type=\"checkbox\" name=\"Sunday\" checked />";
}else{
print "<input type=\"checkbox\" name=\"Sunday\" />";
}
?>
</td><td>
<?

if (mysql_result($objRecordset1,0,"Monday")==True)
{
print "<input type=\"checkbox\" name=\"Monday\" checked />";
}else{
print "<input type=\"checkbox\" name=\"Monday\" />";
}
?>
</td><td><?

if (mysql_result($objRecordset1,0,"Tuesday")==True)
{
print "<input type=\"checkbox\" name=\"Tuesday\" checked />";
}else{
print "<input type=\"checkbox\" name=\"Tuesday\" />";
}
?></td><td>
<?
if (mysql_result($objRecordset1,0,"Wednesday")==True)
{
print "<input type=\"checkbox\" name=\"Wednesday\" checked />";
}else{
print "<input type=\"checkbox\" name=\"Wednesday\" />";
}
?>
</td><td>
<?
if (mysql_result($objRecordset1,0,"Thursday")==True)
{
print "<input type=\"checkbox\" name=\"Thursday\" checked />";
}else{
print "<input type=\"checkbox\" name=\"Thursday\" />";
}
?>
</td><td><?
if (mysql_result($objRecordset1,0,"Friday")==True)
{
print "<input type=\"checkbox\" name=\"Friday\" checked />";
}else{
print "<input type=\"checkbox\" name=\"Friday\" />";
}
?>

</td>
<td><?
if (mysql_result($objRecordset1,0,"Saturday")==True)
{
print "<input type=\"checkbox\" name=\"Saturday\" checked />";
}else{
print "<input type=\"checkbox\" name=\"Saturday\" />";
}
?>

</td>
</tr>



</table>

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

</body>



</html>
<?}?>
Return current item: eCanteen