User Profile tutorial
Posted: Sat Oct 08, 2011 3:59 pm
Hello,
I am implementing the user profile system into your login system. On the edit profile page it isn't grabbing the users information. I have changed the session parts to the session in the login but it still doesn't get the information.
This is my edit_profile.php -
I am implementing the user profile system into your login system. On the edit profile page it isn't grabbing the users information. I have changed the session parts to the session in the login but it still doesn't get the information.
This is my edit_profile.php -
<?php include('core/init.inc.php'); if (isset($_POST['email'], $_POST['location'], $_POST['about'])) { $errors = array(); if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) === false) { $errors[] = 'The email address you entered is not valid.'; } if (preg_match('#^[1-z0-9 ]+$#i', $_POST['location']) === 0) { $errors[] = 'Your location must only contain a-z, 0-9 and spaces.'; } if (empty($errors)) { set_profile_info($_POST['email'], $_POST['about'], $_POST['location']); } $user_info = array( 'email' => htmlentities($_POST['email']), 'about' => htmlentities($_POST['about']), 'location' => htmlentities($_POST['location']) ); } else { $user_info = fetch_user_info($_SESSION['username']); } $user_info = fetch_user_info($_SESSION['username']); ?>and this is my fetch_user_info function -
// Fetches profile information for the given user. function fetch_user_info($uid) { $uid = (int)$uid; $sql = "SELECT `user_name` AS `username`, `first_name` AS `firstname`, `last_name` AS `lastname`, `user_email` AS `email`, `user_about` AS `about`, `user_location` AS `location`, `user_gender` AS `gender` FROM `users` WHERE `user_id` = {$uid}"; $result = mysql_query($sql); return mysql_fetch_assoc($result); }The fetch_user_info shouldn't matter anyway, but in the PHP of edit_profile.php it sets the session to 'username' and that's the session set in my login.php.