【php开源代码栏目提醒】:网学会员在php开源代码频道为大家收集整理了guest_ADD.PHP提供大家参考,希望对大家有所帮助!
<?php include("conn_sql.php"); ?>
<?
//接收addmsg.php传来的信息
$subject=$_REQUEST["subject"];
$name = $_REQUEST["name"];
$email = $_REQUEST["email"];
$pic=$_REQUEST["pic"];
$memo=nl2br($_REQUEST["memo"]);
$personal = $_REQUEST["personal"];
//将单引号置换为双引号
Function chgStr($data)
{
$chgStr = "'" . str_replace("'", "''", $data) . "'";
return $chgStr;
}
//将数据写入数据库
$sql = "Insert Into allmessage (网友, 留言主题, 联络信箱, 留言内容, 私人公开, 图形, 留言时间) Values (";
$sql = $sql . chgStr($name) . ",";
$sql = $sql . chgStr($subject) . ",";
$sql = $sql . chgStr($email) . ",";
$
sql = $sql . chgStr($memo) . ",";
$sql = $sql . chgStr($personal) . ",";
$sql = $sql . $pic . ",'";
$sql = $sql . date("Y-m-j H:i:s") . "')";
mysql_query($sql);
//将网页转向至显示留言意见的网页guest.php
header("Location: guest.php");
?>