Esempio n. 1
0
include "includeMe.php";
//include these files
include "openDB.php";
openDB();
//imported functions
$email = $_POST['email'];
$password1 = $_POST['password'];
$password2 = $_POST['passwordCheck'];
$userId = "1";
//initialize userId to something other than null
$getuserID = "SELECT MAX(userID) FROM User;";
$resultID = mysql_query($getuserID);
//get a table (last row of Question's table)
//if there is an existing userID(user) in the table, get next highest userID, otherwise, userId is 1
if (noerror($resultID)) {
    $userId = makeMax($resultID);
    //get the actual number to be added to this new post
}
//Check to see if the email already exists in system (in other words, the email is already in use)
$findEmail = "SELECT * FROM User WHERE email='{$email}';";
$resultingTable = mysql_query($findEmail);
if (isEmpty($resultingTable)) {
    if ($password1 != $password2) {
        //if any passwords do not match each other, print notice to screen
        echo "<!DOCTYPE> <html> <body>";
        echo "Your passwords do not match.\n";
        echo "Return to <a href=\"midiate_reg.php\">registration</a> and try again.";
        echo "</body> </html>";
    } else {
        //change this later so that after registration user gets an email to finish registration?
        $_SESSION['loggedIn'] = "yes";
Esempio n. 2
0
openDB();
//$questionText = addslashes( $_POST['question']);
//$answer1Text = addslashes( $_POST['answer1']);
//$answer2Text = addslashes( $_POST['answer2']);
$questionText = $_POST['question'];
//variables
$answer1Text = $_POST['answer1'];
$answer2Text = $_POST['answer2'];
$userID = $_SESSION['meadUserId'];
//get postID - if no existing postIDs in Question table, assign postID as 1
$postID = '01';
$getID = "SELECT MAX(postID) FROM Question;";
$resultID = mysql_query($getID);
//get a table (last row of Question's table)
if (noerror($resultID)) {
    $postID = makeMax($resultID);
    //get the actual number to be added to this new post
}
$query = "INSERT INTO Question SET " . "questionText = '{$questionText}', " . "answer1Text = '{$answer1Text}', " . "answer2Text = '{$answer2Text}', " . "userID = '{$userID}', " . "postID = '{$postID}', " . "answer1Votes = '0', " . "answer2Votes = '0';";
if (noerrorquiet(mysql_query($query))) {
    // echo "it worked!";
    header("Location: my_Arguments.php");
} else {
    echo "something's wrong";
    header("Location: ask_It.php");
}
?>

<?php 
//This function will get a number from a query result (a table) and add one to create
//the next postID value