5

Save entry for next entry

 2 years ago
source link: https://www.codesd.com/item/save-entry-for-next-entry.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Save entry for next entry

advertisements

Well, I have this code:

<form name="download" id="download" method="post" enctype="multipart/form-data">
    <div>
        <label for="beginning_date"><span class="required">*</span> Beginning Date: </label>
        <input type="text" size="30" id="beginning_date" name="beginning_date" value="<?php echo date("d.m.Y"); ?>" required="required" />
    </div>
    <input type="submit" value="Next" name="next"/>
</form>

and php..

if(array_key_exists('next', $_POST))
{
    if (preg_match('/^\d{1,2}\.\d{1,2}\.\d{4}$/', $date))
    {
        //the code continues...
    }
    else
    {
        echo "Wrong formation <br />";
    }
}

This is a long form, and I want that if someone inputs a date like this "02.03.20322", and the error appears, they don't have to start over to fill the form... the form already appears with the "fills field"...

I've already tried like these:

<input type="text" size="30" id="beginning_date" name="beginning_date" value="<?php if (isset($date)) { echo $date; } else { echo date("d.m.Y"); } ?>" required="required" />

but... no changes :(


Looking at your code, there simply is no $date so what you should check for is the existence of $_POST['beginning_date'] instead of $date like so:

<input type="text" size="30" id="beginning_date" name="beginning_date" value="<?php if (isset($_POST['beginning_date'])) { echo $_POST['beginning_date']; } else { echo date("d.m.Y"); } ?>" required="required" />


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK