Advertisement
tonykuroi

code

May 16th, 2014
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.32 KB | None | 0 0
  1. <?php require_once('Connections/tj_forum.php');
  2. require('logincheck.php'); ?>
  3. <?php
  4. if (!function_exists("GetSQLValueString")) {
  5. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  6. {
  7. if (PHP_VERSION < 6) {
  8. $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  9. }
  10.  
  11. $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  12.  
  13. switch ($theType) {
  14. case "text":
  15. $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  16. break;
  17. case "long":
  18. case "int":
  19. $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  20. break;
  21. case "double":
  22. $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  23. break;
  24. case "date":
  25. $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  26. break;
  27. case "defined":
  28. $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  29. break;
  30. }
  31. return $theValue;
  32. }
  33. }
  34.  
  35. $editFormAction = $_SERVER['PHP_SELF'];
  36. if (isset($_SERVER['QUERY_STRING'])) {
  37. $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
  38. }
  39. $uid=$_SESSION['userID'];
  40. $topicID=$_GET['topicID'];
  41. if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  42. $insertSQL = sprintf("INSERT INTO threadTable (threadName, initialText, topicID, userID) VALUES (%s, %s, $topicID, '$uid')",
  43. GetSQLValueString($_POST['threadName'], "text"),
  44. GetSQLValueString($_POST['initialText'], "text"));
  45.  
  46. mysql_select_db($database_tj_forum, $tj_forum);
  47. $Result1 = mysql_query($insertSQL, $tj_forum) or die(mysql_error());
  48. $insertGoTo = "comments.php?threadID=".[what do i put here];
  49. if (isset($_SERVER['QUERY_STRING'])) {
  50. $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
  51. $insertGoTo .= $_SERVER['QUERY_STRING'];
  52. }
  53. header(sprintf("Location: %s", $insertGoTo));
  54. }
  55.  
  56. mysql_select_db($database_tj_forum, $tj_forum);
  57. $query_Recordset1 = "SELECT * FROM threadTable";
  58. $Recordset1 = mysql_query($query_Recordset1, $tj_forum) or die(mysql_error());
  59. $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  60. $totalRows_Recordset1 = mysql_num_rows($Recordset1);
  61. ?>
  62. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  63. <html xmlns="http://www.w3.org/1999/xhtml">
  64. <head>
  65. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  66. <title>Post Thread</title>
  67. </head>
  68.  
  69. <body>
  70. <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
  71. <table align="center">
  72. <tr valign="baseline">
  73. <td width="83" align="right" nowrap="nowrap">Title:</td>
  74. <td width="517"><input type="text" name="threadName" value="" size="100" /></td>
  75. </tr>
  76. <tr valign="baseline">
  77. <td nowrap="nowrap" align="right">&nbsp;</td>
  78. <td><textarea name="initialText" cols="100" rows="6"></textarea></td>
  79. </tr>
  80. <tr valign="baseline">
  81. <td nowrap="nowrap" align="right">&nbsp;</td>
  82. <td><input type="submit" value="Insert record" /></td>
  83. </tr>
  84. </table>
  85. <input type="hidden" name="MM_insert" value="form1" />
  86. </form>
  87. <p>&nbsp;</p>
  88. </body>
  89. </html>
  90. <?php
  91. mysql_free_result($Recordset1);
  92. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement