Inserting code
View Plaincopy<?
$action=$_get[' action '];
Switch ($action) {
Add a record
Case "Add";
$mail = Trim (htmlspecialchars ($_post["Mail"]));
$username = Trim (htmlspecialchars ($_post["username"));
$Tel = trim (Htmlspecialchars ($_post["Tel"]));
$传真 = Trim (htmlspecialchars ($_post["Fax"));
$ company= Trim (htmlspecialchars ($_post["Company"));
$address = Trim (Htmlspecialchars ($_post["Address")); $sql="insert into Crm_company (mail,username,tel,fax,company,address,addtime) VALUES (' $mail ', ' $ Username ', ' $tel ', ' $fax ', ' $company ', ' $address ', ' $addtime ');
Echo $sql;
mysql_query ($sql, $conn);
Print "<mce:script type=" Text/javascript "><!-- location.href=' c_companylist.php '; //--></mce:script> ";//*/
}?>
Edit Code
View Plaincopy
<?
$action =$_get[' action '];
Switch ($action) {
Add a record
Case"edit";
$uid = Trim (Htmlspecialchars ($_post["UID"));
$regtime = Trim (Htmlspecialchars ($_post["Regtime"));
$deadline = Trim (Htmlspecialchars ($_post["deadline"));
$item = Trim (Htmlspecialchars ($_post["item2"));
$price = Trim (Htmlspecialchars ($_post["price"));
$product = Trim (Htmlspecialchars ($_post["Product"));
$content = Trim (Htmlspecialchars ($_post["content"));
$sql ="Update crm_info set uid= ' $uid ', regtime= ' $regtime ', deadline= ' $deadline ', item= ' $item ', price= ' $price ', Product= ' $product ', content= ' $content ' where id= ' $id ' ";
Echo $sql;
mysql_query ($sql, $conn);
Print "<mce:script type=" Text/javascript "><!--
location.href=' c_infolist.php '; //--></mce:script> ";//*/
}?>
<form id="Form1" Name="Form1" method= "post" action="? action=edit&id=<?php echo $rs [' id '];? > "onsubmit=" return Checkadd () ">
</form>
Delete code
[XHTML]View Plaincopy<a href="? action=del&id=<? echo $rs [' id '];? > " onclick=" return confirm (' OK delete? ') ' > Delete </a> <?
$action=$_get[' action '];
Switch ($action) {
Deleting records
Case "Del";
$id=$_get[' id '];
$sql="Delete from Crm_info where id= ' $id '";
mysql_query ($sql, $conn);
Print "<mce:script type=" Text/javascript "><!-- location.href=' c_infolist.php '; //--></mce:script> ";
Break
}
?>
PHP Insert Database Code, edit, delete