示例#1
0
?>

<div>
  <form method="post" action="">
    <fieldset>
      <legend>Register</legend>
      <p>
        <label>Username :</label>
        <input name="name" type="text"/><br />

        <label>Email :</label>
        <input name="mail" type="email"/>

        <label>Password :</label>
        <input name="pwd" type="password"/>
      </p>
    </fieldset>
    <p>
      <input type="submit" value="Register" />
    </p>
  </form>
  <div class="error"></div>
</div>

<?php 
if (isset($_POST['name']) && empty($_POST['name']) == false && empty($_POST['pwd']) == false && isset($_POST['pwd']) && empty($_POST['mail']) == false && isset($_POST['mail'])) {
    $name = ECVChat\sanitizeString($_POST['name']);
    $mail = ECVChat\sanitizeString($_POST['mail']);
    $pwd = ECVChat\sanitizeString($_POST['pwd']);
    ECVChat\DB\register($name, $pwd, $mail);
}
示例#2
0
require_once 'session.php';
require_once 'pdo.php';
require_once 'functions.php';
$message = "";
if (isset($_SESSION['id'])) {
    ECVChat\redirect('index.php');
} else {
    if ($_SERVER['REQUEST_METHOD'] === "POST") {
        if (empty($_POST['username']) || empty($_POST['password']) || empty($_POST['email'])) {
            $message = '<p>Something went wrong. You must fill all the fields</p>';
        } else {
            $username = ECVChat\sanitizeString($_POST['username']);
            $email = ECVChat\sanitizeString($_POST['email']);
            $password = ECVChat\sanitizeString($_POST['password']);
            try {
                ECVChat\DB\register($username, $password, $email);
                ECVChat\redirect("index.php");
            } catch (Exception $e) {
                $message = '<p>' . $e->getMessage() . '</p>';
            }
        }
    }
}
require_once 'header.php';
?>
<div>
  <form method="post" action="">
    <fieldset>
      <legend>Register</legend>
      <p>
        <label>Username :</label>