2013-10-29 73 views
-1

我試圖讓我的表單正常工作,但如果我發佈我的表單數據,它只是刷新網站。我登錄時應該隱藏登錄表單,但這種情況也沒有發生。表單沒有正確響應php函數

更新: 仍然無法正常工作,我把這個值放在URL中,但是我不認爲它對這個函數有反應。

如果任何人有teamviewer,並希望通過聊天/旁觀幫助我解決這個問題會容易得多。 REMOTE ID:532 027 730 PASS:vsu868

我很想爲那些可以幫助我做的東西回來,我是一個平面設計師,所以我可以幫忙帶回來任何圖形的需求。

謝謝。

這是代碼現在:

if($_POST['submit']){ 
    $gbn = sha1($_POST['gbn']); 
    $ww = sha1($_POST['ww']); 
    if(!$gbn || !$ww){ 
     // Check if no data is sent. if true, message the error. 
     echo "<span style='color:#F04A60;'>Geen gegevens ingevuld, probeer opnieuw.</span>"; 
     /*echo "<script type='text/javascript'>document.location.href='../products.php';</script>";*/ 
    }else{ 
     // Check if username exists in database. 
     $res = mysql_query("SELECT * FROM customers WHERE gbn = '".$gbn."'"); 
     $num = mysql_num_rows($res); 

     if($num == 0){ 
      // Message Error 
      echo "<span style='color:#F04A60;'>Gebruikersnaam onjuist, probeer opnieuw.</span>"; 
      /*echo "<script type='text/javascript'>document.location.href='../products.php';</script>";*/ 
     }else{ 

      // We have a match! 
      // Check if there is match between the username and password in the Database. 
      $res = mysql_query("SELECT * FROM `customers` WHERE `username` = '".$gbn."' AND `password` = '".$ww."'"); 
      $num = mysql_num_rows($res); 

      if($num == 0){ 
       // Message Error 
       echo "<span style='color:#F04A60;'>Wachtwoord onjuist, probeer opnieuw.</span>"; 
      /* echo "<script type='text/javascript'>document.location.href='../products.php';</script>";*/ 
      }else{ 
       //if there was continue checking 
       //split all fields fom the correct row into an associative array 
       $row = mysql_fetch_assoc($res); 
       $_SESSION['uid'] = $row['id']; 
       //show message 
       echo "<script type='text/javascript'>document.location.href='../products.php?u=" . $gbn . "';</script>"; 
       //if they have log them in 
       //set the login session storing there id - we use this to see if they are logged in 
      } 
     } 
    } 
} 

if(isset($_SESSION['uid'])){ 
    echo "Welcome $gbn, klik <a href='shoppingcart.php'>hier</a> om naar uw winkelwagen te gaan"; 
    } 
    else{ 
    ?> 
    <!-- LOG IN DIV--> 
     <div id="login"> 
      <form name="form2" methode="POST" action=""> 
       <h2>Log in</h2> 
       <div> 
        <input type="text" placeholder="Username" required="" id="gbn" /> 
       </div> 
       <div> 
        <input type="password" placeholder="Password" required="" id="ww" /> 
       </div> 
       <div> 
        <input class="button" type="submit" value="log In" /> 
        <a href="passwordhelp.php">Lost your password?</a> 
        <a href="register.php">Register</a> 
       </div> 
      </form><!-- form --> 
     </div> 
    <?php 
     } 
    ?> 

回答

2

要調用與名稱的$ _ POST 「提交」,但你的按鈕沒有名字

試試這個

<input class="button" type="submit" name="submit" value="log In" />