2017-01-08 1 views
-3

Ich habe mir eine Stunde lang den Kopf kratzt und kann nicht herausfinden, warum PHP meine Formularwerte nicht posten.PHP Poste meine Formularwerte nicht

-Code

 <!-- Login --> 
     <div class="login__block toggled" id="l-login"> 
      <div class="login__block__header"> 
       <i class="zmdi zmdi-account-circle"></i> 
       Hi there! Please Sign in 

       <div class="actions login__block__actions"> 
        <div class="dropdown"> 
         <a href="#" data-toggle="dropdown"><i class="zmdi zmdi-more-vert"></i></a> 

         <ul class="dropdown-menu pull-right"> 
          <li><a data-block="#l-register" href="#">Create an account</a></li> 
          <li><a data-block="#l-forget-password" href="#">Forgot password?</a></li> 
         </ul> 
        </div> 
       </div> 
      </div> 

      <div class="login__block__body"> 
       <div class="form-group form-group--float form-group--centered form-group--centered"> 
        <input type="text" class="form-control" name="email"> 
        <label>Email Address</label> 
        <i class="form-group__bar"></i> 
       </div> 

       <div class="form-group form-group--float form-group--centered form-group--centered"> 
        <input type="password" class="form-control" name="password"> 
        <label>Password</label> 
        <i class="form-group__bar"></i> 
       </div> 

       <button type="submit" class="btn btn--light btn--icon m-t-15"><i class="zmdi zmdi-long-arrow-right"></i></button> 
      </div> 
      <?php 
      if(isset($_POST['login'])) { 
       if(isset($_POST['email']) && isset($_POST['password']) && 
       is_string($_POST['email']) && is_string($_POST['password']) && 
       !empty($_POST['email']) && !empty($_POST['password'])) { 
        $email = stripslashes(strip_tags($_POST['email'])); 
        $password = md5($_POST['password']); 

        $stmt = $pdo->prepare('SELECT * FROM users WHERE UserEmail = :UserEmail'); 
        $stmt->bindParam(':UserEmail', $email); 
        $stmt->execute(); 

        if($stmt->rowCount() > 0) { 
         $stmt = $pdo->prepare('SELECT * FROM users WHERE UserEmail = :UserEmail AND UserPassword = :UserPassword'); 
         $stmt->execute(array(':UserEmail' => $email, ':UserPassword' => $password)); 

         if($stmt->rowCount() > 0) { 
          $row = $stmt->fetch(); 
          $UserLevel = $row['UserLevel']; 

          if($UserLevel == 'banned') { 
           $display->ReturnError('Your account has been suspended.'); 
           return false; 
          } 
          $UserID = $row['UserID']; 
          $time = time(); 
          $IPAddress = $_SERVER['REMOTE_ADDR']; 

          $_SESSION['auth'] = $UserID; 

          $stmt = $pdo->prepare('INSERT INTO logs (LogUserID, LogDate, LogIPAddress) VALUES (:LogUserID, :LogDate, :LogIPAddress)'); 
          $stmt->execute(array(':LogUserID' => $UserID, ':LogDate' => $time, ':LogIPAddress' => $IPAddress)); 

          $display->ReturnSuccess('You was successfully logged in.'); 
          $settings->forceRedirect('index.php', 2); 
         } else { 
          $display->ReturnError('Invalid user credentials.'); 
         } 
        } else { 
         $display->ReturnError('User with these credentials does not exists.'); 
        } 
       } 
      } 
     ?> 
     </div> 

Bitte beachte, dass ich sehr neu in PHP bin und es würde die Welt für mich bedeuten, wenn Sie mir helfen können! Vielen Dank.

+2

Sie haben kein "" -Tag. Tatsächlich fehlen Ihnen viele grundlegende Tags. Ist das dein ganzer Code? –

+0

Wo ich bin fehlt das Formular Tag? @JohnConde – Jack

+0

Die Elemente der Form sollten in einem '' Tag eingeschlossen werden. –

Antwort

1

Schaltfläche "Senden" funktioniert nur, wenn sie sich innerhalb des Form-Tags befindet. Ihr Code hat keine Tag-Form Versuchen Sie, diese

<form action="" > 
     <!-- Login --> 
     <!--your code here --> 
    </form> 
0

Form hinzufügen Attribute wie diese

<div class="login__block__body"> 
    <form action="url which will process form" method="POST"> 
       <div class="form-group form-group--float form-group--centered form-group--centered"> 
        <input type="text" class="form-control" name="email"> 
        <label>Email Address</label> 
        <i class="form-group__bar"></i> 
       </div> 

       <div class="form-group form-group--float form-group--centered form-group--centered"> 
        <input type="password" class="form-control" name="password"> 
        <label>Password</label> 
        <i class="form-group__bar"></i> 
       </div> 

       <button type="submit" class="btn btn--light btn--icon m-t-15"><i class="zmdi zmdi-long-arrow-right"></i></button> 
    </form> 

      </div> 
+0

bitte dick meine Antwort, wenn es hilft –

0

Alle <input>-Tags innerhalb der <form>-Tags sein muss.

<form action="" method="post"> //Submits form to same page 
<input/> 
<input/> 
<button type="submit" class="btn btn--light btn--icon m-t-15"><i class="zmdi zmdi-long-arrow-right"></i></button> 
</form> 

Wenn Sie dieses Formular „Eintragen“, wird es alle Eingangswerte innerhalb des Form-Post, die Sie von den $_POST['name_of_input'] Variablen abrufen

Ich empfehle HTML lernen, bevor PHP würde.

Verwandte Themen