<?php
$hostname="It is in correctly";
$username="It is in correctly";
$password="It is in correctly";
$dbname="It is in correctly";
$db_conx = mysqli_connect($hostname, $username, $password) OR DIE ("Unable to
connect to database! Please try again later.");
if(mysqli_connect_errno()){
echo mysqli_connect_error();
exit();
}
$select = mysqli_select_db($db_conx,$dbname);
$firstname= $_POST["first_name"];
$lastname= $_POST["last_name"];
$email= $_POST["email"];
$password= $_POST["password"];
$gender= $_POST["gender"];
mysqli_query($db_conx,"INSERT INTO users (firstname, lastname, email, password, gender)
VALUES ($firstname, $lastname, $email, $password, $gender)");
mysqli_close($db_conx);
?>
<form method="POST" name="signup" action="php/signup_script.php">
<label for="first name"></label>
<input id="first name" name="first_name" placeholder="First Name" type="text" />
<label for="last_name"></label>
<input id="last name" name="last_name" placeholder="Last Name" type="text" />
<br><br><label for="email">
</label><input id="email" name="email" placeholder="Email" type="email" />
<label for="password"></label><input id="password" name="password" placeholder="Create Password" type="password" />
<label for="male"><strong>Male</strong></label>
<input id="male" value="Male" name="gender" type="radio" />
<label for="female"><strong>Female</strong>
</la... <input id="female" value="Female" name="gender" type="radio" />
<label for="submit">"I Agree To Terms And Conditions"</label>
<input id="submit" value="Submit" type="submit" name="submit"/>
</form>
答案 0 :(得分:1)
你忘了用单引号将插入查询中的php变量括起来,纠正它。
mysqli_query($db_conx,"INSERT INTO users (firstname, lastname, email, password, gender)
VALUES ('$firstname', '$lastname', '$email', '$password', '$gender')");