Php本地服务器注册

时间:2017-11-28 22:14:04

标签: php sql

我在php中注册/登录。现在我试图通过html公式注册,填写输入,我在终端接收到这个:

[Tue Nov 28 22:57:30 2017] ::1:59017 [200]: /

但我的数据库中没有任何内容。我疯了,我不明白错误:

我的dbconfig:

<?php
$config = [
  "host" => "host",
  "dbname"=>"dbname"
  "user" => "dbuser",
  "password" => "dbpassword",
];

?>

我的dbconnexion:

<?php

require_once(realpath(dirname(__FILE__))."/../config/dbconfig.php");

try {
    $pdo = new PDO('mysql:host='.$config["host"].';dbname='.$config["dbname"], $config["user"], $config["password"]);
} catch (PDOException $e) {
    print "Erreur !: " . $e->getMessage() . "<br/>";
}

最后我的index.php:

<?php

echo "<h1> BulletProof </h1>";
require './utils/dbconnexion.php';
//session_start();
?>

<form method="POST">
<label>Pseudo: <input type="text" name="nickname_register"/></label><br/>
<label>Mot de passe: <input type="password" name="password_register"/></label><br/>
<input type="submit" value="M'inscrire"/>
</form>

<?php
if(isset($_POST['nickname_register']) && !empty($_POST['nickname_register']) && isset($_POST['password_register']) && !empty($_POST['password_register'])){
    $pseudo_register = htmlspecialchars($_POST['nickname_register']);
    $password_register = htmlspecialchars($_POST['password_register']);
    $password_hash = password_hash($password_register, PASSWORD_DEFAULT);

    $q = $pdo->prepare('INSERT user (nickname, password) VALUES (:nickname, :password');
    $q->bindParam(':nickname', $nickname_register, PDO::PARAM_STR);
    $q->bindParam(':password', $password_hash, PDO::PARAM_STR);
    $register = $q->execute();

}


?>

有人可以告诉我我做错了什么吗? 我已查看了我的语法,我的sql请求,我的信息以连接数据库,但我没有看到任何错误

1 个答案:

答案 0 :(得分:1)

您忘记了应该[[1]] # A tibble: 5 x 5 gender n totalN percent cumpercent <chr> <int> <int> <dbl> <dbl> 1 female 19 19 0.218 0.218 2 hermaphrodite 1 20 0.011 0.230 3 male 62 82 0.713 0.943 4 none 2 84 0.023 0.966 5 <NA> 3 87 0.034 1.000 [[2]] # A tibble: 15 x 5 eye_color n totalN percent cumpercent <chr> <int> <int> <dbl> <dbl> 1 black 10 10 0.115 0.115 2 blue 19 29 0.218 0.333 3 blue-gray 1 30 0.011 0.345 4 brown 21 51 0.241 0.586 5 dark 1 52 0.011 0.598 6 gold 1 53 0.011 0.609 7 green, yellow 1 54 0.011 0.621 8 hazel 3 57 0.034 0.655 9 orange 8 65 0.092 0.747 10 pink 1 66 0.011 0.759 11 red 5 71 0.057 0.816 12 red, blue 1 72 0.011 0.828 13 unknown 3 75 0.034 0.862 14 white 1 76 0.011 0.874 15 yellow 11 87 0.126 1.000 的{​​{1}}语句语法:

INSERT