은 사용자가 웹 사이트를 만들 수있는 PHP 소프트웨어를 구입했습니다. 하지만 내가 돈을 준 사람은 가입 양식을 작성하지 않았습니다. 나는 기본적인 코딩을 할만큼 위험하다. 그러나 나는 이것이 나의 기술 수준을 넘었다 고 느낍니다. 내가 만든 양식은 mysql 데이터베이스에 잘 삽입되었지만 암호 필드가 해시가 아니기 때문에이 양식을 사용하는 새로운 사용자가 로그인 할 수있게되었습니다.암호 필드 해시하는 방법
HMTL 가입 양식 :
<form action="input.php" method="post" class="pcss3f pcss3f-type-hor">
<header>Fillout the below to join.</header>
<section class="state-normal">
<label for="">First Name</label>
<input type="text" name="first_name"/>
<i class="icon-user"></i>
</section>
<section class="state-normal">
<label for="">Last Name</label>
<input type="text" name="last_name"/>
<i class="icon-user"></i>
</section>
<section class="state-normal">
<label for="">Email</label>
<input type="email" name="email"/>
<i class="icon-envelope"></i>
</section>
<section class="state-normal">
<label for="">Password</label>
<input type="password" name="password"/>
<i class="icon-key"></i>
</section>
<footer>
<button type="button" onclick="window.location = 'index.html'">Back</button>
<button type="submit" class="color-blue">Submit</button>
</footer>
</form>
와 PHP 스크립트 :
<?php
$con = mysql_connect("localhost","name","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("instantw_builder", $con);
$sql="INSERT INTO users (first_name, last_name, username, email, password)
VALUES
('$_POST[first_name]','$_POST[last_name]','$_POST[email]','$_POST[email]','$_POST[password]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
mysql_close($con)
?>
내가 암호 필드를 해시 어떻게해야합니까?
** 위험 ** : [오래된 ** 데이터베이스 API] (http://stackoverflow.com/q/12859942/19068)를 사용하고 있으며 [modern 대체] (http://php.net/manual/en/mysqlinfo.api.choosing.php). 또한 ** [SQL 주입 공격] (http://bobby-tables.com/) **에 현대적인 API를 사용하면 쉽게 방어 할 수 있습니다 ** (http://stackoverflow.com/questions/60174/best-way-to-prevent-sql-injection-in-php)을 사용하십시오. – Quentin
PHP 설명서에는 [예제] (http://php.net/manual/en/)뿐만 아니라 [FAQ] (http://php.net/manual/en/faq.passwords.php)도 있습니다. function.password-hash.php). – Quentin
http://daveismyname.com/login-and-registration-system-with-php-bp에는 필요한 모든 것이 있습니다. * 또한, 준비된 명령문과'password_hash()'와 함께 PDO를 사용합니다. –