標籤:
插入代碼
view plaincopy <?
$action=$_GET[‘action‘];
switch($action){
//添加記錄
case"add";
$mail = trim(htmlspecialchars($_POST["mail"]));
$username = trim(htmlspecialchars($_POST["username"]));
$tel = trim(htmlspecialchars($_POST["tel"]));
$fax = 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>";//*/
}?>
編輯代碼
view plaincopy
<?
$action=$_GET[‘action‘];
switch($action){
//添加記錄
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>
刪除代碼
[xhtml] view plaincopy <a href="?action=del&id=<? echo $rs[‘id‘];?>" onclick="return confirm(‘確定刪除?‘)">刪除</a> <?
$action=$_GET[‘action‘];
switch($action){
//刪除記錄
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插入資料庫代碼,編輯,刪除