データベースにフォームを挿入しようとすると、コードにエラーが見つかりました...
SQL 構文にエラーがあります。2行目のnear ''を使用する正しい構文については、MySQLサーバーのバージョンに対応するマニュアルを確認してください
形:
<div class="form">
<form id="contactform" method="POST" action="">
<p class="contact"><label for="name">Name</label></p>
<input id="name" name="name" placeholder="First and last name" required="" tabindex="1" type="text" value="<?php echo $name;?>">
<p class="contact"><label for="email">Email</label></p>
<input id="email" name="email" placeholder="example@domain.com" required="" type="email" value="<?php echo $email;?>">
<p class="contact"><label for="username">Create a username</label></p>
<input id="username" name="username" placeholder="username" required="" tabindex="2" type="text" value="<?php echo $username;?>">
<p class="contact"><label for="password">Create a password</label></p>
<input type="password" id="password" name="password" required="" placeholder="Set password">
<p class="contact"><label for="repassword">Confirm your password</label></p>
<input type="password" id="repassword" name="repassword" required="" placeholder="Confirm password"> </br>
<label>Birthday</label></br>
<select class="select-style" name="birthMonth" >
<option value="" class="nothing">Month</option>
<option value="01">January</option>
<option value="02">February</option>
<option value="03" >March</option>
<option value="04">April</option>
<option value="05">May</option>
<option value="06">June</option>
<option value="07">July</option>
<option value="08">August</option>
<option value="09">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12" >December</option>
</select>
<select class="select-style" name="birthDay" required="">
<option value="" class="nothing">Day</option>
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
<input class="birthyear" maxlength="4" name="birthYear" placeholder="Year" required="" value="<?php echo $birthYear;?>">
</br>
<label>Gender</label>
<select class="select-style" style="width:400px;" name="gender" >
<option class="nothing" value="select">i am..</option>
<option value="male">Male</option>
<option value="female">Female</option>
<option value="others">Other</option>
</select><br><br>
<input class="buttom" name="submit" id="submit" tabindex="5" value="Sign me up!*" type="submit">
<font style="color:white; size:10px; background-color:black"> * - By clicking on "Sign me up" button, you completly agree with <a href="#terms-box" class="terms-window"><u>Terms & Conditions of use</u></a> .</font>
検証:
if(isset($_POST['submit'])){
//VARIABLES
$name = $_POST['name'];
$email = $_POST['email'];
$username = $_POST['username'];
$password = $_POST['password'];
$confPass = $_POST['repassword'];
$birthDay = $_POST['birthDay'];
$birthMonth = $_POST['birthMonth'];
$birthYear = $_POST['birthYear'];
$gender = $_POST['gender'];
$type = 'user';
$birthday = date($birthDay."/".$birthMonth."/".$birthYear);
$date0 = mktime(0,0,0,date("m"),date("d"),date("Y"));
$today = date("Y/m/d", $date0);
echo '<script type="text/javascript">','hideTerms();','</script>';
if(strlen($password) < 5 or $password != $confPass){
echo "<span id='abouTitle'> Something wrong..</span>";
echo "<script type='text/javascript'> alert('Password too small or different');</script>";
}else{
echo "<span id='abouTitle'>Bem-Vindo, ".$username."!</span></br></br>";
echo '<font style="color:white; font-size:20px;"';
echo 'Name: '.$name.'</br>Email: '.$email.'</br>Username: '.$username.'</br>Password: <u>-Check your email-</u> </br>Birthday: '.$birthday.'</br>Gender: '.$gender.'</br>Account type: '.$type.'</br>Account Creation Day: '.$today.'</br>';
include ('php/content/connect.php');
$sql = mysql_query("INSERT INTO users (name, email, username, password, /*birthday,*/ gender, accountType/*, creationDate*/)
VALUES ( '$name', '$email', '$username', '$password',/*STR_TO_DATE('$birthYear,$birthMonth,$birthDay','%Y,%m,%d'),*/ '$gender', '$type'/*, '$today'*/") or die(mysql_error());
$data = mysql_query($sql);
$termina = mysql_close($conexao);
}
}else{
$name = "";
$email = "";
$birthYear ="";
$username = "";
}echo '</font>';
?>