Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7799569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:21:14+00:00 2026-06-02T00:21:14+00:00

I have a form that takes some user details, and allows them to upload

  • 0

I have a form that takes some user details, and allows them to upload a file. The file names and information is saved to a csv file.

If the user doesn’t fill in all the fields, the form asks them to fill them and try again. I wanted it to remember the values the user had entered, so I set the default value of the form fields using php:

value="<?php print $fulltitle;?>"

where $fulltitle = $_POST[‘fulltitle’];

However, if the user submits something unsuccessfully, hitting reset does not clear the form, it returns their previous attempts.

How can I make the reset functionality work? In the reset button I tried to use

onclick="<?php $fulltitle='' ?>"

but it seems to have no effect, I guess because the PHP is already processed by the time you hit reset.

Anyone got any suggestions?


EDIT:

Thanks for the help, I solved this with a simple reload as suggested.
For anyone looking for an answer to the problem:

In place of a reset button I put:

<FORM METHOD="LINK" ACTION="resetform.php">
<INPUT TYPE="submit" VALUE="Reset">
</FORM>

In the file resetform.php I have:

<?php
$firstname = '' ;
$lastname = '' ;
$fulltitle = '' ;
$email = '' ;
// etc.

header("Location: submitfile.php");
?>

where submitfile.php is the form

/EDIT


Trimmed code follows…

Header:

<?php
//error_reporting(E_ALL & ~E_NOTICE);
$message = false;

if(isset($_POST['Submit'])){

//user input with commas and < stripped:
    $firstname = str_replace("<","",str_replace(",",";",$_POST['firstname']));

//if values missing, dont process:
    if(empty($firstname)){
        $message =  '<span style="color:red;text-align:center;">Please complete all required(*) fields,<br />and check the file has been selected correctly.</span>';
        $aClass = 'errorClass';
    }

else {
    //return data array cvsData from user input

    $cvsData = $firstname
    fwrite($fp,$cvsData);
    fclose($fp);
    //reset form
    $firstname = '' ;           
    $message = '<span style="color:blue;text-align:center;">Submission successful, thank you.</span>'; 
    }

}
//if page reloaded, clear form:
else {
    $firstname = '' ;
    }

?>

Body:

<form enctype="multipart/form-data" id="form1" name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>" >
<table>
<?php
if ($message != false)
    {
    print "<tr><td colspan='2'><span align='center'>" . $message . "</span></td></tr>";
    }
?>  

<tr>
    <td width="200"><span class="texto">*First Name(s)</span></td>
    <td><input type="text" name="firstname" id="firstname" value="<?php print $firstname;?>" /></td>
</tr>

<tr>
    <td colspan="2">
        <div align="center">
            <input type="submit" name="Submit" id="Submit" value="Submit"/>
            <input type="reset" name="Reset" id="Reset" value="Reset" />
        </div>
    </td>
</tr>
</table>

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T00:21:16+00:00Added an answer on June 2, 2026 at 12:21 am

    Hitting reset will just reset the form to it’s original values. In your case it’s their original form submission values because that’s what you’re setting in the value attribute. You need to use JavaScript to delete the form values completely if you want to present the user a blank form.

    Here’s a JavaScript snippet that should do it:

    function clear_form_elements(ele) {
    
        tags = ele.getElementsByTagName('input');
        for(i = 0; i < tags.length; i++) {
            switch(tags[i].type) {
                case 'password':
                case 'text':
                    tags[i].value = '';
                    break;
                case 'checkbox':
                case 'radio':
                    tags[i].checked = false;
                    break;
            }
        }
    
        tags = ele.getElementsByTagName('select');
        for(i = 0; i < tags.length; i++) {
            if(tags[i].type == 'select-one') {
                tags[i].selectedIndex = 0;
            }
            else {
                for(j = 0; j < tags[i].options.length; j++) {
                    tags[i].options[j].selected = false;
                }
            }
        }
    
        tags = ele.getElementsByTagName('textarea');
        for(i = 0; i < tags.length; i++) {
            tags[i].value = '';
        }
    
    }
    

    Then put this in your reset button:

    onclick="clear_form_elements(this.form[0])"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an upload form that takes a user about 30 min. to complete.
I have a form that takes some input from a user and then gets
I have a multipart form that takes basic user information at the beginning with
Say I want to have a simple web app that takes some user input,
I have a form that takes the following inputs: Name: IBM Surface(in m^2): 9
I have a form that takes in a number of fields about a camera's
So i have a simple form that takes a few inputs (two text and
I have a recursive method on the base form that takes in a control
I have a form on my website that takes input from a text area
I have a website that just takes a really big form and saves the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.