Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php keep input value after submit

<input type="text" name="myField1" value="<?php echo isset($_POST['myField1']) ? $_POST['myField1'] : '' ?>" />
Comment

keep value after submit php

// Author: Rimon(ProgrammerRimon), this code was pasted by ProgramemrRimon
// Date: 2022-02-19, 3:29 AM GMT + 6
<?php

if (isset($_REQUEST['f'])) echo 'Fruits: ' . $_REQUEST['f'];
echo "<br>";
if (isset($_REQUEST['v'])) echo 'Vagetables: ' . $_REQUEST['v'];
global $v, $f;
$f = ['apple', 'banana', 'papaya', 'mangos', 'carrot', 'grapes', 'guava', 'strawbarries', 'watermelons', 'Pomegranates'];
$v = ['lettuce', 'cabbage', 'onion', 'garlic',  'Asparagus', 'Rhubarb', 'Celery', 'Spinach', 'Arugula', 'Broccoli'];
function s($a, $n)
{
    $s = '';
    foreach ($a as $key => $value) {
        if (isset($_REQUEST[$n])) {
            if ($_REQUEST[$n] == $value) {
                $s = 'selected';
            } else {
                $s = '';
            }
        }
        echo "<option $s value='" . $value . "' >$value</option>";
    }
}
?>
<form action="" method="post">
    <select name="f" id="">
        <?php s($f, 'f'); ?>
    </select>
    <br>
    <select name="v" id="">
        <?php s($v, 'v'); ?>
    </select>
    <input type="submit" value="Submit">
</form>

Comment

PREVIOUS NEXT
Code Example
Php :: Ajax refreshing custom mini-cart count and content in Woocommerce 
Php :: encapsulation in php 
Php :: laravel guard 
Php :: php unix socket client 
Php :: wpquery search taxonomy 
Php :: laravel get route 
Php :: withcookie function in php 
Php :: laravel make job command 
Php :: make model factory and controller laravel 
Php :: difference between array_merge and + 
Php :: checkout 
Php :: wp wordPress variables de session 
Php :: Using $this when not in object context 
Php :: php function use 
Php :: wherebetween laravel 
Php :: laravel get next and previous record 
Php :: How to insert header in php 
Php :: php class 
Php :: laravel all 
Php :: wordpress get all published post 
Php :: list function php 
Php :: php DateTime only date 
Php :: php array in variable 
Php :: how to delete database in phpmyadmin 
Php :: laravel eloquent relationships 
Php :: insert into php myqsl 
Php :: default time of session in php 
Php :: how to create object in php 
Php :: create symfony project 
Php :: laravel admin disable batch selection 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =