Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (isset($_POST["register"])) {
- if($_SERVER['SERVER_ADDR'] == "94.23.103.25"){
- if(!verifyFormToken('register')){
- echo'no-no';
- }else{
- if (empty($_POST["username"]) || empty($_POST["password1"]) || empty($_POST["password2"]) || empty($_POST["fullname"]) || empty($_POST["address"]) || empty($_POST["email"]) || !isset($_POST['check'])) {
- echo "Minden mező kitöltése kötelező.";
- return;
- }
- if (!isset($_POST["username"]) && !isset($_POST["password1"]) && !isset($_POST["password2"]) && !isset($_POST["fullname"]) && !isset($_POST["address"]) && !isset($_POST["email"]) && !isset($_POST['check'])) { return; }
- if ($_POST["password1"] == $_POST["password2"]){
- $connection = new Database;
- $stmt1 = $connection->pdo->prepare("SELECT * FROM users WHERE username = :username");
- $stmt1->bindParam(":username", clean_input($_POST["username"]));
- $stmt1->execute();
- $stmt1 = $connection->pdo->prepare("SELECT * FROM users WHERE email = :email");
- $stmt1->bindParam(":email", clean_input($_POST["email"]));
- $stmt1->execute();
- if ($stmt1->rowCount() == 0) {
- $stmt = $connection->pdo->prepare("INSERT INTO users(username, password, fullname, address, email, ip, credits) VALUES(:username, :password, :fullname, :address, :email, :ip, 0)");
- $pass = sha1(clean_input($_POST["password1"]));
- $stmt->bindParam(":username", clean_input($_POST["username"]));
- $stmt->bindParam(":password", $pass);
- $stmt->bindParam(":fullname", clean_input($_POST["fullname"]));
- $stmt->bindParam(":address", clean_input($_POST["address"]));
- $stmt->bindParam(":email", clean_input($_POST["email"]));
- $stmt->bindParam(":ip", $_SERVER["REMOTE_ADDR"]);
- $stmt->execute();
- echo "<center><label class='alert alert-success'>Sikeres regisztráció.</label></center>";
- header( "Refresh:5; url=index.php", true, 303);
- } else {
- echo "<center><label class='alert alert-danger'>Ez a Felhasználónév, vagy Email cím foglalt!</label></center>";
- header( "Refresh:2; url=reg.php", true, 303);
- }
- }else{
- echo "<center><label class='alert alert-danger'>A két jelszó nem egyezik.</label></center>";
- header( "Refresh:2; url=reg.php", true, 303);
- }
- }
- }
- }
- $newToken = generateFormToken('register');
- //Felül validáljuk alul generálunk, így fut le a kód is felülről lefelé.
- //valahol meg ezalatt a form ahol <?php echo $newToken; ? >
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement