허용되지 않습니다 그것이 내가 다음과 같은 오류 얻을 데이터베이스에 양식 내용을 제출하려고하면 제가 아파치를 실행하는 드림위버 CC 2017 XAMPP의 v3.2.2을 사용하고 {"code":"MethodNotAllowedError","message":"POST is not allowed"}
PHP : POST 오류
및 윈도우 10에서 MySQL
HTML 양식 :
<form action="register.php" id="form1" name="form1" method="post">
및 register.php 내용은 다음과 같습니다
<?php
$hostname_conn = "localhost";
$database_conn = "hotels";
$username_conn = "root";
$password_conn = "";
$conn = mysqli_connect($hostname_conn, $username_conn, $password_conn) or trigger_error(mysqli_error(),E_USER_ERROR);
$db=mysqli_select_db($conn,$database_conn);
$q1= "insert into users(username,email,password,number)values('$_POST[textfield]','$_POST[email]','$_POST[password]','$_POST[number]')";
$q2=mysqli_query($conn,$q1);
if(mysqli_query($conn,$q1))
{
$msg = 'User information saved successfully.';
}
else
{
$msg = 'Error: We encountered an error while inserting the new record.';
}
echo $msg;
mysqli_close($conn);
?>
</body>
</html>
,
귀하의 코드에 취약 [** SQL 주입 공격 **] (https://en.wikipedia.org/wiki/SQL_injection). [** mysqli **] (https://secure.php.net/manual/en/mysqli.prepare.php) 또는 [** PDO **] (https://secure.php.net/)를 사용해야합니다. manual/en/pdo.prepared-statements.php) [** this post **] (https://stackoverflow.com/questions/60174/how-can-i-prevent-sql)에 설명 된 바운드 매개 변수가있는 준비된 문 - 인젝션 - 인 - php). –
** 일반 텍스트 비밀번호는 저장하지 마십시오 **. ['password_hash()'] (http://us3.php.net/manual/en/function.password-hash.php)와 ['password_verify()'] (http : //us3.php. net/manual/ko/function.password-verify.php)를 사용하십시오. –
https://www.w3schools.com/php/php_mysql_prepared_statements.asp – b2ok