本文整理汇总了PHP中DataSource::getUser方法的典型用法代码示例。如果您正苦于以下问题:PHP DataSource::getUser方法的具体用法?PHP DataSource::getUser怎么用?PHP DataSource::getUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataSource
的用法示例。
在下文中一共展示了DataSource::getUser方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: escapeValue
<?php
require_once "requires/functions.php";
require_once "requires/datasource.php";
if (!isLoggedIn()) {
include "headers/publicheader.php";
} else {
include "headers/adminheader.php";
}
// if was submitted from the contact seller, review, or email submit button
// get the seller information to display
if (isset($_POST["contactseller"]) || isset($_POST["reviewsubmit"]) || isset($_POST["mailsubmit"])) {
$sellerName = $_POST["name"];
$seller = $_POST["seller"];
$itemID = $_POST["item"];
$result = DataSource::getUser("username = '{$seller}'");
$row = $result->fetch_assoc();
$email = $row["emailAddress"];
$phone = $row["phoneNumber"];
// if was submitted from the review submit button, create the new
// review for the seller
if (isset($_POST["reviewsubmit"])) {
$newReview = escapeValue(trim($_POST["review"]));
$seller = $_POST["seller"];
if (!empty($newReview)) {
DataSource::createUserReview($seller, $newReview);
}
// else if was submitted from the email message button, create
// the message and send it to the seller
} else {
if (isset($_POST["mailsubmit"])) {
示例2: escapeValue
class="waves-effect waves-light btn indigo accent-1">
Log In</button>
</div>
</div>
</div>
</div>
<?php
// if was submitted from the log in button, hash the password as md5
// 128 bit format, then compare the username and password in the database
// if match, log the user in, else display the error
if (isset($_POST["loginsubmit"])) {
$username = escapeValue(trim($_POST["username"]));
$password = md5(trim($_POST["password"]));
$selection = "username = '{$username}' ";
$selection .= "AND password = '{$password}';";
$result = DataSource::getUser($selection);
$row = $result->fetch_assoc();
if ($row != NULL) {
// user found, log in successfully
$_SESSION["currentUser"] = $row["username"];
$_SESSION["currentName"] = $row["firstName"] + $row["lastName"];
redirectTo("myitems.php");
} else {
echo "<h3>Error: incorrect username/password</h3>";
}
}
closeConnection();
?>
</form>
</div>
</div>
示例3: escapeValue
include "headers/adminheader.php";
if (isset($_SESSION["currentUser"])) {
$username = $_SESSION["currentUser"];
// if the current session has a logged in user
// and the update info button was submitted, update
// their information
if (isset($_POST["updateinfosubmit"])) {
$firstName = escapeValue(trim($_POST["firstname"]));
$lastName = escapeValue(trim($_POST["lastname"]));
$phoneNumber = escapeValue(trim($_POST["phone"]));
$emailAddress = escapeValue(trim($_POST["email"]));
DataSource::updateUser($username, $firstName, $lastName, $emailAddress, $phoneNumber);
// else get current information about the username in the
// database to display
} else {
$result = DataSource::getUser("username = '{$username}'");
$row = $result->fetch_assoc();
$firstName = $row["firstName"];
$lastName = $row["lastName"];
$emailAddress = $row["emailAddress"];
$phoneNumber = $row["phoneNumber"];
}
// get the reviews for the username from the database to
// display
$reviewResult = DataSource::getUserReviews($username);
$reviews = array();
if ($reviewResult) {
while ($review = $reviewResult->fetch_assoc()) {
$reviews[] = $review["reviewDescription"];
}
}