2016-03-22 5 views
-1


私はいくつかのPHPコードに問題があります。テスト用のWebサイトでコードを実行することができました。私は現在、ユーザーにポップアップ登録メニューを登録しようとしています。情報を入力して登録ボタンをクリックすると、何も私のデータベーステーブルに送られません。
Heres my code。情報が私のテーブルにない

<!doctype html> 
<html lang="en"> 
<head> 
    <title>untitled.com</title> 
    <meta name="description" content="">  
    <link rel="stylesheet" type="text/css" href="frontPage.css"> 
    <script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script> 
    <script src="js/general.js" type="text/javascript"> 
    </script> 
</head> 
<body> 

<h1> untitled </h1> 

<h2> description of website</h2> 

<div id="wrapper"> 
<nav id="nav"> 
    <ul id="navigation"> 
     <a class="button" href="" >Login</a>   
     <div class="popup">  
      <a href="#" class="close">CLOSE</a>   
      <form> 
       <P><span class="title">Username</span> <input name="" type="text" /></P> 
       <P><span class="title">Password</span> <input name="" type="password" /></P> 
       <P><input name="" type="button" value="Login" /></P> 
      </form>   
     </div> 
    </ul> 
</nav> 


<?php 
require('db.php'); 

if (isset($_POST['username'])){ 
$username = $_POST['username']; 
$password = $_POST['password']; 
$email = $_POST['email']; 
$city = $_POST['city']; 
$state = $_POST['state']; 
$zip = $_POST['zip']; 
$phone = $_POST['phone'];; 
$query = "INSERT into `users` (username, password, email, city, state, zip, phone) VALUES ('$username', '".md5($password)."', '$email', '$city', '$state', '$zip', '$phone')"; 
$result = mysql_query($query); 
if($result){ 
echo "<div class='form'><h3>You are registered successfully.</h3><br/>Click here to <a href='login.php'>Login</a></div>"; 
} 
}else{ 
?> 



     <a class="Regbutton" href="#" >Register</a>   
     <div class="Regpopup">  
      <a href="#" class="close">CLOSE</a>   
      <form> 
       <P><span class="title">Username</span> <input name="username" type="text" /></P> 
       <P><span class="title">Password</span> <input name="password" type="password" /></P> 
       <P><span class="title">Email</span> <input name="email" type="email" /></P> 
       <P><span class="title">City</span> <input name="city" type="text" /></P> 
       <P><span class="title">State</span> <input name="state" type="text" maxlength="2" /></P> 
       <P><span class="title">zip</span> <input name="zip" type="text" maxlength="5" /></P> 
       <P><span class="title">phone</span> <input name="phone" type="text" maxlength="15"/></P> 
       <P><input type="submit" name="submit" value="Register" /></P> 
      </form> 
    </div> 


<?php } ?> 
</body> 
</html> 
+0

あなたは= <入力された名前を記入するのを忘れて "???" ...私は、<入力名= "ユーザ名" ...と、<入力名= "パスワード" を意味... –

+0

''

現在のページに対して 'GET'リクエストを行います。フォーム処理のメソッドを定義するには、 'method'属性を使います。また、SQLインジェクションも可能です。 – chris85

+0

ありがとう!私はそれを見落としていました。私は実際にSQLインジェクションが何であるか分からない。 – Cory

答えて

2

入力フィールドから値を取得するには、フォームメソッドを定義することが重要です。例

<form action="" method="POST"> 
</form> 
+0

私はそれを修正しました。ありがとうございました!今すぐログインボタンを操作する必要があります。 – Cory

関連する問題