postrec.php

来自「火花留言本」· PHP 代码 · 共 55 行

PHP
55
字号
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO board (digiB_name, digiB_face, digiB_subject, digiB_potime, digiB_email, digiB_web, qq, `open`, ip, digiB_content) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['digiB_name'], "text"),
                       GetSQLValueString($_POST['digiB_face'], "text"),
                       GetSQLValueString($_POST['digiB_subject'], "text"),
                       GetSQLValueString($_POST['digiB_potime'], "date"),
                       GetSQLValueString($_POST['digiB_email'], "text"),
                       GetSQLValueString($_POST['digiB_Web'], "text"),
                       GetSQLValueString($_POST['qq'], "text"),
                       GetSQLValueString($_POST['open'], "int"),
                       GetSQLValueString($_POST['ip'], "text"),
                       GetSQLValueString($_POST['digiB_content'], "text"));

  mysql_select_db($database_connBoard, $connBoard);
  $Result1 = mysql_query($insertSQL, $connBoard) or die(mysql_error());

  $insertGoTo = "index.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}
?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?