コード例 #1
0
ファイル: insertProfile.php プロジェクト: hopet1/Graphinnati
$negative = "<center style='color: black;'>Whoops! Looks like some fields were left empty; please try again.</center>";
$databaseName = 'localhost:/tmp/mysql.sock';
$databaseUserName = '******';
$databasePassword = '';
$link = mysql_connect($databaseName, $databaseUserName, $databasePassword);
if (!$link) {
    //die('Not connected : ' . mysql_error());
    echo "Connection could not be established.";
}
$fname = $_POST['firstName'];
$lname = $_POST['lastName'];
$pNumber = $_POST['phoneNumber'];
$username = $_POST['username'];
$password = password_hash($_POST['password'], PASSWORD_BCRYPT);
$message;
if (anyEmpty($fname, $lname, $pNumber, $username, $password)) {
    $message = $negative;
} else {
    //Insert data.
    mysql_select_db('Graphinnati');
    $sql = "INSERT INTO Accounts (FirstName, LastName, PhoneNumber, Username, Password) VALUES ('{$fname}', '{$lname}', '{$pNumber}', '{$username}', '{$password}')";
    $result = mysql_query($sql, $link);
    if (!$result) {
        echo "No result could be established.";
    } else {
        $message = $positive;
    }
}
function anyEmpty($fname, $lname, $pNumber, $username, $password)
{
    if (empty($fname) || empty($lname) || empty($pNumber) || empty($username) || empty($password)) {
コード例 #2
0
ファイル: handleLogin.php プロジェクト: hopet1/Graphinnati
<?php

$negative = "<center style='color: black;'>Whoops! Looks like some fields were left empty; please try again.</center><br>";
$error = "<center style='color: black;'>Incorrect login; please try again.</center><br>";
$databaseName = 'localhost:/tmp/mysql.sock';
$databaseUserName = '******';
$databasePassword = '';
$link = mysql_connect($databaseName, $databaseUserName, $databasePassword);
if (!$link) {
    //die('Not connected : ' . mysql_error());
    echo "Connection could not be established.";
}
$username = $_POST['username'];
$password = $_POST['password'];
$message;
if (anyEmpty($username, $password)) {
    $message = $negative;
    header("Location: login.php?message=" . $message);
} else {
    mysql_select_db('Graphinnati');
    $sql = "SELECT * FROM Accounts where Username='******'";
    $result = mysql_query($sql, $link);
    $row = mysql_fetch_array($result);
    if (!empty($row['Username']) and password_verify($password, $row['Password'])) {
        session_start();
        $_SESSION['name'] = $username;
        header("Location: index.php");
    } else {
        $message = $error;
        header("Location: login.php?message=" . $message);
    }