更新到WampServer版本3.0.0 64位后,无法将表单数据插入Mysql数据库

时间:2016-05-16 02:47:03

标签: php mysql post wampserver

在更新到运行php 5.6.6的WampServer版本3.0.0 64位之前,我能够将表单数据提交到数据库中,没有任何问题。但是现在我提交表单时,即使我没有出现任何错误,数据也不会出现在我的数据库中。

当我检查php错误日志时,这就是所写的

php堆栈跟踪:  PHP 1. {main}()C:\ wamp \ www \ wavestech \ interface \ admin \ add_data.php:0

但我不知道那个错误意味着什么。

这是我的代码

<?php
include("../../config/connect.php");

session_start();
if (isset($_SESSION['uname'])) {

$username = $_SESSION['uname'];
}
else 
{

$username = '';
}

if("$username") {


  }
else  {
  echo
  '<html>
     <head>
      <title>BWT | Admin Area</title>
     <link rel="stylesheet" type="text/css" href="style.css" />
   </head>
  <body>
     <!--wrapper around the input fields-->
  <div id="wrapper">
      <center><b>    You must be logged in to view this page</b></center>
      <center>
  <img src="../../images/logo/smalllogo.png" width="120px" height="100px" />

   <div id="login">

<form action="index.php" method="POST">
  <input id="uname" name="uname" type="text" placeholder="Username" width="20"/> <br /><br />
  <input id="upass" name="upass" type="password" placeholder="Password" width="20"/><br /><br />

  <input type="submit" name="submit" value="Login" width=""/>
  </form>
</div>
</center>
</div><!--End of wrapper-->


   </body>
    </html>';

 die();
 exit();
   }


//User Login Code
if(isset ($_POST["uname"]) && isset($_POST["upass"])){
$uname = preg_replace('#[^A-Za-z0-9]#i', '', $_POST["uname"]);//Filter            everything but numbers and letter
$upass = preg_replace('#[^A-Za-z0-9]#i', '', $_POST["upass"]);//Filter everything but numbers and letter
$upass_md5 = md5($upass);

$sql = mysqli_query($db, "SELECT id FROM users WHERE username = '$uname' AND   password = '$upass_md5'");
//Check for their existence
$userCount = mysqli_num_rows($sql); //Count the number of rows
if ($userCount == 1){

    while($row = mysqli_fetch_array($sql)){
        $id = $row['id'];
    }

    $_SESSION["uname"] = $uname;
    header("location: home.php"); 
    exit();
} else {?>
    <script language="javascript" type="text/javascript">
    alert("The username or password provided is incorrect, try again");
    window.location = './index.php';
</script>
<?php           
}

}
if(@$_POST['submit']) {

$blogimage = $_FILES['blogimage'];
$blogtitle =($_POST['blogtitle']);
$rsstitle = ($_POST['rsstitle']);
$blogurl = ($_POST['blogurl']);
$blogsource = ($_POST['blogsource']);
$rsssummary = ($_POST['rsssummary']);
$blogcontent = ($_POST['blogcontent']);
$featured = ($_POST['featured']);
$date = date("Y/m/d");


$blogimage_name = ($_FILES["blogimage"]["name"]);
move_uploaded_file($_FILES["blogimage"]["tmp_name"], "../../images/blog/" . $_FILES["blogimage"]["name"]);

/*checking for errors*/
if ($_FILES["blogimage"]["error"] > 0) {
 echo "Apologies, an error has occurred.";
 echo "Error Code: " . $_FILES["blogimage"]["error"];
} 
 else 
{
    move_uploaded_file($_FILES["blogimage"]["tmp_name"],
        "../../images/blog/" . $_FILES["blogimage"]["name"]);
}

/*Restricting the file types to be uploaded*/
if (($_FILES["blogimage"]["type"] == "image/gif")
  || ($_FILES["blogimage"]["type"] == "image/jpeg")
  || ($_FILES["blogimage"]["type"] == "image/png" ) 
  && ($_FILES["blogimage"]["size"] < 100000)
) {
 move_uploaded_file($_FILES["blogimage"]["tmp_name"],
"../../images/blog/" . $_FILES["blogimage"]["name"]);
echo "<h1>File upload successful</h1>";

  } else {
    echo "Files must be either JPEG, GIF, or PNG and less than 10,000 kb";
  }




/*

$add_data = mysql_query("INSERT INTO user ('id','national_id', 'photo','first_name', 'last_name', 'age', 'sex', 'tribe', 'nationality', 'skincolor', 'eyecolor', 'height', 'weight', 'address', 'occupation') VALUES('', '$nrc', '$photo', '$fname', '$lname', '$age', '$sex', '$tribe', '$nationality', '$skincolor', '$eyecolor', '$height', '$weight', '$address', '$occupation')");*/


  $add_data = mysqli_query($db, "INSERT INTO blog VALUES ('', '$blogtitle','$blogcontent', '$blogsource', '$date', '$blogimage_name', '$featured', '$blogurl', '$rsstitle', '$rsssummary')");
echo $add_data;
}




