SchweppesAle Posted August 20, 2008 Share Posted August 20, 2008 basically I'm trying to use a Text Area form to post each resume within a LONGTEXT column. The data is entered correctly, it just loses all formating-how would I go about correcting this? index.php which contains the form <form action="Insert.php" method="post"> Name: <input type="text" name="Name" /> <br/> Number: <input type="text" name="Number" /> <br/> Resume: <TEXTAREA name = "Resume" ROWS = 47 COLS = 110 wrap = physical></TextArea> <br/> <Font size = -1>Maximum of 500 characters</Font> <br/> <input type="submit" Value= "Submit Resume" > </form> Insert.php <?php include("Connect.php"); DBConnect(); mysql_select_db("Jobs"); $Name = $_POST['Name']; $Number = $_POST['Number']; $Resume = $_POST['Resume']; mysql_query("INSERT INTO AvailableJobs (Name, Number, Resume) VALUES('$Name', '$Number', '$Resume') ") or die(mysql_error()); echo("Data Inserted"); ?> Quote Link to comment Share on other sites More sharing options...
akitchin Posted August 20, 2008 Share Posted August 20, 2008 if you're talking about the newline formatting and tab characters, chances are the data isn't losing it. it's just ignored when it gets output to HTML. some functions that might help are: nl2br() (use when outputting, not when saving) also have a look into the <pre> tag, which will preserve the simple whitespace formatting such as tab characters. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted August 20, 2008 Share Posted August 20, 2008 just a heads up do not do inserts without properly escaping the data into the database first. Quote Link to comment Share on other sites More sharing options...
SchweppesAle Posted August 20, 2008 Author Share Posted August 20, 2008 just a heads up do not do inserts without properly escaping the data into the database first. not exactly sure what that means. Also the nl2br function seems to have helped but everything which was aligned to the right hand side of each resume is instead moved a line down. :-\ Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted August 20, 2008 Share Posted August 20, 2008 mysql_real_escape_string() should go around stuff going into the database (at a basic point of view) You also need to be observant html tags/php coding isn't going into places it could be reexecuted from. Quote Link to comment Share on other sites More sharing options...
akitchin Posted August 20, 2008 Share Posted August 20, 2008 could it be that things aligned right are now outside of the allowable width? try echoing the resume's text within those pre tags, and see what they look like. @cooldude: while encouraging data cleaning is useful, please stick to the question at hand, otherwise you derail the thread. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted August 20, 2008 Share Posted August 20, 2008 @cooldude: while encouraging data cleaning is useful, please stick to the question at hand, otherwise you derail the thread. I am because in mysql the slashes are/aren''t gonna to be escaped and thus \n will be n Quit being so harsh to someone helping. Quote Link to comment Share on other sites More sharing options...
SchweppesAle Posted August 20, 2008 Author Share Posted August 20, 2008 sweet~! thanks a lot guys, looks like that did the trick. Set a width within the pre element and everything came out just the way I entered it. One last question before we let this thread die though-the current code I'm using for the html form: <form action="Insert.php" method="post"> Name: <input type="text" name="Name" /> <br/> Number: <input type="text" name="Number" /> <br/> Resume: <TEXTAREA name = "Resume" ROWS = 47 COLS = 110 wrap = physical></TextArea> <br/> <Font size = -1>Maximum of 500 characters</Font> <br/> <input type="submit" Value= "Submit Resume" > </form> <a href = "Query.php"> Query </a> It seems users are unable to push the tab button without changing over to a different form. Also, if I copy and paste anything from openoffice writer it doesn't seem to preserve the alignment of all the text entered. Is there a quick fix for this? Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted August 20, 2008 Share Posted August 20, 2008 the text element field and textarea field don't allow the characters of \n or \t to show (and some others) you can write in \n or \t into it to get them in there. Quote Link to comment Share on other sites More sharing options...
SchweppesAle Posted August 20, 2008 Author Share Posted August 20, 2008 the text element field and textarea field don't allow the characters of \n or \t to show (and some others) you can write in \n or \t into it to get them in there. damn, i'm such a noob Should probably go find a good book on Javascript. Might help me throw some of these ideas together. I'm not sure my boss' clients would be thrilled if we told them to throw in a \n here and there to make sure their resume is lined up correctly. Gonna have to try something else I guess. Quote Link to comment Share on other sites More sharing options...
akitchin Posted August 20, 2008 Share Posted August 20, 2008 that's a flat-out lie. textareas will process \n and \t. chances are they are converted to different characters when input into openoffice. if you'd like to give the user an option to insert a tab character, your best bet is to copy and paste it. unfortunately, tab is too valuable a button for application browsing. if you input \n and \t directly, it won't work, but that's because those aren't the characters you want to input. those will be considered the actual characters (backslash and letter). copying and pasting from other sources has always been tricky for textareas. rule of thumb is the way it looks in notepad = the way it will look in textarea and pre. if you'd like to offer them more options for formatting (and copying from other sources), perhaps have a look into tinyMCE, a rich HTML editor that you can slot into the form. Quote Link to comment Share on other sites More sharing options...
SchweppesAle Posted August 20, 2008 Author Share Posted August 20, 2008 that's a flat-out lie. textareas will process \n and \t. chances are they are converted to different characters when input into openoffice. if you'd like to give the user an option to insert a tab character, your best bet is to copy and paste it. unfortunately, tab is too valuable a button for application browsing. if you input \n and \t directly, it won't work, but that's because those aren't the characters you want to input. those will be considered the actual characters (backslash and letter). copying and pasting from other sources has always been tricky for textareas. rule of thumb is the way it looks in notepad = the way it will look in textarea and pre. if you'd like to offer them more options for formatting (and copying from other sources), perhaps have a look into tinyMCE, a rich HTML editor that you can slot into the form. thanks dude, that actually sounds like a good idea. I'll look into it now. Quote Link to comment Share on other sites More sharing options...
akitchin Posted August 20, 2008 Share Posted August 20, 2008 i will warn you that in order to get tinyMCE working the way you want it, you're going to have to invest a fair bit of time tinkering with little nuances in the HTML that it gives you for storage. is there a reason you're using the copy/paste method rather than allowing users to upload their resumes? Quote Link to comment Share on other sites More sharing options...
SchweppesAle Posted August 26, 2008 Author Share Posted August 26, 2008 i will warn you that in order to get tinyMCE working the way you want it, you're going to have to invest a fair bit of time tinkering with little nuances in the HTML that it gives you for storage. is there a reason you're using the copy/paste method rather than allowing users to upload their resumes? ..... .... *crickets* alright, we'll do it your way. lol Quote Link to comment Share on other sites More sharing options...
akitchin Posted August 26, 2008 Share Posted August 26, 2008 no no, if you need to let users copy and paste, by all means do so. i was just warning you that from personal experience, getting tinyMCE to work the way you want it to, you might need to invest some time. Quote Link to comment 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.