I'm trying to load user data from my index.php page using a text box and a submit button.
My main php page is index.php and I have a post call to an index_dispatcher.php script that opens the database and loads some data into some $_SESSION variables regarding the user name typed into the text box. My debug prints show the DB is opening fine and the data is being loaded into the $_SESSION vars fine too.
Then my index_dispatcher.php calls my index.php file again but the $_SESSION vars are not set in index.php.
If I repeat this process, meaning if I type in the user name into the text box again and click on the submit button again, then it will work.
Does anyone know why it takes two times for the $_SESSION variables (which get set in index_dispatcher.php) to get set in the index.php file?
I should also add that this behavior is with Firefox and Safari browsers - IE 7.0 works the first time but FF/Safari needs this to happen twice!
index.php
PHP Code:
<FORM NAME="index_form.php" ACTION="index_dispatcher.php" METHOD="post">
index.php text box and submit code
PHP Code:
Name <INPUT TYPE="text" NAME="frm_name"> <INPUT TYPE="submit" NAME="frm_login_name" VALUE="Login">
index_dispatcher.php code:
PHP Code:
$php_string = strtolower($_POST["frm_login_name"]); // open mysql database connection -------------------------------- // server username password $php_linkID = mysql_connect("localhost","db16_ralph","atg568h93hf65jn8"); if ($php_linkID != TRUE) { print '<br>database connection failed.<br>'; exit; } // select the main database -------------------------------------- $php_resultID = mysql_select_db("db_db",$php_linkID); if ($php_resultID != TRUE) { print "database selection failed.<br>"; exit; } $php_SQL = "SELECT * FROM Salesmen WHERE login_name = '".$php_string."'"; $php_resultID = mysql_query($php_SQL, $php_linkID); $php_row = mysql_fetch_object($php_resultID); $php_row_count = mysql_num_rows($php_resultID); if ($php_row_count > 0) { $_SESSION['php_g_sc_login_name'] = $php_row->login_name; $_SESSION['php_g_sc_first_name'] = $php_row->first_name; $_SESSION['php_g_sc_last_name'] = $php_row->last_name; print $_SESSION['php_g_sc_first_name'].'<br>'; print $_SESSION['php_g_sc_last_name'].'<br>'; }
__________________
RalphF
Business Text Messaging Services
Please login or register to view this content. Registration is FREE
|