Re: Reload page after form submit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Afan Pasalic <afan@xxxxxxxx>

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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux