lookee Posted October 29, 2008 Share Posted October 29, 2008 I've almost got my login script working, but for some reason the username string is not passing to my successful.php page. Code -------------------------------------------- <?php session_start(); include 'config.php'; // Connect to server and select databse. //mysql_connect("$host", "$username", "$password")or die("cannot connect"); //mysql_select_db("$db_name")or die("cannot select DB"); // username and password sent from form $username=$_POST['username']; $password=$_POST['password']; // captures username & passwords, so they can be passed on to other pages session_register("username"); $sql="SELECT * FROM nixon WHERE username='$username' and password='$password'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matches table row must be 1 row if($count==1){ header("location: successful.php"); } else { header ("Location: again.html"); } ?> ------------------------ Any assistance would be of great help! Thanks! Link to comment https://forums.phpfreaks.com/topic/130657-solved-session-not-passing-username-string/ Share on other sites More sharing options...
lookee Posted October 30, 2008 Author Share Posted October 30, 2008 Nevermind... I accidentally posted this under Mysql... I moved it to the .php forum. Link to comment https://forums.phpfreaks.com/topic/130657-solved-session-not-passing-username-string/#findComment-678001 Share on other sites More sharing options...
alexweber15 Posted October 30, 2008 Share Posted October 30, 2008 basically session_register() is deprecated (reasons below), use: $_SESSION['username'] = $username; and please, PLEASE tell me this is simplified sample script right? you are not actually taking $_POST variables, adding them directly to a session and then using them in an sql statement are you? quoted from PHP Manual: Caution: If you want your script to work regardless of register_globals, you need to instead use the $_SESSION array as $_SESSION entries are automatically registered. If your script uses session_register(), it will not work in environments where the PHP directive register_globals is disabled. Note: register_globals: important note As of PHP 4.2.0, the default value for the PHP directive register_globals is off, and it was completely removed as of PHP 6.0.0. The PHP community discourages developers from relying on this directive, and encourages the use of other means, such as the superglobals. Link to comment https://forums.phpfreaks.com/topic/130657-solved-session-not-passing-username-string/#findComment-678027 Share on other sites More sharing options...
revraz Posted October 30, 2008 Share Posted October 30, 2008 Was answered in the PHP forum already. Link to comment https://forums.phpfreaks.com/topic/130657-solved-session-not-passing-username-string/#findComment-678130 Share on other sites More sharing options...
alexweber15 Posted October 30, 2008 Share Posted October 30, 2008 Was answered in the PHP forum already. someone lock the thread then or mark it as solved please. Link to comment https://forums.phpfreaks.com/topic/130657-solved-session-not-passing-username-string/#findComment-678172 Share on other sites More sharing options...
Recommended Posts