function checkResetID() { if (isset($_GET['resetid'])) { $db = new DbObject(); $resUser = $db->select("username", "Member", 'resetID="' . $_GET['resetid'] . '"'); $username = getUsername($resUser); return $username; } else { return false; } }
/** * Purpose: Determine whether the supplied username and password * combination is valid * @param string $username the username to check * @param string $password the password to check * @return boolean True if the username/password combo is valid * and False otherwise */ public function isValid($username, $password) { // Verify that the username exits, and that the supplied password // matches the real password // By default, the combination is not valid $valid = FALSE; // Open a database connection $db = new DbObject(); // Query for the password for the specified username $qryResults = $db->select("password", "Member", "username='******'"); // If there was one row returned, check the password against // the supplied password if ($qryResults->num_rows == 1) { $passwordRow = $qryResults->fetch_row(); if (password_verify($password, $passwordRow[0])) { $valid = TRUE; } } // Return whether the username and password combination is valid return $valid; }
// Once the form is submitted and the email passes the validation //check to see if the email exists in the database // if not then display that the email could not be found //if the email exists // then display that the email has been sent and wait 5 seconds before redirecting to index if (!isset($_POST["resetForm"])) { loadForm(true); } else { if (checkEmailRegex()) { // check the database to see if it exists //connect to database $db = new DbObject(); //received email value from the page $email = $_POST['email']; //check email in db $results = $db->select("username", "Member", 'email="' . $email . '"'); //stores the username in a variable for the storing of their resetID $user = getUsername($results); $email_exist = $results->num_rows; //records count //if returned value is more than 0, email exists if ($email_exist > 0) { // send an email and replace div if (sendMail($user)) { echo '<script > window.setTimeout(function(){window.location.href = "index.php";}, 5000);</script>'; echo "<p>An email has been sent, redirecting to the homepage</p>"; } } else { if ($email_exist === 0) { //display that the email does not exist loadForm(true);
<?php function my_autoloader($className) { require_once "classes/{$className}.class.php"; } spl_autoload_register("my_autoloader"); if (isset($_POST["username"])) { //connect to database $db = new DbObject(); //received username value from registration page $username = $_POST['username']; //check username in db $results = $db->select("username", "Member", "username='******'"); // var_dump($results); $username_exist = $results->num_rows; //records count //if returned value is more than 0, username is not available echo $username_exist; }
function saveToDb($report, $table, $days) { try { $dbObject = new DbObject(); $dataArray = $report->data; foreach ($report->metrics as $key => $value) { if ($value->id == "orders") { $orderIndex = $key; } if ($value->id == "visits") { $visitIndex = $key; } if ($value->id == "event3") { $productViewIndex = $key; } if ($value->id == "carts") { $cartIndex = $key; } } foreach ($dataArray as $data) { if (strpos($data->name, "unspecified") == false) { $id_keyword = $data->name; //md5() $metricesKeyword = $data->counts; $keyword = array("id" => $id_keyword, "value" => $data->name, "orders" => $metricesKeyword[$orderIndex], "visits" => $metricesKeyword[$visitIndex], "product_views" => $metricesKeyword[$productViewIndex], "carts" => $metricesKeyword[$cartIndex]); if (count($dbObject->select('keyword', array('*'), 'id="' . $id_keyword . '"')) == 0) { $dbObject->insert("keyword", $keyword); } else { $dbObject->update("keyword", $keyword, "id='" . $id_keyword . "'"); } if ($table == "sub_category") { $this->saveToSubCategory($data, $id_keyword, $orderIndex, $visitIndex, $productViewIndex, $cartIndex); } elseif ($table == "brand") { $this->saveToBrand($data, $id_keyword, $orderIndex, $visitIndex, $productViewIndex, $cartIndex, $this->availableDays[$days]); } elseif ($table == "item_id") { $this->saveToItemId($data, $orderIndex, $visitIndex, $productViewIndex, $cartIndex, $this->availableDays[$days], $keyword); } /*foreach ($data->breakdown as $subcategory) { if (strpos($subcategory->name, "other") === false && strpos($subcategory->name, "Unspecified") === false) { $id_subcategory = md5($subcategory->name); $dbObject->insert("sub_category", array("id" => $id_subcategory, "value" => $subcategory->name)); //foreach($subcategory->counts as $metric){ $metrices = $subcategory->counts; $dbObject->insert( "three_days_sub_category_ae", array("id" => md5($id_keyword . $id_subcategory), "id_sub_category" => $id_subcategory, "id_keyword" => $id_keyword, "orders" => $metrices[$orderIndex], "visits" => $metrices[$visitIndex], "product_views" => $metrices[$productViewIndex], "carts" => $metrices[$cartIndex] ) ); } }*/ } } return true; } catch (Exception $e) { var_dump($e); return false; } }