Jump to content

how to retrieve text area content to store to variable


mpsn

Recommended Posts

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!

Link to comment
Share on other sites

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;
}

Link to comment
Share on other sites

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..

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.