Re: Reload page after form submit

From: Date: Thu, 30 Aug 2007 20:14:14 +0000
Subject: Re: Reload page after form submit
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-261546@lists.php.net to get a copy of this message
From: Afan Pasalic <afan@afan.net> rough code, to give you an idea: <?php if (isset($_POST)) { # after validation $first = $_POST['firs']; $last = $_POST['last']; mysql_query("
           insert into table
           (first, last)
           values
           ('".mysql_real_escape_string($first)."', '".mysql_real_escape_string($last)."')
       ");
} else { $query = mysql_query("
           select first, last
           from table
           where id=xyz
       ");
$result = mysql_fetch_array($query, MYSQL_ASSOC); $first = $result['first']; $last = $result['last']; } ?> <form method="POST" action="<?= $_SERVER['PHP_SELF'] ?>"> First: <input type="text" name="first" value="<?= $first ?>"><br> Last: <input type="text" name="last" value="<?= $last ?>"><br> <input type="submit" value="submit"> </form> -afan
Afan, From your rough code, I'd say the OP always needs the select block (just remove the "else" keyword and keep the block) for the current info at the present page refresh/load. But I'd like clarification on how the OP thinks about it. _________________________________________________________________ A new home for Mom, no cleanup required. All starts here. http://www.reallivemoms.com?ocid=TXT_TAGHM&loc=us

« previous php.general (#261546) next »