| Server IP : 172.67.187.206 / Your IP : 172.71.28.156 Web Server : Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/5.6.30 System : Windows NT WIN-ECQAAA40806 6.2 build 9200 (Windows Server 2012 Standard Edition) i586 User : SYSTEM ( 0) PHP Version : 5.6.30 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /Inetpub/www/training/ |
Upload File : |
<?php
echo '<meta charset="utf-8">';
include('condb.php');
$u_name = mysqli_real_escape_string($con, $_POST["u_name"]);
$username = mysqli_real_escape_string($con, $_POST["username"]);
$password = mysqli_real_escape_string($con, $_POST["password"]);
$u_member = mysqli_real_escape_string($con, $_POST["u_member"]);
$u_school = mysqli_real_escape_string($con, $_POST["u_school"]);
$u_other = mysqli_real_escape_string($con, $_POST["u_other"]);
if (!preg_match('/^[0-9]+$/', $password)) {
echo '<script>';
echo "alert('กรุณากรอกเบอร์โทรเป็นตัวเลขเท่านั้น');";
echo "window.location='register.php';";
echo '</script>';
exit();
}
// ตรวจสอบว่ามี u_email หรือ u_tel ซ้ำในระบบหรือไม่
$check_sql = "SELECT * FROM users WHERE username = '$username' OR password = '$password' OR u_name = '$u_name'";
$check_result = mysqli_query($con, $check_sql);
$num_rows = mysqli_num_rows($check_result);
if ($num_rows > 0) {
// ถ้ามีข้อมูลซ้ำ
echo '<script>';
echo "alert('ชื่อ อีเมล หรือเบอร์โทรนี้มีอยู่ในระบบแล้ว! ไม่สามารถสมัครได้');";
echo "window.location='register.php';";
echo '</script>';
} else {
// ถ้าไม่มีข้อมูลซ้ำ ให้ทำการบันทึก
$sql = "INSERT INTO users (u_name, username, password, u_member, u_school, u_other, role)
VALUES ('$u_name', '$username', '$password', '$u_member', '$u_school', '$u_other', 'user')";
$result = mysqli_query($con, $sql);
if ($result) {
echo '<script>';
echo "alert('สมัครสมาชิกสำเร็จ กรุณาเข้าสู่ระบบ');";
echo "window.location='index.php';";
echo '</script>';
} else {
echo '<script>';
echo "alert('สมัครสมาชิกไม่สำเร็จ กรุณาสมัครอีกครั้ง');";
echo "window.location='register.php';";
echo '</script>';
}
}
mysqli_close($con);
?>