jcote65 Posted July 15, 2011 Share Posted July 15, 2011 Hi I am new to PHP coding as I used to create my pages in HTML. I have a form on a site that enables the users to enter various data. I did not create the page, it came with the site, however, I did add all the fields, except for the first 2. My problem is that the description field is only on one line and I need it to be a text area. I added the information field, it does appear as a text area, but when I click on Sauvegarder (save), the field empties and of course that information is not posted. I have attached the page with the defective coding Both the Information and Description fields are mediumblob in the SQL table. Any help would be greatly appreciated Thanks [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/242095-text-area-empties/ Share on other sites More sharing options...
Psycho Posted July 16, 2011 Share Posted July 16, 2011 The text area is named "Information" <textarea rows=\"12\" name=\"Information\" cols=\"31\">$dInformation</textarea> But you appear to be trying to reference the value using "information" mysql_real_escape_string($_REQUEST['information']) Quote Link to comment https://forums.phpfreaks.com/topic/242095-text-area-empties/#findComment-1243313 Share on other sites More sharing options...
jcote65 Posted July 16, 2011 Author Share Posted July 16, 2011 I checked in my SQL table and the word is actually Information, I changed it in my code and the problem remains the same, when I type in the text area it disappears after I click on save (sauvegarder) Quote Link to comment https://forums.phpfreaks.com/topic/242095-text-area-empties/#findComment-1243386 Share on other sites More sharing options...
TeNDoLLA Posted July 16, 2011 Share Posted July 16, 2011 Just the top of my head (didn't look the code) your mysql field names has nothing to do with that what your textarea field is named. If you give textarea a name="Information" then the textarea content will be in variable $_REQUEST['Information'] and not in $_REQUEST['information'] just like mjdamato mentioned. From there you can process, rename or do whatever with the data and save it to the database. Does not matter if textarea has name="Bunny", then the content will be in $_REQUEST['Bunny']. And your db structure is not relevant to that. Quote Link to comment https://forums.phpfreaks.com/topic/242095-text-area-empties/#findComment-1243387 Share on other sites More sharing options...
jcote65 Posted July 16, 2011 Author Share Posted July 16, 2011 I did modify the code everywhere on the page to have Information just like the table, the part of the code you are referencing now looks like this: if ($_REQUEST['save'] != "") { if ($edit) { $SQL = 'UPDATE PosteDisponible_db SET Title = "' . mysql_real_escape_string($_REQUEST['title']) . '", DateDisp = "' . mysql_real_escape_string($_REQUEST['datedisp']) . '", Cabinet = "' . mysql_real_escape_string($_REQUEST['cabinet']) . '", Contact = "' . mysql_real_escape_string($_REQUEST['contact']) . '", Information = "' . mysql_real_escape_string($_REQUEST['Information']) . '", Courriel = "' . mysql_real_escape_string($_REQUEST['courriel']) . '", Description = "' . mysql_real_escape_string($_REQUEST['description']) . '", Body = "' . mysql_real_escape_string($_REQUEST['body']) . '", Deleted = "' . mysql_real_escape_string($_REQUEST['deleted']) . '" '; $SQL .= ", ModifiedDate = NOW()"; $SQL .= ", ModifiedBy = '" .$UserInfo["Usager_id"] . "'"; $SQL .= 'WHERE id = "' . mysql_real_escape_string($_REQUEST['id']) . '"'; } else { $SQL = 'INSERT INTO PosteDisponible_db (Type,Title,DateDisp,Cabinet,Contact,Information,Courriel,Description,Body,Filename,Filetype,Document,CreateDate,CreateBy) VALUES("' . mysql_real_escape_string($_REQUEST['Type']) . '","' . mysql_real_escape_string($_REQUEST['title']) . '","' . mysql_real_escape_string($_REQUEST['datedisp']) . '","' . mysql_real_escape_string($_REQUEST['cabinet']) . '","' . mysql_real_escape_string($_REQUEST['contact']) . '","' . mysql_real_escape_string($_REQUEST['Information']) . '","' . mysql_real_escape_string($_REQUEST['courriel']) . '","' . mysql_real_escape_string($_REQUEST['description']) . '","' . mysql_real_escape_string($_REQUEST['body']) . '",NOW(),"' . $UserInfo['Usager_id'] . '")'; Am I not understanding? thank you for your help Quote Link to comment https://forums.phpfreaks.com/topic/242095-text-area-empties/#findComment-1243390 Share on other sites More sharing options...
TeNDoLLA Posted July 16, 2011 Share Posted July 16, 2011 Do some basic debugging like print_r($_REQUEST) to see if all the values are there that are supposed to be. Also echo out your SQL query to see if it is correct, or maybe missing values or something else what is not normal. Quote Link to comment https://forums.phpfreaks.com/topic/242095-text-area-empties/#findComment-1243395 Share on other sites More sharing options...
jcote65 Posted July 16, 2011 Author Share Posted July 16, 2011 Sorry, I am new to SQL and PHP, where would I put the print_r($_REQUEST) code and what it is supposed to do and also how do I echo out my SQL query and what am I looking for when I do that thank you for your help Quote Link to comment https://forums.phpfreaks.com/topic/242095-text-area-empties/#findComment-1243397 Share on other sites More sharing options...
TeNDoLLA Posted July 16, 2011 Share Posted July 16, 2011 You can put the echo $_REQUEST; in the top of the page for example. It will output the posted data for you when you submit. Then you can see the variables and values that are submitted and see if theres something missing and start looking further why they are missing. And echo $SQL; before running query. Then you see how your SQL queries are formed. You can then inspect them to see if they are correct. Quote Link to comment https://forums.phpfreaks.com/topic/242095-text-area-empties/#findComment-1243399 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.