コード例 #1
0
 * Configuration de la base de données
 **/
session_start();
$db_host = 'localhost';
$db_port = '3306';
$db_name = '';
$db_pass = '';
$db_user = '';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if (TRUE == isset($_POST['step3'])) {
        $db_host = $_POST['db_host'];
        $db_name = $_POST['db_name'];
        $db_pass = $_POST['db_pass'];
        $db_port = $_POST['db_port'];
        $db_user = $_POST['db_user'];
        if (FALSE == testDb($_POST)) {
            $mess = ' Les paramêtres fournis sont incorrects';
        } else {
            $_SESSION['db'] = $_POST;
            header('Location:step3.php');
            exit;
        }
    } else {
        if (TRUE == isset($_POST['step1'])) {
            header('Location:step1.php');
            exit;
        }
    }
}
/**
 * Test de la connexion a la base de donnÈes
コード例 #2
0
ファイル: testMethods.php プロジェクト: mark-orussa/Adrlist
<?php

require_once 'ssl.php';
$debug->newFile('test/testMethods.php');
$success = false;
if (!empty($_POST['mode'])) {
    define('MODE', $_POST['mode']);
    $debug->add('MODE: ' . MODE);
    if (MODE == 'testDb') {
        testDb();
    }
} else {
    define('MODE', '');
    $debug->add('$_POST[\'mode\'] is empty.');
}
function testDb()
{
    global $Dbc, $debug, $message, $success;
    if (!empty($_POST['email']) && emailValidate($_POST['email']) && !empty($_POST['firstName']) && !empty($_POST['lastName']) && !empty($_POST['password']) && passwordValidate($_POST['password'])) {
        destroySession();
        $email = trim($_POST['email']);
        $pass = sha1(trim($_POST['password']));
        $firstName = trim($_POST['firstName']);
        $lastName = trim($_POST['lastName']);
        $rememberMeCode = sha1($email);
        $Dbc->beginTransaction();
        try {
            $stmt = $Dbc->prepare("SELECT getUserIdByEmail(?) AS 'userId'");
            $stmt .= $stmt->execute(array($email));
            while ($row = $stmt->fetch()) {
                $debug->add('$row[\'userId\']: ' . $row['userId']);