Location: PHPKode > projects > Decider > decider/Domain/domaintab.php
<?php

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

?>
<html>
<head>
<title>Decider - Information Gathering Assistant</title>
<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 showHint(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++){

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

}


document.getElementById("domain_description").value=arr[0]


} 
} 

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=="adddomainhelp"){
		    str = "This form is used to add new domain details";
			}
			if(id=="editdomainhelp"){
			str = "This form is used to edit domain details";
			}
			if(id=="deletedomainhelp"){
			str = "This form is used to delete domain 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 align="left" valign="top"><?php require('../common/menu.html'); ?></td>
		<td width="600px" align="left" valign="top"><?php require('domaintab.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 domain (Name, Description)
	VALUES
	('$_POST[domain_name]','$_POST[domain_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 domain SET Description='$_POST[domain_description]' WHERE Name = '$_POST[domain_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 domain WHERE Name='$_POST[domain_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