2017-01-24 16 views
0

私のPHPログインフォームが動作しない、私は問題を見つけることができません。 私はphpで固定値のSQLクエリをテストし、(ボタンなしで)動作します。 私の推測は、その送信ボタンです。phpログインフォームの送信ボタンが機能しない

データベースは正常に動作しますが、アイテムを選択できますが、送信フォームでデータを挿入することはできません。列フィールドcity, street, address, zipcode))に)余分ここ

$query = "INSERT into php_users_login (email, password, name, phone, student, city, street, address, zipcode)) VALUES ('$email', '$password)', '$name', '$telefoon', '$student', '$city','$street','$address','$zipcode')"; 

と別のはおそらくそれが挿入する上で問題だったVALUES ('$email', $password)自分の価値観である -

<?php 

session_name('LoginForm'); 
@session_start(); 

error_reporting(0); 
include("config.php"); 

?> 


<!DOCTYPE html> 
<!--[if lt IE 7]>  <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]--> 
<!--[if IE 7]>   <html class="no-js lt-ie9 lt-ie8"> <![endif]--> 
<!--[if IE 8]>   <html class="no-js lt-ie9"> <![endif]--> 
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]--> 
<head> 
     <?php include_once("analyticstracking.php"); ?> 
     <meta charset="utf-8"> 
     <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
     <title>test</title> 
     <meta name="description" content=""> 
     <meta name="viewport" content="width=device-width, initial-scale=1"> 

     <link rel="apple-touch-icon" sizes="57x57" href="/img/apple-icon-57x57.png"> 
     <link rel="apple-touch-icon" sizes="60x60" href="/img/apple-icon-60x60.png"> 
     <link rel="apple-touch-icon" sizes="72x72" href="/img/apple-icon-72x72.png"> 
     <link rel="apple-touch-icon" sizes="76x76" href="/img/apple-icon-76x76.png"> 
     <link rel="apple-touch-icon" sizes="114x114" href="/img/apple-icon-114x114.png"> 
     <link rel="apple-touch-icon" sizes="120x120" href="/img/apple-icon-120x120.png"> 
     <link rel="apple-touch-icon" sizes="144x144" href="/img/apple-icon-144x144.png"> 
     <link rel="apple-touch-icon" sizes="152x152" href="/img/apple-icon-152x152.png"> 
     <link rel="apple-touch-icon" sizes="180x180" href="/img/apple-icon-180x180.png"> 
     <link rel="icon" type="image/png" sizes="192x192" href="/img/android-icon-192x192.png"> 
     <link rel="icon" type="image/png" sizes="32x32" href="/img/favicon-32x32.png"> 
     <link rel="icon" type="image/png" sizes="96x96" href="/img/favicon-96x96.png"> 
     <link rel="icon" type="image/png" sizes="16x16" href="/img/favicon-16x16.png"> 
     <link rel="manifest" href="/img/manifest.json"> 
     <meta name="msapplication-TileColor" content="#ffffff"> 
     <meta name="msapplication-TileImage" content="/img/ms-icon-144x144.png"> 
     <meta name="theme-color" content="#ffffff"> 


     <!-- Place favicon.ico and apple-touch-icon.png in the root directory --> 

     <link rel="stylesheet" href="css/main.css"> 
     <link href='http://fonts.googleapis.com/css?family=Roboto:400,300,500' rel='stylesheet' type='text/css'> 
     <link href="//netdna.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet"> 
     <script src="js/jquery-1.8.2.min.js"></script> 
     <script src="js/jquery.validate.min.js"></script> 
     <script src="js/main.js"></script> 




    </head> 
    <body> 

      <div id="login-form" class="login-form" name="form1"> 
       <ul> 
         <li><a class="active" href="index.php">Home</a></li> 
         <li><a href="register.php">register</a></li> 
       </ul> 

       <?php 
        $servername = "localhost"; 
        $username = "root"; 
        $password = ""; 
        $dbname = "test"; 

        // Create connection 
        $conn = mysqli_connect($servername, $username, $password, $dbname); 
        // Check connection 
        if (!$conn) { 
         die("Connection failed: " . mysqli_connect_error()); 
        } 
       // If form submitted, insert values into the database. 
        if (isset($_POST['submit'])) { 
         $email = $_POST['email'];     
         $password = $_POST['password'];     
         $name = $_POST['name'];     
         $phone = $_POST['phone'];    
         $student =$_POST['student'];          
         $city = $_POST['city'];          
         $street = $_POST['street'];           
         $address = $_POST['address'];          
         $zipcode = $_POST['zipcode']; 


         $password = mysqli_real_escape_string($conn, $password);      
         $name = mysqli_real_escape_string($conn, $name);     
         $phone = mysqli_real_escape_string($conn, $phone);    
         $student = mysqli_real_escape_string($conn, $student);         
         $city = mysqli_real_escape_string($conn, $city);          
         $street = mysqli_real_escape_string($conn, $street);           
         $address = mysqli_real_escape_string($conn, $address);         
         $zipcode = mysqli_real_escape_string($conn, $zipcode); 


         $query = "INSERT into php_users_login (email, password, name, phone, student, city, street, address, zipcode)) VALUES ('$email', '$password)', '$name', '$telefoon', '$student', '$city','$street','$address','$zipcode')"; 
         $result = mysqli_query($conn,$query); 
         if ($res) { 
          $errTyp = "success"; 
          $errMSG = "Successfully registered, you may login now"; 
          unset($name); 
          unset($email); 
          unset($pass); 
          } else { 
          $errTyp = "danger"; 
          $errMSG = "Something went wrong, try again later..."; 
          } 
        } 
       ?> 
       <div class="form-content" > 
       <h1>Registreren</h1> 
       <form name="registration" action="" method="post"> 
       <table> 
       <tr> 
        <td>E-mail</td> 
        <td><input type="email" name="email" placeholder="E-mail" required /></td> 
       </tr> 
       <tr> 
        <td>password:</td> 
        <td><input type="password" name="password" placeholder="password" required /></td> 
       </tr> 
       <tr> 
        <td>name:</td> 
        <td><input type="name" name="name" placeholder="name" required /></td> 
       </tr> 
       <tr> 
        <td>phone:</td> 
        <td><input type="phone" name="phone" placeholder="phone" required /></td> 
       </tr> 
       <tr> 
        <td>Student:</td> 
        <td><input type="student" name="student" placeholder="student" required /></td> 
       </tr> 
       <tr> 
        <td>city:</td> 
        <td><input type="city" name="city" placeholder="city" required /></td> 
       </tr> 
       <tr> 
        <td>street:</td> 
        <td><input type="street" name="street" placeholder="street" required /></td> 
       </tr> 
       <tr> 
        <td>address:</td> 
        <td><input type="address" name="address" placeholder="address" required /></td> 
       </tr> 
       <tr> 
        <td>zipcode:</td> 
        <td><input type="zipcode" name="zipcode" placeholder="zipcode" required /></td> 
       </tr> 
       <tr> 
        <td></td> 
        <td><button type="submit" class="submit" name="submit">Register</button></td> 
       </tr> 
       </table> 
       </form> 
       </div> 



      </div> 
    </body> 
</html> 
+0

ここにエラーを貼り付けてください –

+0

$ queryをエコーし​​てからこのクエリをコピーしてください。 phpmyadminに貼り付けて実行してください。エラーをコピーして、ここに貼り付けます。 – Shubhranshu

+0

print_r($ _ POST)を試してください。どのような壺が渡されているか見ることができます。また、私は送信ボタンが名前を必要としないと思う、タイプは十分です。 –

答えて

1

あなたのコードがあります。余分な中かっこを削除するか、次のコードを試してください。 -

$query = "INSERT into php_users_login (email, password, name, phone, student, city, street, address, zipcode) VALUES ('$email', '$password', '$name', '$telefoon', '$student', '$city','$street','$address','$zipcode')" 
0

@Mdと同様です。 データベースエラーです。データベースエラーはPHPコードでは表示されません。 try {} catch(){}

関連する問題