headstress Posted August 9, 2013 Share Posted August 9, 2013 HI, I carried out a tutorial on the net for a login form/registration page I have the form fully working but need it to direct to a certain page depending on users login details This is where I am at and cannot get it to direct to right page <?php include 'core/init.php'; if (empty($_POST) === false) { $email = $_POST['email']; $password = $_POST['password']; if(empty($email) === true || empty($password) === true) { $errors[] = 'You need to enter a username and password'; } elseif (user_exists($email) === false){ $errors[] = 'This email address does not excist'; } elseif (user_active($email) === false){ $errors[] = 'You have not acivated your account'; } else { $login = login($email, $password); if($login === false) { $errors[] = 'Username or Password Incorrect'; } if (logged_in() === true && user_data('user_type')=== 1){ header ("Location: member1.php"); } else if (logged_in() === true && user_data('user_type')=== 2){ header ("Location: member2.php"); } else if (logged_in() === true && user_data('user_type')=== 3){ header ("Location: member3.php"); } Link to comment https://forums.phpfreaks.com/topic/280984-please-help-with-this-code/ Share on other sites More sharing options...
headstress Posted August 9, 2013 Author Share Posted August 9, 2013 These are the functions function user_data($user_id) { $data = array(); $user_id = (int)$user_id; $func_num_args = func_num_args(); $func_get_args = func_get_args(); if ($func_num_args > 1) { unset ($func_get_args[0]); $fields = '`' . implode(' `, ` ', $func_get_args) . '`'; $data = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `user_id` = $user_id")); return $data; } } function logged_in(){ return (isset($_SESSION['user_id'])) ? true : false; } Link to comment https://forums.phpfreaks.com/topic/280984-please-help-with-this-code/#findComment-1444119 Share on other sites More sharing options...
cyberRobot Posted August 9, 2013 Share Posted August 9, 2013 It looks like the user_data() function expects a user ID. You're currently passing a string: user_data('user_type') Link to comment https://forums.phpfreaks.com/topic/280984-please-help-with-this-code/#findComment-1444146 Share on other sites More sharing options...
headstress Posted August 9, 2013 Author Share Posted August 9, 2013 It looks like the user_data() function expects a user ID. You're currently passing a string: user_data('user_type') Thank you but I am still trying to grasp this php language This php code is in a file called init.php if (logged_in() === true) { $session_user_id = $_SESSION['user_id']; $user_data = user_data ($session_user_id, 'email', 'user_type', 'name', 'company', 'telephone', 'password'); Link to comment https://forums.phpfreaks.com/topic/280984-please-help-with-this-code/#findComment-1444148 Share on other sites More sharing options...
headstress Posted August 9, 2013 Author Share Posted August 9, 2013 HI Im really struggling with this can someone please give us a pointer Link to comment https://forums.phpfreaks.com/topic/280984-please-help-with-this-code/#findComment-1444241 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.