2017-04-20 11 views
-2

こんにちは、私はドロップダウンメニューからコードを挿入することに問題があります。値の残りの部分は完全に罰金挿入されていますが、ドロップダウンから1だけ挿入さ0ドロップダウンが機能しない、挿入するだけ0

HTML:

<form action="send_registration.php" method="post"> 

    <p> 

     <label for="username">Username:</label> 

     <input type="text" name="username" id="username"> 

    </p> 

    <p> 

     <label for="password">password:</label> 

     <input type="password" name="password" id="password"> 

    </p> 

    <p> 

     <label for="email">Email:</label> 

     <input type="text" name="email" id="email"> 

    </p> 

    <p> 


<label for="countryID">Country:</label> 
<select> 
<option name="countryID" id="countryID" value="countryID" > 
    <option value="1">"Andorra" </option> 
    <option value="2">"United Arab Emirates" </option> 
    <option value="3">"wont bore with the rest" </option> 
</option> 

</select> 

    </p> 
    <input type="submit" value="Submit"> 

</form> 

PHP:

<?php 

include('connection.php'); 
/* Attempt MySQL server connection. Assuming you are running MySQL 

server with default setting (user 'root' with no password) */ 





// Check connection 

if($conn === false){ 

    die("ERROR: Could not connect. " . mysqli_connect_error()); 

} 



// Escape user inputs for security 

$username = mysqli_real_escape_string($conn, $_REQUEST['username']); 

$password = mysqli_real_escape_string($conn, $_REQUEST['password']); 

$email = mysqli_real_escape_string($conn, $_REQUEST['email']); 
$countryID = mysqli_real_escape_string($conn, $_REQUEST['countryID']); 

$encrypt_password = md5($password); 

// attempt insert query execution 

$sql = "INSERT INTO users (username, password, email, countryID) VALUES ('$username', '$encrypt_password', '$email', '$countryID')"; 

if(mysqli_query($conn, $sql)){ 

    header("Location: login.php"); 

} else{ 

    echo "ERROR: Could not able to execute $sql. " . mysqli_error($conn); 

} 



// close connection 

mysqli_close($conn); 

?> 
+4

'md5()'はハッシュパスワードのために時代遅れです。*使用しないでください*。 PHPは[password_hash()](http://php.net/manual/en/function.password-hash.php)と[password_verify()]を提供しています(http://php.net/manual/en/function.password -verify.php)、それらを使用してください。そして、ここにいくつかの[パスワードに関する良いアイデア](https://www.owasp.org/index.php/Password_Storage_Cheat_Sheet)があります。 5.5より前のバージョンのPHPを使用している場合([互換性パックがあります])(https://github.com/ircmaxell/password_compat) –

+3

'