divadiva Posted November 12, 2008 Share Posted November 12, 2008 In the website login screen I am working on,I have globvars('username','password','do'); global $globvars; extract($globvars) ; session_start(); //$_SESSION['username'] = $username; //$_SESSION['password'] = $passsword; $globvars['session_id'] = session_id(); // get host if (isset($HTTP_HOST)){ $globvars['host']=$HTTP_HOST; } else { $globvars['host']=$_SERVER['HTTP_HOST']; } // get page name if (isset($PHP_SELF)){ $page=$PHP_SELF; } else { $page=$_SERVER['PHP_SELF']; } if(strrpos($page,'/')) { $page = substr( $page , strrpos($page,'/')+1 ); } $globvars['page']=$page; opendb(); function verify($filename) { global $globvars; extract($globvars) ; $stamp = date("Y-m-d H:i:s"); $globvars['login']['user'] = null ; $globvars['login']['email'] = null ; $globvars['login']['message'] = null ; $globvars['login']['types'] = null ; $globvars['login']['pages'] = null ; $globvars['login']['name'] = null ; if($filename) { $string = "SELECT * FROM `pages` WHERE `filename` = '$filename'"; $query= mysql_query("$string"); if(mysql_num_rows($query)) { $t_row = mysql_fetch_array($query); $utallow = $t_row['user_types']; if( ( $do == 'logout' ) && $session_id ) { $string = "UPDATE `users` SET `session` = '' WHERE `session` = '$session_id' LIMIT 1"; mysql_query("$string"); $globvars['login']['message'] = 'You are logged out'; } elseif($do=='login') { if($username && $password) { // check user $string = "SELECT * FROM `users` WHERE `username` = '$username' AND `password` = '$password'"; $check = mysql_query("$string"); I want to create a session for the username and password that would be entered by the user on the login screen. How to do that in this case. What if I write $_SESSION['usename'] and $_SESSION['password'] would this solve my problem? Link to comment https://forums.phpfreaks.com/topic/132475-session-variables/ Share on other sites More sharing options...
revraz Posted November 12, 2008 Share Posted November 12, 2008 What's wrong with session_start(); $_SESSION['username'] = $username; $_SESSION['password'] = $passsword; Link to comment https://forums.phpfreaks.com/topic/132475-session-variables/#findComment-688775 Share on other sites More sharing options...
premiso Posted November 12, 2008 Share Posted November 12, 2008 session_start(); $_SESSION['username'] = $_POST['username']; $_SESSION['password'] = $_POST['passsword']; I failed to see where $username and $password were given a variable. You said this comes from a form, so this should give them a valid value. Link to comment https://forums.phpfreaks.com/topic/132475-session-variables/#findComment-688779 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.