mpsn Posted November 3, 2011 Share Posted November 3, 2011 Hi, I want to be able to let user type in xml text and it will be parsed and uploaded to db, but it doesn't work, it just keeps redirecting me back to this form below! here is html form: <html> <body> <form method='post' method='form.php'> <p> <textarea name="pastedXML" rows="10" cols="30"> Please paste your xml file here. </textarea> </p> <p> <input type="submit" value="Convert to SQL" name="textXML" /> </p> </form> </body> </html> Here is script (form.php;I just want to retrieve the contents typed in text area to store to variable...how??) <?php //get the text in textarea and shred it! if(isset($_POST['textXML'])) print $_POST['pastedXML']; ?> Any help much appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/250348-how-to-retrieve-text-area-content-to-store-to-variable/ Share on other sites More sharing options...
creata.physics Posted November 3, 2011 Share Posted November 3, 2011 your php code just outputs what is typed ito the textbox. all you've said is you want the text stored into a new variable, since it is already stored in $_POST so this is how you would do so: if(isset($_POST['textXML'])) { $variable_string = $_POST['pastedXML']; echo $variable_string; } Quote Link to comment https://forums.phpfreaks.com/topic/250348-how-to-retrieve-text-area-content-to-store-to-variable/#findComment-1284508 Share on other sites More sharing options...
mpsn Posted November 3, 2011 Author Share Posted November 3, 2011 Yes, I meant to store to variable, but I can't even display it to browser screen, once I press submit it just redirects me to the text area form again! Any help much appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/250348-how-to-retrieve-text-area-content-to-store-to-variable/#findComment-1284509 Share on other sites More sharing options...
Zane Posted November 3, 2011 Share Posted November 3, 2011 once I press submit it just redirects me to the text area form again! This can only happen if you code it to happen. Your form points to form.php on submit, now unless form.php is the same page the form is on then there is no other way to get that problem unless you are using a redirect EDIT : Oh ok. I see Here is script (form.php;I just want to retrieve the contents typed in text area to store to variable...how??) So the form and the script ARE on the same page. Why the big surprise? If you submit to the same page... of course the form will show up again. If you want to display XML data the user has typed in then you must submit to another file with XML headers. ... or just ... don't display the form again on submission and set the headers.. Quote Link to comment https://forums.phpfreaks.com/topic/250348-how-to-retrieve-text-area-content-to-store-to-variable/#findComment-1284511 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.