간단한 등록 양식을 만들었습니다. 이 양식을 편집하여 user_id 또는 date_created 같은 것을 추가해야합니까? user_id 열을 PHPMyAdmin에 추가 할 때 사용자가 등록 할 수 없지만 'First Name'; '성'; '이메일'; 데이터베이스 내 '암호'는 모든 것이 작동합니다.php; mysql; user_id 또는 date_created를 삽입하는 방법?
<!DOCTYPE html>
<html>
<head>
<title>Registration</title>
</head>
<body>
<?php
$lclhost = "localhost";
$pass = "";
$root = "root";
$database = "regis";
$con=mysqli_connect ("$lclhost", "$root", "$pass") or die("connection fail".mysql_error());
mysqli_select_db($con, $database) or die("database fail".mysql_error());
?>
<form method="get">
First Name : <input type="text" name="fname"><br>
Last Name : <input type="text" name="lname"><br>
Email: <input type="text" name="email"><br>
Password: <input type="Password" name="password">
<input type="submit" name="btnsubmit">
</form>
<?php
if (isset($_GET['btnsubmit']))
{
$fname = $_GET['fname'];
$lname = $_GET['lname'];
$email = $_GET['email'];
$password = $_GET['password'];
$registration = "INSERT INTO tbl_info values ('".$fname."','".$lname."','".$email."','".$password."')";
mysqli_query($con,$registration);
echo "Succes!";
}
?>
</body>
</html>
자동 증가 중입니까? –
db에'user_id' 컬럼을 추가하면 코드가 단순히 값을 필요로하기 때문에 코드가 작동하지 않게됩니다. 당신이해야 할 일은 HTML 뷰에 user_id 필드를 추가하고 그것을 나머지 입력과 함께 보내는 것입니다. –
귀하의 스크립트는 [SQL Injection Attack] 위험에 있습니다. (http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php) [ 리틀 바비 테이블] (http://bobby-tables.com/) 심지어 [당신이 입력을 탈출하는 경우, 안전하지 않습니다!] (http://stackoverflow.com/questions/5741187/sql-injection-that-gets -around-mysql-real-escape-string) [준비된 매개 변수가있는 명령문] 사용 (http://php.net/manual/en/mysqli.quickstart.prepared-statements.php) – RiggsFolly