PHP submit form issues

They have: 1 posts

Joined: Apr 2010

Hi Everyone

This is my first time posting here... I have been searching long and hard for a solution to my problem and hopefully someone here will be able to help me... I have a simple PHP email form that I have created for my writers to email articles to me, a sort of simple CMS system for text articles... It works great for emailing the fields of the forms and I even got it to save the fields into my database and in a .txt file on my server... However, there is a problem, and that is that the form gets cleared whenever my writers submit the it.

This means that if they want to make any changes to the already submitted article, they will have to re-upload everything and resubmit it with corrections they have made in a word processor of some kind. This is a huge hassle for them, so I want to know is if there is any way that i can sort of save the data they entered into the form on the form so that when they log out and back in later it is still there and they can simply modify it on the site and resubmit it easier without needing to fill in all the fields again ? I am not looking for a file upload thing, I would like to use the form I have as it works perfectly expect for that one issue. Please help?????????????

Thanks
Shaun

Greg K's picture

He has: 2,145 posts

Joined: Nov 2003

Since you say they are logging in an out, I'll assume you already have some type of user account system in place.

When they submit the item, have it save their userid with the article. Then when they log back in, look it up via their user ID, then display that data in the form. assuming below $aryArticle contains all the fields from the database:

<input type="text" name="txtTitle" value="<?php echo htmlspecialchars($aryArticle['Title']); ?>" />

<fieldset>
    <legend>Status</legend>
    <input type="radio" name="radStatus" value="Published" <?php echo ($aryArticle['Status']=='Published')?'selected="selected"':''; ?> /> Published<br />
    <input type="radio" name="radStatus" value="Draft" <?php echo ($aryArticle['Status']=='Draft')?'selected="selected"':''; ?> /> Draft <br />
</fieldset>
Body: <br />
<textarea name="txtBody" cols=120 rows=20><?php echo htmlspecialchars($aryArticle['Body']); ?></textarea>

-Greg

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.