Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // configuration
- require("../includes/config.phhttp://pastebin.com/ab_out.php?oid=GTND423YC6AITK7LCASLYKQWFTYILK7WFTYDKZ3JCEAD6K3LCTYIPK7KC6BDEKQ7CVBIKK3EHJNCLSIZp");
- //require("../includes/helpers.php");
- //require("../vendor/library50-php-5/CS50/CS50.php");
- // if user reached page via GET (as by clicking a link or via redirect)
- if ($_SERVER["REQUEST_METHOD"] == "GET")
- {
- // else render form
- render("register_form.php", ["title" => "Register"]);
- }
- // else if user reached page via POST (as by submitting a form via POST)
- else if ($_SERVER["REQUEST_METHOD"] == "POST")
- {
- if (empty($_POST["username"]) || empty($_POST["password"]))
- {
- apologize("Please provide a username and password");
- }
- if ($_POST["password"] !== $_POST["confirmation"])
- {
- apologize("Your passwords don't match");
- }
- if (empty($_POST["username"]))
- {
- apologize("You have not provided a username!");
- }
- $result = CS50::query("INSERT IGNORE INTO users (username, hash, cash) VALUES(?, ?, 10000.0000)", $_POST["username"], password_hash($_POST["password"], PASSWORD_DEFAULT));
- if ($result !== false)
- {
- $rows = CS50::query("SELECT LAST_INSERT_ID() AS id");
- $id = $rows[0]["id"];
- $_SESSION["id"] = "id";
- }
- else
- {
- apologize("Something went wrong (maybe the username you entered already exists in the database)");
- }
- redirect("/");
- }
- ?><?php
- // configuration
- require("../includes/config.php");
- //require("../includes/helpers.php");
- //require("../vendor/library50-php-5/CS50/CS50.php");
- // if user reached page via GET (as by clicking a link or via redirect)
- if ($_SERVER["REQUEST_METHOD"] == "GET")
- {
- // else render form
- render("register_form.php", ["title" => "Register"]);
- }
- // else if user reached page via POST (as by submitting a form via POST)
- else if ($_SERVER["REQUEST_METHOD"] == "POST")
- {
- if (empty($_POST["username"]) || empty($_POST["password"]))
- {
- apologize("Please provide a username and password");
- }
- if ($_POST["password"] !== $_POST["confirmation"])
- {
- apologize("Your passwords don't match");
- }
- if (empty($_POST["username"]))
- {
- apologize("You have not provided a username!");
- }
- $result = CS50::query("INSERT IGNORE INTO users (username, hash, cash) VALUES(?, ?, 10000.0000)", $_POST["username"], crypt($_POST["password"], PASSWORD_DEFAULT));
- if ($result !== false)
- {
- $rows = CS50::query("SELECT LAST_INSERT_ID() AS id");
- $id = $rows[0]["id"];
- $_SESSION["id"] = "id";
- }
- else
- {
- apologize("Something went wrong (maybe the username you entered already exists in the database)");
- }
- redirect("/");
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement