Location: PHPKode > projects > Decider > decider/Client/clienttab.php
<?php

	require('../Login/authen.php');

?>
<html>
<head>
<title>Decider - Information Gathering Assistant</title>
<script src="clienthint.js"></script> 
<link rel="stylesheet" type="text/css" href="../ajaxtabs/ajaxtabs.css" />
<link rel="stylesheet" type="text/css" href="../common/styles.css" />
<script type="text/javascript" src="../ajaxtabs/ajaxtabs.js">
</script>

<script type="text/javascript">
var xmlHttp

function show_edit_details(str)
{

if (str.length==0)
{ 
document.getElementById("suggest").innerHTML=""
return
}
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
} 
var url="gethint.php"
url=url+"?q="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
} 

function stateChanged() 
{ 

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 
var str=xmlHttp.responseText;



var length=str.length
var arr=new Array();
for(i=0;i<length;i++){

//using 'x' instead of 'k'

arr[i]=str.substring(0,str.indexOf('x'))
str=str.substring(str.indexOf('x')+1)

}

document.getElementById("client_address").value=arr[0]
document.getElementById("client_telno").value=arr[1]
document.getElementById("client_mail").value=arr[2]
document.getElementById("client_url").value=arr[3]
document.getElementById("client_description").value=arr[4]
} 
} 

function GetXmlHttpObject()
{ 
var objXMLHttp=null
if (window.XMLHttpRequest)
{
objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject)
{
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
return objXMLHttp
} 
</script> 
<!-- help code-->
<script language="javascript">
var id;
var txtname;
function handleSearchSuggest(txt) {
var str;

			id=txt;
			txtname=txt;		
			var ss = document.getElementById("help");
			ss.innerHTML = '';
			if(id=="addhelp"){
		    str = "This form is used to add new client details";
			}
			if(id=="edithelp"){
			str = "This form is used to edit client details";
			}
			if(id=="deletehelp"){
			str = "This form is used to delete client details";
			}
			var suggest = '<div onmouseover="javascript:helpOver(this);" ';
			suggest += 'onmouseout="javascript:helpOut(this);" ';
			suggest += 'onclick="javascript:closeBox(this.innerHTML);" ';
			suggest += 'class="suggest_link">'+ str + '</div>';
			ss.innerHTML += suggest;
			}

//Mouse over function
function helpOver(div_value) {
	div_value.className = 'help_over';
}
//Mouse out function
function helpOut(div_value) {
	div_value.className = 'help_out';
}
//Click function
function closeBox(value) {
	document.getElementById("help").innerHTML = '';
}

</script>
</head>
<body>
<div id='maindiv'  align="center" >
<table width="800px">
	<tr>
		<td align="left" valign="top"><?php require('../common/top.html'); ?></td>
	</tr>
</table>

<table background="../common/tableback.png"  width="800px" height="800px" >
<tr align="right"><td></td><td class="label" align="right">
	<?php 
	
echo $_SESSION['username'];
?></td></tr>
	<tr>
		<td width="200px" align="left" valign="top"><?php require('../common/menu.html'); ?></td>
		<td width="600px" align="left" valign="top"><?php require('../Client/clienttab.html'); ?></td>
	</tr>
</table>

<?php
//to add data to client table
if(isset($_POST['add'])){
 echo $_post['client_name'];
	require("../common/database.php");
	
	$q_string="INSERT INTO client (Name, Address,Tel,Email,Website,Description)
	VALUES
	('$_POST[client_name]','$_POST[client_address]','$_POST[client_telno]','$_POST[client_email]','$_POST[client_url]','$_POST[cleint_description]')";

	if (!mysql_query($q_string,$link))
	  {
	  die('Error: ' . mysql_error());
	  }
	 
	echo "1 record added";
	
	mysql_close($link);
	
}

?>
<?php 
//to edit data in client table
if(isset($_POST['edit'])){
	require("../common/database.php");
	if (!$link)
  	{
  		die('Could not connect: ' . mysql_error());
  	}

$q_string="UPDATE client SET Address='$_POST[client_address]',Tel='$_POST[client_telno]',Email='$_POST[client_email]',Website='$_POST[client_url]',Description='$_POST[client_description]' WHERE Name = '$_POST[client_name]'";
	
if (!mysql_query($q_string,$link))
	  {
	  die('Error: ' . mysql_error());
	  }
	echo "1 record edited";
	
	mysql_close($link);
	
	
}
?>
<?php 
//to delete data from client table
if(isset($_POST['delete'])){

	require("../common/database.php");
	if (!$link)
  	{
  		die('Could not connect: ' . mysql_error());
  	}

$q_string="DELETE FROM client WHERE Name='$_POST[client_name]'";
	
if (!mysql_query($q_string,$link))
	  {
	  die('Error: ' . mysql_error());
	  }
	echo "1 record deleted";
	
	mysql_close($link);
	
	
}
?>
</div>
</body>
</html>
Return current item: Decider