<?php
if(isset($_POST['btn-signup'])) {
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "test";
$conn = new mysqli($servername, $username, $password, $dbname);
if($conn->connect_error)
{
die("Connection failed :" . $conn->connect_error);
}
$uname = trim($_POST['uname']);
$email = trim($_POST['email']);
$upass = trim($_POST['pass']);
$mobile = trim($_POST['mobile']);
$fee = trim($_POST['fee']);
$uname = strip_tags($uname);
$email = strip_tags($email);
$upass = strip_tags($upass);
$mobile = strip_tags($mobile);
$fee = strip_tags($fee);
$role = "user";
// check email exist or not
$query = "SELECT email FROM users WHERE email='$email'";
$result = mysqli_query($query);
$count = mysqli_num_rows($result); // if email not found then proceed
if ($count==0) {
$query = "INSERT INTO users(username,email,password,mobile,fee,role) VALUES('$uname','$email','$upass','$mobile','$fee','$role')";
$res = mysqli_query($query);
if ($res) {
$errTyp = "success";
$errMSG = "successfully registered, you may login now";
} else {
$errTyp = "danger";
$errMSG = "Something went wrong, try again later..." .mysql_error();
}
} else {
$errTyp = "warning";
$errMSG = "Sorry Email already in use ...";
}
mysqli_close($conn);
}
?>私はどのユーザー登録で管理パネルを作成しましたが、それは常に私が送信ボタンをクリックしたときに何かが、それは常に私さえ「何かが間違ってエラーを行ってきました」私を与える誤ったエラーメッセージ
を行ってきました、私を示します「申し訳ありませんメールは既に使用中です。」というエラーを確認しますが、「何か問題が発生しました」と表示されます。 私もセッションを使用しています。私はPHPで初心者であり、管理者や学生などの異なる役割のためのセッションベースのログインシステムを作成しています。 できるだけ早く私に解決策をお願いします:)をありがとう
コード内のエラーをチェックしないのはなぜですか?もしあなたが何が間違っていたのか分かっていたなら:['mysql_error()'](http://php.net/manual/en/function.mysql-error.php) –
それはshwoingエラーを起こしました。私はmysql_error()を使用していますが、私はすでにdbnameに言及しています。今何をすべきか? –
[PHPでMySQL APIを混在させることはできますか?](0120-338-331) – Epodax