모든 이름이 데이터베이스와 동일하지만 데이터베이스에 요소를 추가하지는 않았습니다. 무엇이 문제일까요?내 가입 양식이 데이터베이스에 응답하지 않습니다. 뭐가 문제 야?
<div class="form_div" required>
<p class="form_label">Not a customer? Signup Here!</p>
<form method="Post" action="Register.php" required>
<p><input type="text" name="name" placeholder="Name and Last Name" required></p>
<p><input type="text" name="Email" placeholder="Email Address" required></p>
<p><input type="text" name="Phone" placeholder="Your Phone Number" required></p>
<p><input type="password" name="password" placeholder="**********" required></p>
<p><input type="submit" name="submit" value="SIGNUP"> </p>
<?php
//Fill out the following fields to be able to register.
if(isset($_POST['submit'])) {
$nameandlast= $_POST['name'];
$Email= $_POST['Email'];
$Phone= $_POST['Phone'];
$password= $_POST['password'];
//Inserts customer details into the customer table in the SQL database so they can schedule appointments and login later. If the registration have been added successfully, display a success message.
$query = "INSERT INTO customers (name, email, phone, pass) VALUES ('{$nameandlast}','{$Email}','{$Phone}','{$password}');";
runQuery($query);
echo "You have been successfully registered";
// If the customer is succesfully registered, redirect him so he can log in.
header('Location: Login.php');
}
?>
'runQuery'의 기능은 무엇입니까? SQL 인젝션에 대해 열려 있습니다. 암호는 해쉬되어야합니다. 귀하의 코드가 쿼리 작업을 가정하고 로그인 페이지로 사용자를 리디렉션하는 것처럼 보입니다. 리디렉션은 이미 출력을 전송했기 때문에 작동하지 않습니다. – chris85
입력을 필터링해야합니다! 준비된 명령문을 사용하여 사용자 데이터를 db에 삽입하십시오. 안전한 것은 없으며, 항상 확인/테스트하십시오! 시작하려면 https://www.w3schools.com/php/php_mysql_prepared_statements.asp를 참조하십시오. – Chad