<?php
//@include 'config.php';
if(isset($_POST['submit'])){
$name = $_POST['name'];
$email = $_POST['email'];
$maxn = $_POST['ma'];
$pass = $_POST['password'];
$cpass = $_POST['cpassword'];
$kt=0;
$filename = "pass.php";
if (file_exists($filename)) {
$fp = fopen($filename, "r"); //m? file ? ch? ?? ??c
$line = file($filename); //gan tat ca dong trong file vao mang $line
if($maxn=='ok'){
for ($row = 0; $row < (int)count($line) ; $row++){
//echo $mail."<br>";
//echo explode("nhc",$line[$row])[2]."<br>";
if(trim(strval($email)) == trim(strval(str_replace(' ','',(explode("nhc",$line[$row])[2])))))
{
echo '<script type="text/javascript">
window.onload = function () { alert("B?n ch?a ??ng ký ???c, Mail ?ã t?n t?i hãy ch?n mail khác"); }
</script>'; $kt++; break;
}
}
if($kt==0){
$fp1 = fopen($filename, 'a');//m? file ? ch? ?? write-only
date_default_timezone_set('Asia/Ho_Chi_Minh');
$date = date('d-m-y h:i:s');
$data = "qe nhc $name nhc $email nhc $pass nhc $maxn nhc $date\n";
fwrite($fp1, $data);
echo '<script type="text/javascript">
window.onload = function () { alert("B?n ?ã t?o xong User"); }
</script>';
}
}
else {echo '<script type="text/javascript">
window.onload = function () { alert("B?n ch?a ??ng ký ???c do sai mã xác nh?n LH 0985.36.54.64, mã xác nh?n là: ok "); }
</script>';}
}
fclose($fp);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>register form</title>
<!-- custom css file link -->
<link rel="stylesheet" href="style1.css">
</head>
<body>
<div class="form-container">
<form action="" method="post">
<h3>register now</h3>
<?php
if(isset($error)){
foreach($error as $error){
echo '<span class="error-msg">'.$error.'</span>';
};
};
?>
<input type="text" name="name" required placeholder="enter your name">
<input type="email" name="email" required placeholder="enter your email">
<input type="password" name="password" required placeholder="enter your password">
<input type="password" name="cpassword" required placeholder="confirm your password">
<input type="text" name="ma" required placeholder="Mã Xác Nh?n: ok">
<input type="submit" name="submit" value="register now" class="form-btn">
<p>?ã có account? <a href="login_form.php">login now</a></p>
</form>
</div>
</body>
</html>
|