SaturdayNightSpecial Posted August 19, 2009 Share Posted August 19, 2009 Hello, I've been working on this for days and read everything I can and can't get this resolved so I figured it was time to pull into the gas station and get directions. I've got 2 databases that I'm working with and 3 forms. One form is just the login where I've set a session variable of the username. Once logged in the user goes to a news upload form. The other form is the registration form where I keep all the info on their organization. I'm wanting to use dynamic text to pre-fill some of the fields in the news upload form so they can confirm that the info is correct and if not allow them to update it in that form but I can't get the dynamic text to echo in the form fields. Here's the code for the SESSION in the login page that I'm using: //declare two session variables and assign them $_SESSION['MM_Username'] = $loginUsername; $_SESSION['MM_UserGroup'] = $loginStrGroup; And here's the recordset code in the news upload page: $colname_rs_nfupload_formfill = "-1"; if (isset($_SESSION['MM_Username'])) { $colname_rs_nfupload_formfill = $_SESSION['MM_Username']; } mysql_select_db($database_tracks, $tracks); $query_rs_nfupload_formfill = sprintf("SELECT trkname, trkusername, trkstate, orgtrack, orgsanction, orgprmarketing, orgmedia, firstname, lastname, contactphone, contactemail, trkwebsite FROM tracklist WHERE trkusername = %s", GetSQLValueString($colname_rs_nfupload_formfill, "text")); $rs_nfupload_formfill = mysql_query($query_rs_nfupload_formfill, $tracks) or die(mysql_error()); $row_rs_nfupload_formfill = mysql_fetch_assoc($rs_nfupload_formfill); $totalRows_rs_nfupload_formfill = mysql_num_rows($rs_nfupload_formfill); if (!isset($_SESSION)) session_start(); ?> I am trying to pull the data from one database for the dynamic text but the "Insert Record" behavior sends the data to another database. Could this be a problem? Everything seems to work OK with the exception that the dynamic data doesn't appear. I can look in cookies and there is a session id set, the login page forwards to the news upload page and the data that is input in both the registration form and the newsupload form does insert into the database. Any ideas here? Please be gentle on the explanations as this is only my 4th website design and my first dynamic site so I'm new to all of this. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/170989-solved-problem-with-dynamic-data-in-registration-form/ Share on other sites More sharing options...
Adam Posted August 19, 2009 Share Posted August 19, 2009 I have the feeling you've not started the session before trying to access session data, though the code I'm not sure if that's in order or what. If it's not already, move "session_start()" to the start of your code and see if that fixes the problem. Quote Link to comment https://forums.phpfreaks.com/topic/170989-solved-problem-with-dynamic-data-in-registration-form/#findComment-901832 Share on other sites More sharing options...
ignace Posted August 19, 2009 Share Posted August 19, 2009 if (!isset($_SESSION)) session_start(); $_SESSION is always set, you can even store data in it but it just won't get saved. Use if (!session_id()) { session_start(); } Quote Link to comment https://forums.phpfreaks.com/topic/170989-solved-problem-with-dynamic-data-in-registration-form/#findComment-901949 Share on other sites More sharing options...
SaturdayNightSpecial Posted August 19, 2009 Author Share Posted August 19, 2009 Thank you very much. I used both suggestions and it Worked! Quote Link to comment https://forums.phpfreaks.com/topic/170989-solved-problem-with-dynamic-data-in-registration-form/#findComment-901994 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.