how to clear php form data after submit

Solutions on MaxInterview for how to clear php form data after submit by the best coders in the world

showing results for - "how to clear php form data after submit"
Marco
04 Oct 2019
1// This file is PHP.
2<html>    
3<?php
4    if ($_POST['submit']) {
5        $firstname = $_POST['firstname'];
6        $lastname = $_POST['lastname'];
7        $email = $_POST['email'];
8        $password = $_POST['password'];
9        $confirmpassword = $_POST['confirmpassword'];
10        $strtadd1 = $_POST['strtadd1'];
11        $strtadd2 = $_POST['strtadd2'];
12        $city = $_POST['city'];
13        $country = $_POST['country'];
14        $success = '';
15
16
17        // Upon Success.
18        if ($firstname != '' && $lastname != '' && $email != '' && $password != '' && $confirmpassword != '' && $strtadd1 != '' && $strtadd2 != '' && $city != '' && $country != '') {
19            // Change $success variable from an empty string.
20            $success = 'success';
21
22            // Insert whatever you want to do upon success.
23
24        } else {
25            // Upon Failure.
26            echo '<p class="error">Fill in all fields.</p>';
27
28            // Set $success variable to an empty string.
29            $success = '';
30        }
31    }
32   ?>
33<form method="POST" action="#">
34    <label class="w">Plan :</label>
35    <select autofocus="" name="plan" required="required">
36        <option value="">Select One</option>
37        <option value="FREE Account">FREE Account</option>
38        <option value="Premium Account Monthly">Premium Account Monthly</option>
39        <option value="Premium Account Yearly">Premium Account Yearly</option>
40    </select>
41    <br>
42    <label class="w">First Name :</label><input name="firstname" type="text" placeholder="First Name" required="required" value="<?php if (isset($firstname) && $success == '') {echo $firstname;} ?>"><br>
43    <label class="w">Last Name :</label><input name="lastname" type="text" placeholder="Last Name" required="required" value="<?php if (isset($lastname) && $success == '') {echo $lastname;} ?>"><br>
44    <label class="w">E-mail ID :</label><input name="email" type="email"  placeholder="Enter Email" required="required" value="<?php if (isset($email) && $success == '') {echo $email;} ?>"><br>
45    <label class="w">Password :</label><input name="password" type="password" placeholder="********" required="required" value="<?php if (isset($password) && $success == '') {echo $password;} ?>"><br>
46    <label class="w">Re-Enter Password :</label><input name="confirmpassword" type="password" placeholder="********" required="required" value="<?php if (isset($confirmpassword) && $success == '') {echo $confirmpassword;} ?>"><br>
47    <label class="w">Street Address 1 :</label><input name="strtadd1" type="text" placeholder="street address first" required="required" value="<?php if (isset($strtadd1) && $success == '') {echo $strtadd1;} ?>"><br>
48    <label class="w">Street Address 2 :</label><input name="strtadd2" type="text" placeholder="street address second"  value="<?php if (isset($strtadd2) && $success == '') {echo $strtadd2;} ?>"><br>
49    <label class="w">City :</label><input name="city" type="text" placeholder="City" required="required" value="<?php if (isset($city) && $success == '') {echo $city;} ?>"><br>
50    <label class="w">Country :</label><select autofocus="" id="a1_txtBox1" name="country" required="required" placeholder="select one" value="<?php if (isset($country) && $success == '') {echo $country;} ?>">
51    <input type="submit" name="submit">
52</form>
53</html>
queries leading to this page
php clear post after submitclear the data for form in php using cancel buttonphp clear 24 post data after form submithow to clear form after submit success phphow to stop input clear on submit on phphow to clear form after submit in phphow to reload page after submit phpphp clear post variables after submithow to reset the form after submit in phpphp clear post data after form submitphp code to clear form after submithow to reset form after submit phpclear post after submit phpclear input field after submit phpform data clear in phpclear 24 post data after form submit phphow to make the form clear after submit phphow to use clear field property after submit in phphow to clear all post data after form submit in phpclear fields after submittion phphow to clear form data after submit in php using ajaxphp reset input after submithow to reset data after submitting the form phpclear post data after form submit phphow to clear form after submit using phpclear form posted fileds in phpafter submit data delete phphow to clear a form after submit in phpphp form reset after submitphp submit clear posthow to reset form after submit in phpreset form after submit phphow to keep form data after submit phpclear form data after submission phpphp form submit clear postreset form after submit in phpclear form after submit in phpclearing values from form after submit phpreset form values after submit phpphp clear input after submithow to clear post data after form submit in phphow to clear input field after submit in phphow to clear php form data after submitclear 24 post values after submit phpphp clear form after submitform submit clear in phpphp clear form values after submitphp clear input fields after submithow to clear a form in php so page refresh does not submitclear form data phphow to clear php formphp keep form data after submitclear form after submitting in phpreset form in php after submithow to reset form input on submit with phpclear input value after submit phpform submit and reset phpafter form submition all text box clear how in phphow to clear form php post on redreshreset form php after submitclear a form on submit using phpprevent form clear on submit phpclear form after submit phpphp reset form after submitreset php form after submissionafter form submit data not clear from text box how 3f in phpphp prevent form clearhow to clear form data after submit in phpphp clear form post dataphp how to clear a formafter form submit once how to clear value in phpphp clean data form submit clear the form fields in php after submitclear form data after submission php on the same pagebutton clear form in phphow to clear php form data after submit