Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML

*Answered* Submitting text in a <textarea>, but have the submitted text remain after submitting?

Sorry guys for the stupid title, I wasn't sure what to put really, and that pretty much explains it exactly how it is. :)

Basically I'm making a plugin for WordPress, and inside my admin settings, I have a few options to change, and there is a <textarea> tag there also.

What I can't figure out how to do, is once the user has inserted their text, and then clicked the submit button, the page refreshes, but the text is gone and inserted into the database. I want to have the text inputted, remain in that text box, so the user can come back and edit whatever is in there, whenever they want.

My plugin is adding custom text onto the site that the user wants to have.

There is a screenshot of my admin page, and of the textarea. Here is also a snippet of my current code for the textarea:

My custom settings page

    <table class="form-table">
    <tr valign="top">
    <th scope="row">Text Color</th>
    <td><input type="text" name="new_option_name" value="<?php echo get_option('new_option_name'); ?>" /></td>
    </tr>

    <tr valign="top">
    <th scope="row">Some Other Option</th>
    <td><input type="text" name="some_other_option" value="<?php echo get_option('some_other_option'); ?>" /></td>
    </tr>

    <tr valign="top">
    <th scope="row">Options, Etc.</th>
    <td><input type="text" name="option_etc" value="<?php echo get_option('option_etc'); ?>" /></td>
    </tr>

    <tr valign="top">
    <th scope="row">Font Size</th>
    <td><input type="text" name="font_size" value="<?php echo get_option('font_size'); ?>" /></td>
    </tr>

    <tr>    
    <th scope="row">Text Area</th>
    <td><textarea name="post_text" cols="60" rows="10"><?=$post_text?></textarea></td>  

    </tr>

</table>

<?php submit_button(); ?>

Sorry if it doesn't 'markdown' properly.

Any and all help is massively appreciated guys and gals. :)

Thank you.

Casey.

2 Answers

I'm sorry, I managed to get this sorted myself! =0)

Although, I probably have another question coming up hehe.

Good hustle Casey! :)