form nach submit leeren

Hallo, ich habs erwartet.
Tja, es war ein Versuch wert. Auch in anderen Foren gab es nur einen Versuchsansatz.
Den habe ich allerdings nicht ans Laufen gekriegt.

MONI

PHP:
<?php
    if ($_POST['submit']) {
        $firstname = $_POST['firstname'];
        $lastname = $_POST['lastname'];
        $email = $_POST['email'];
        $password = $_POST['password'];
        $confirmpassword = $_POST['confirmpassword'];
        $success = '';

        if ($firstname != '' && $lastname != '' && $email != '' && $password != '' && $confirmpassword != '') {

            $success = 'success';

        } else {
            echo '<p class="error">Fill in all fields.</p>';

            $success = '';
        }
    }
   ?>
<form method="POST" action="clearformaftersubmit.php">
    <label class="w">Plan:</label>
    <select autofocus="" name="plan" required="required">
        <option value="">Select One</option>
        <option value="FREE Account">FREE Account</option>
        <option value="Premium Account Monthly">Premium Account Monthly</option>
        <option value="Premium Account Yearly">Premium Account Yearly</option>
    </select>
    <br>
    <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 />
    <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 />
    <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 />
    <label class="w">Password:</label><input name="password" type="password" placeholder="***" required="required" value="<?php if (isset($password) && $success == '') {echo $password;} ?>"><br />
    <label class="w">Re-Enter Password:</label><input name="confirmpassword" type="password" placeholder="***" required="required" value="<?php if (isset($confirmpassword) && $success == '') {echo $confirmpassword;} ?>"><br />
    <br />
    <input type="submit" name="submit">
</form>
 
Die inputs sind nicht leer nach submit. Ich habe mich damit aber auch noch nicht wirklich beschäftigt.
 
Dann warten bis morgen, dann weiß ich mehr.
Ansonsten bleibe ich bei der bisherigen Lösung die prüft ob der Eintrag schon vorhanden ist falls ein Submit doppelt bzw. mehrfach erfolgt. Dazu nutze ich ein zusätzliches input type="hidden".

Die Sache ist also nicht so wichtig.

MONI
 

Neue Beiträge

Zurück