2013-09-01 45 views
0

我有一個問題白色表單提交。我有一個html表單,simpli不想工作。也許是我做錯了什麼,但這裏看看吧:表單操作不正常刷新

<form action="add.php" method="post" autocomplete="off"> 
    <input type="text" name="title" placeholder="Title" style="width:300px;"> 
    <select id="type" name="type"> 
     <option value="0">Matrix</option> 
      <option value="1">LoL</option> 
      <option value="2">Dota 2</option> 
    </select><br /> 
    <textarea rows="30" cols="90" placeholder="Content here" name="content"></textarea><br /> 
    <input type="submit" value="DODAJ"> 

</form> 

所以,當我點擊按鈕我也刷新頁面,但不顯示任何內容。我在本地工作,但是當我在網上上傳nothnig,只是一個空白頁面。而必須去數據庫的東西並沒有去。沒有錯誤,沒有任何東西。

有幫助嗎?

下面是該add.php頁面的完整代碼:

<?php 

include '../php/db/init.php'; 
include '../php/db/connection.php'; 
protect_page(); 
admin_protect(); 


if(isset($_SESSION['logged_in'])){ 

    if(isset($_POST['title'], $_POST['content'], $_POST['type'])){ 
     $title = $_POST['title']; 
     $content = nl2br($_POST['content']); 
     $content_short = substr($content,0, 150); 
     $type = $_POST['type']; 

     echo $type; 
     die(); 

     if(empty($title) or empty($content) or empty($type)){ 
      $error = 'Potrebno je popuniti sva polja!'; 
     } else { 

      $query = $pdo->prepare('INSERT INTO articles (article_title, article_content, article_content_short, article_timestamp, article_type) VALUES (?,?,?,?,?)'); 

      $query->bindValue(1,$title); 
      $query->bindValue(2,$content); 
      $query->bindValue(3,$content_short); 
      $query->bindValue(4,time()); 
      $query->bindValue(5,$type); 

      $query->execute(); 

      redirect('http://www.matrixgamingns.com/admin/index.php'); 

     } 
    } 
?> 

<html> 

    <head> 
     <title>Matrix Gaming Admin Panel</title> 
     <link rel="stylesheet" type="text/css" href="../css/admin.css"> 
     <link rel="stylesheet" type="text/css" href="../css/reset.css"> 
    </head> 

    <body> 

     <div id="home"> 
      <div id="wrapper"> 

       <?php include 'adminmenusidebar.php'; ?> 

       <div id="field"> 
        <h3 style="font-size:22px;">Dodaj vest</h3> 

        <?php if(isset($error)){ ?> 
         <small style="color:#aa0000"> <?php echo $error?> </small> 
        <br/> 
        <?php }?> 
        <br /> 

        <form action="add.php" method="post" autocomplete="off"> 
         <input type="text" name="title" placeholder="Title" style="width:300px;"> 
         <select id="type" name="type"> 
          <option value="0">Matrix</option> 
          <option value="1">LoL</option> 
          <option value="2">Dota 2</option> 
         </select><br /> 
         <textarea rows="30" cols="90" placeholder="Content here" name="content"></textarea><br /> 
         <input type="submit" value="DODAJ"> 
         <?php 

ini_set('display_errors','On');?> 

        </form> 

       </div> 
      </div> 
     </div> 
    </body> 

</html> 

<?php 
} else { 
      redirect('http://www.matrixgamingns.com/admin/index.php'); 
} 

?> 
+0

您的'logged_in'會話名稱未在您發佈的代碼/問題中的任何位置定義,因此如果它不存在,它將不會被設置,因爲沒有任何內容可以檢查它是否被設置。 –

+0

如果您正在獲取完全空白的頁面,通常意味着發生了致命錯誤,並且您沒有display_errors,請查看服務器錯誤日誌,或者在調試時打開php.ini文件中的display_errors。 –

+0

'looged_in'變量被定義我知道,因爲我正在訪問'我的'index.php'頁面'add.php'頁面,其中'logged_id'也被檢查。 – Vladimir

回答

1

擺脫die()echo $type;

通過包括die()功能,它會停止所有在其軌道上,就像return不之後沒有任何事情會被執行。