| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- $name = $discord = $bedrock = $birthdate = $nameErr = "";
- if ($_SERVER["REQUEST_METHOD"] == "POST") {
- $name = test_input($_POST["fname"]);
- if (!preg_match("/^[a-zA-Z-' ]*$/",$name)) {
- $nameErr = "Only letters and white space allowed.";
- }
- $discord = test_input($_POST["fdiscord"]);
- if (!preg_match("/.+#[0-9]{4}(?<!0000)/",$discord)) {
- $nameErr = "Discord name not valid";
- }
- $bedrock = test_input($_POST["fbedrock"]);
- if (!preg_match("/^[a-zA-Z-' ]*$/",$bedrock)) {
- $nameErr = "Only letters and white space allowed.";
- }
- $birthdate = test_input($_POST["fbirthdate"]);
- } else {
- $nameErr = "Request not valid.";
- }
- if ($nameErr == "") {
- echo "name " . $name . "<br>";
- echo "discord " . $discord . "<br>";
- echo "bedrock " . $bedrock . "<br>";
- echo "birthday " . $birthdate . "<br>";
- // send data somehow to db
- // end then redirect to the succes page
- header("Location: success.php");
- die();
- } else {
- header("Location: index.php?error=" . htmlspecialchars($nameErr));
- die();
- }
- function test_input($data) {
- $data = trim($data);
- $data = stripslashes($data);
- $data = htmlspecialchars($data);
- return $data;
- }
- ?>
|