Exemplo n.º 1
0
$dept = $_POST['dept'];
$degree = $_POST['degree'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$address = $_POST['address'];
$error = null;
$saved = false;
try {
    $dsn = 'mysql:dbname=bookweb;host=140.127.74.142';
    $user = '******';
    $password = '******';
    $db = new PDO($dsn, $user, $password);
    $db->exec("set names utf8");
    $accountCheck = searchAccount($db, $account);
    if ($accountCheck) {
        insertAccount($db, $account, $pwd);
        $u_id = searchID($db, $account);
        insertUserInfo($db, $name, $dept, $degree, $email, $phone, $address, $u_id);
        $saved = true;
    } else {
        $error = "account";
        $saved = false;
    }
} catch (PDOException $e) {
    $error = $e;
}
$result = array("result" => $saved, "responseDetail" => $error);
$json_result = json_encode($result);
echo $json_result;
//----exit----
function searchAccount($db, $account)
    exit;
}
if ($action == 'Submit') {
    try {
        $stmt1 = getAccountById($id);
        if ($stmt1->rowCount()) {
            header('Location: ../vues/vue_inscription.php?Error=usedId');
            exit;
        }
        $stmt1 = getAccountByMail($email);
        if ($stmt1->rowCount()) {
            header('Location: ../vues/vue_inscription.php?Error=usedEmail');
            exit;
        }
        $idValidation = md5($id);
        $stmt2 = insertAccount($id, $email, $pwd, $idValidation);
    } catch (PDOException $e) {
        header('Location: ../vues/vue_inscription.php?Error=db');
        exit;
    }
    $message = 'Voici vos identifiants d\'inscription :' . "\n";
    $message .= 'Identifiant          : ' . $id . "\n";
    $message .= 'Email                : ' . $email . "\n";
    $message .= 'Merci de valider votre mail pour activer votre compte : ' . ' octaaron.alwaysdata.net/vues/vue_validation.php?idvalidation=' . md5($id);
    //$message2 = "Nouvelle inscription : " . $id . "\n E-mail : " . $email . "\n";
    $subject = 'Bienvenue ' . $id;
    //$subject2 = 'Nouvelle inscription : ' . $id;
    mail($email, $subject, $message);
    header('Location: ../vues/vue_validation.php?validation=Success');
} else {
    header('Location: ../vues/vue_inscription.php?Error=button');
Exemplo n.º 3
0
function generateAccountNumber($id, $balance)
{
    $account = selectAccountByUserId($id);
    if ($account) {
        return $account->ACCOUNT_NUMBER;
    }
    $accountNumber = $id + 1000000000;
    return insertAccount($id, $accountNumber, $balance);
}
Exemplo n.º 4
0
<?php

include "pdo.php";
$firstName = $_POST['firstName'];
$lastName = $_POST['lastName'];
$username = $_POST['username'];
$password = $_POST['password'];
$email = $_POST['email'];
$id = insertAccount($username, $password);
if ($id != false) {
    insertProfile($id, $firstName, $lastName, $email);
    echo true;
} else {
    echo false;
}