截至:2013 年 6 月 4 日,美国中部标准时间晚上 7:37,我们没有解决此问题的方法。
我有一个脚本可以让我的用户登录并从数据库表中提取信息。现在它从一张桌子上拉出来affiliate_information
并得到多个项目。
我希望它从affiliate_information
ANDaffiliate_tasks
现在我只是在上面添加了以下内容,$_SESSION['company_name'] = $row['company_name'];
并将所需的代码添加到我的页面以呼应它,但没有发生任何事情。
//pull from another table in the database
$res = mysql_query("SELECT * FROM `affiliate_tasks` WHERE `username` = '".$username."'");
$_SESSION['task_name'] = $row['task_name'];
$_SESSION['due_date'] = $row['due_date'];
$_SESSION['status'] = $row['status'];
这是完整的脚本:
<?php
include "scripts/user_managment/connect.php";
//If the user has submitted the form
if($_POST['submit']){
//protect the posted value then store them to variables
$username = protect($_POST['username']);
$password = protect($_POST['password']);
//Check if the username or password boxes were not filled in
if(!$username || !$password){
//if not display an error message
echo '<meta http-equiv="Refresh" content="0;url=http://www.green-panda.com/website/panda/affiliates/login.php?msg=' . urlencode(base64_encode('A username and password is required!')) . '">';
}else{
//if the were continue checking
//select all rows from the table where the username matches the one entered by the user
$res = mysql_query("SELECT * FROM `affiliate_information` WHERE `username` = '".$username."'");
$num = mysql_num_rows($res);
//check if there was not a match
if($num == 0){
//if not display an error message
echo '<meta http-equiv="Refresh" content="0;url=http://www.green-panda.com/website/panda/affiliates/login.php?msg=' . urlencode(base64_encode('The username and/or password does not match!')) . '">';
}else{
//if there was a match continue checking
//select all rows where the username and password match the ones submitted by the user
$res = mysql_query("SELECT * FROM `affiliate_information` WHERE `username` = '".$username."' AND `password` = '".$password."'");
$num = mysql_num_rows($res);
//check if there was not a match
if($num == 0){
//if not display error message
echo '<meta http-equiv="Refresh" content="0;url=http://www.green-panda.com/website/panda/affiliates/login.php?msg=' . urlencode(base64_encode('The username and/or password does not match!')) . '">';
}else{
//if there was continue checking
//split all fields fom the correct row into an associative array
$row = mysql_fetch_assoc($res);
//check to see if the user has not activated their account yet
if($row['active'] != 1){
//if not display error message
echo '<meta http-equiv="Refresh" content="0;url=http://www.green-panda.com/website/panda/affiliates/login.php?msg=' . urlencode(base64_encode('You have not yet activated your account!')) . '">';
}else{
//if they have log them in
//set the login session storing there id - we use this to see if they are logged in or not
$_SESSION['uid'] = $row['id'];
//pull from another table in the database
$res = mysql_query("SELECT * FROM `affiliate_tasks` WHERE `username` = '".$username."'");
$_SESSION['task_name'] = $row['task_name'];
$_SESSION['due_date'] = $row['due_date'];
$_SESSION['status'] = $row['status'];
//get the users informaiton
$_SESSION['company_name'] = $row['company_name']; //get the company name
$_SESSION['first_name'] = $row['first_name'];
$_SESSION['last_name'] = $row['last_name'];
$_SESSION['email_address'] = $row['email_address'];
$_SESSION['check_payable_to'] = $row['check_payable_to'];
$_SESSION['add_line_1'] = $row['add_line_1'];
$_SESSION['add_line_2'] = $row['add_line_2'];
$_SESSION['city'] = $row['city'];
$_SESSION['state'] = $row['state'];
$_SESSION['zip'] = $row['zip'];
$_SESSION['main_phone'] = $row['main_phone'];
$_SESSION['mobile_phone'] = $row['mobile_phone'];
$_SESSION['affiliate_since_date'] = $row['affiliate_since_date'];
$_SESSION['direct_deposit'] = $row['direct_deposit'];
$_SESSION['paper_check'] = $row['paper_check'];
$_SESSION['username'] = $row['username']; //gets the username
$_SESSION['password'] = $row['password']; //get the password
$_SESSION['profile_pic_src'] = $row['profile_pic_src']; //gets the profile pic
$_SESSION['website_url'] = $row['website_url']; //gets the website
$_SESSION['account_balance'] = $row['account_balance'];
$_SESSION['domain_count'] = $row['domain_count'];
$_SESSION['earning_count'] = $row['earning_count'];
$_SESSION['received_count'] = $row['received_count'];
$_SESSION['referrals_count'] = $row['referrals_count'];
//update the online field to 50 seconds into the future
$time = date('U')+50;
mysql_query("UPDATE `affiliate_information` SET `online` = '".$time."' WHERE `id` = '".$_SESSION['uid']."'");
//redirect them to the affiliate_informationonline page
echo '<meta http-equiv="Refresh" content="0;url=http://www.green-panda.com/website/panda/affiliates/index.php?msg=' . urlencode(base64_encode('You have successfully logged in!')) . '">';
}
}
}
}
}
?>
我怎样才能使这个脚本从affiliate_information
甚至`affiliate_tasks
更多的表中提取?还是我需要在单独的脚本中执行此操作?如果是这样,我将如何让它同时获取信息。
在我的常规页面中,我必须<?php session_start(); echo $_SESSION[task_name]; ?>
能够回显变量。