简体   繁体   English

需要帮助来修改“股票”的PHP / MySQL Dreamweaver代码

[英]need help modifying “stock” php/mysql dreamweaver code

i am using the dreamweaver cs4 "insert into" function to manage multiple forms on a single page. 我正在使用Dreamweaver CS4“插入”功能来管理单个页面上的多个表单。 but i am having difficulty editing the code so that it: 但我在编辑代码时遇到困难,因此:

  1. inserts data from the form into the table 将表单中的数据插入表中
  2. retrieves the id of the newly added row 检索新添加的行的ID
  3. echoes a confirmation message on the same page and a link containing the id (as a reference) 在同一页面上回显确认消息以及包含id的链接(作为参考)

here is what dreamweaver has given me so far... it should only add a new row to database (untested): 这是Dreamweaver到目前为止给我的东西...它应该只向数据库添加一个新行(未经测试):

<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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"] == "form")) {
  $insertSQL = sprintf("INSERT INTO tbl_solicitors (solicitorName, solicitorDetail) VALUES (%s, %s)",
                       GetSQLValueString($_POST['solicitorName'], "text"),
                       GetSQLValueString($_POST['solicitorDetail'], "text"));

  mysql_select_db($database_speedycms, $speedycms);
  $Result1 = mysql_query($insertSQL, $speedycms) or die(mysql_error());
}
?>

any help would be appreciated... thanks and happy New Year! 任何帮助将不胜感激...新年快乐!

dont worry i found a solution... decided not to use code i am not familiar with! 不用担心,我找到了解决方案...决定不使用我不熟悉的代码!

thanks for checking tho! 感谢您的检查!

if (array_key_exists('solicitor',$_POST)) {
            $solicitorName = $_POST['solicitorName'];
            echo "The record for <b>$solicitorName</b> has been successfully added to the database.<p>
            <a href='#' class='form'>View details</a><p>
            <a href='instructus.php' class='form'>Create a new record</a>
            ";
            exit;
            };

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM