Exemplo n.º 1
0
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>
        <input name="username" type="text"/><br />
Exemplo n.º 2
0
<?php

require_once 'functions.php';
$error = "";
if ($_SERVER['REQUEST_METHOD'] === "POST") {
    if (empty($_POST['username']) || empty($_POST['email']) || empty($_POST['password'])) {
        $error = '<p>Please fill all the fields</p>';
    } else {
        $username = ECVChat\sanitizeString($_POST['username']);
        $email = ECVChat\sanitizeString($_POST['email']);
        $password = ECVChat\sanitizeString($_POST['password']);
        $id = ECVChat\DB\register($username, $password, $email);
        if ($id) {
            ECVChat\redirect('login.php');
        } else {
            $error = '<p>Something went wrong...</p>';
        }
    }
}
include 'header.php';
?>

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

        <label for="email">Email :</label>
Exemplo n.º 3
0
<?php

require_once 'session.php';
require_once 'functions.php';
session_destroy();
ECVChat\redirect('index.php');
Exemplo n.º 4
0
require_once 'session.php';
require_once 'functions.php';
$error = "";
if ($_SERVER['REQUEST_METHOD'] === "POST") {
    if (empty($_POST['username']) || empty($_POST['password'])) {
        $error = '<p>Please fill all the fields</p>';
    } else {
        $username = ECVChat\sanitizeString($_POST['username']);
        $password = ECVChat\sanitizeString($_POST['password']);
        $user = ECVChat\DB\login($username, $password);
        if ($user) {
            $_SESSION['id'] = $user['id'];
            $_SESSION['username'] = $user['username'];
            $_SESSION['photo_id'] = $user['photo_id'];
            ECVChat\redirect('chat.php');
        } else {
            $error = '<p>Something went wrong...</p>';
        }
    }
}
include 'header.php';
?>
<div>
  <form method="post" action="">
    <fieldset>
      <legend>Connexion</legend>
      <p>
        <label for="username">Username :</label>
        <input name="username" type="text" /><br />