?>

<html>
<head>
 <title>Blue Waves Technologies | Create New Blog</title>
 <meta http-equiv="content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="shortcut icon" href="../../favicon.ico" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="js/tinymce.min.js"></script>
<script type="text/javascript" src="js/jquery.tinymce.min.js"></script>
<script language="javascript" type="text/javascript">

      tinymce.init({ selector:"textarea", plugins: "image, link",
      image_advtab: true,  

   setup: function (editor) {
    editor.on('change', function () {
        editor.save();
    });
  }
   });


</script>
</head>
<body>
  <!--wrapper around the input fields-->
  <div id="wrapper_all1">
    <div id="nav-bar">
        <div id="nav">
            <a href="home.php">Home</a>
            <a href="add_data.php">Creat Blog</a>
            <a href="home.php">Search Inmate</a>
            <a class="logout" href="logout.php">Logout</a>
        </div>
    </div>
<div id="date-time">
<?php echo date("Y/m/d");?>
 &nbsp
    <?php echo date("h : i : s a"); ?>
</div>




 <center>
   <form enctype="multipart/form-data" action="add_data.php" method="POST">

    <table>
       <tr>
        <td  style="padding-right: 20px; padding-top:15px; padding-bottom: 20px;"><label>Blog Image</label></td>
        <td><input type="file" name="blogimage" id="data_field" size="50" required="" /><br>
        <label style="color: red">Image format: jpeg, jpg, png, gif</label>
        </td>
    </tr>

    <tr>
        <td  style="padding-right: 20px; padding-top:15px; padding-bottom: 20px;"><label>Blog Title</label></td>
        <td><input type="text" name="blogtitle" id="data_field" size="50" required="" placeholder="Article title"/></td>
    </tr>
    <tr>
        <td  style="padding-right: 20px; padding-top:15px; padding-bottom: 20px;"><label>Rss Title</label></td>
        <td><input type="text" name="rsstitle" id="data_field" size="50" required="" placeholder="Same as Blog Title"/></td>
    </tr>
    <tr>
        <td  style="padding-right: 20px; padding-top:15px; padding-bottom: 20px;"><label>Blog Url</label></td>
        <td><input type="text" name="blogurl" id="data_field1" size="50" required="" placeholder="Blog Title with hyphen (-) inbetween"/><br>
            </td>
            <br>
    </tr>

    <tr>
        <td  style="padding-right: 20px; padding-top:15px; padding-bottom: 20px;"><label>Blog Source</label></td>
        <td><input type="text" name="blogsource" id="data_field" size="50" required="" placeholder="Eg. peacefmonline.com"/><br>
        </td>
    </tr>
    <tr>
        <td  style="padding-right: 20px; padding-top:15px; padding-bottom: 20px;"><label>Rss Summary</label></td>
        <td><textarea name="rsssummary" type="text" id="data_field" rows="7" cols="50" required="" placeholder="First few lines of the article"></textarea><br>
        </td>
    </tr>
    <tr>
        <td  style="padding-right: 20px; padding-top:15px; padding-bottom: 20px;"><label>Blog Content</label></td>
        <td><textarea name="blogcontent" type="text" id="data_field" rows="10" cols="100" required="" placeholder="Main article goes here"></textarea><br></td>
    </tr>

    <tr>
        <td  style="padding-right: 20px; padding-top:15px; padding-bottom: 20px;"><label>Featured</label></td>
        <td><select name="featured">
            <option value=""></option>
            <option value="1">1</option>

        </select><br>
        <label style="color: red">Select 1 to make it a featured post</label></td>
    </tr>

</table>
<div id="submitdatabutt">
    <input type="submit" name="submit" value="Submit data"/>
</div>

</form>

    

提前谢谢。

0 个答案:

没有答案