PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I want to get the variables on http://www.4boredom.com/editbasic.php to load from the database. With PHP how would I edit what I have to load from my 'basic' database what the user entered when they registered?
<?php
ob_start();
session_start();
require 'db.php';
// Check to see if user is logged in and what there username is
if(isset($_SESSION['email_address']) && isset($_SESSION['loggedin'])){
// If user is logged in SESSION session variables
if($_SESSION['loggedin']==1){
$email_address = $_SESSION['email_address'];
if(isset($_SESSION['password'])){
$pass = $_SESSION['password'];
}
$loggedin = $_SESSION['loggedin'];
if(isset($_SESSION['time'])){
$time = $_SESSION['time'];
}
}
// now only process if user is logged in
if($loggedin == 1){
// Get user Information from users db
$info = mysql_query("SELECT * FROM `users` WHERE email_address = '{$email_address}' ");
$info2 = mysql_query("SELECT * FROM `basic` WHERE email_addy = '{$email_addy}' ");
if(!$info){
die("Could not get user info");
}
$info = mysql_fetch_array($info);
$info2 = mysql_fetch_array($info2);
// Get other required user infomation
$first_name = $info['first_name'];
$last_name = $info['last_name'];
$email_address = $info['email_address'];
$signup_date = $info['signup_date'];
$username = $info['username'];
$gender = $info['gender'];
$month = $info['month'];
$day = $info['day'];
$year = $info['year'];
$userid = $userid['userid'];
// Fix for any place you put session instead of just the variable.
$_SESSION['first_name'] = $first_name;
$_SESSION['email_adress'] = $email_address;
$_SESSION['signup_date'] = $signup_date;
$_SESSION['last_name'] = $last_name;
$_SESSION['username'] = $username;
$_SESSION['gender'] = $gender;
$_SESSION['month'] = $month;
$_SESSION['day'] = $day;
$_SESSION['year'] = $year;
// Get user Information from basic db
$info = mysql_query("SELECT * FROM `basic` WHERE userid = '{$userid}' ");
if(!$info){
die("Could not get user info");
}
$info = mysql_fetch_array($info);
// Get other required user infomation
$gender = $info['gender'];
$month = $info['month'];
$day = $info['day'];
$year = $info['year'];
$email_addy = $info['email_addy'];
// Fix for any place you put session instead of just the variable.
$_SESSION['gender'] = $gender;
$_SESSION['month'] = $month;
$_SESSION['day'] = $day;
$_SESSION['year'] = $year;
$_SESSION['email_addy'] = $email_addy;
$current_time = date("Y");
//end of only process if user is logged in code
}
//if user is not logged in:
/*} else {
// Set user is not logged in if session is not detected
$_SESSION['loggedin'] = 0;
$loggedin = $_SESSION['loggedin'];
}*/
}
ob_flush();
?>
Ok. The problem is you need to cut your question down. You have posted too much. Anyway just to give you an idea look at the following which is just a date example loaded from MySQL:
// Get user Information from users db
$info = mysql_query("SELECT * FROM `users` WHERE email_address = '{$email_address}' ");
$info2 = mysql_query("SELECT * FROM `basic` WHERE email_addy = '{$email_addy}' ");
if(!$info){
die("Could not get user info");
}
$info = mysql_fetch_array($info);
$info2 = mysql_fetch_array($info2);
// Get other required user infomation
$first_name = $info['first_name'];
$last_name = $info['last_name'];
$email_address = $info['email_address'];
$signup_date = $info['signup_date'];
$username = $info['username'];
$gender = $info['gender'];
$month = $info['month'];
$day = $info['day'];
$year = $info['year'];
$userid = $userid['userid'];
// Fix for any place you put session instead of just the variable.
$_SESSION['first_name'] = $first_name;
$_SESSION['email_adress'] = $email_address;
$_SESSION['signup_date'] = $signup_date;
$_SESSION['last_name'] = $last_name;
$_SESSION['username'] = $username;
$_SESSION['gender'] = $gender;
$_SESSION['month'] = $month;
$_SESSION['day'] = $day;
$_SESSION['year'] = $year;
// Get user Information from basic db
$info = mysql_query("SELECT * FROM `basic` WHERE userid = '{$userid}' ");
if(!$info){
die("Could not get user info");
}
$info = mysql_fetch_array($info);
// Get other required user infomation
$gender = $info['gender'];
$month = $info['month'];
$day = $info['day'];
$year = $info['year'];
$email_addy = $info['email_addy'];
// Fix for any place you put session instead of just the variable.
$_SESSION['gender'] = $gender;
$_SESSION['month'] = $month;
$_SESSION['day'] = $day;
$_SESSION['year'] = $year;
$_SESSION['email_addy'] = $email_addy;
anyone willing to take a quick look thru my system for some money?
I cant pay a huge price because im a college student trying to learn, but sometimes i cant work out my own errors, so I will compensate you for your time at a reasonable rate... PM me
$info = mysql_query("select * from users where email_address='$email_address'");
$info2 = mysql_query("select * from basic where email_addy = '$email_addy'");
copy the above and test it and then post the warnings/errors back here if u still got stuck up..