Re: Reload page after form submit

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

 



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




From: "Wagner Garcia Campagner" <wagnergc@xxxxxxxxxxx>

Hello,

I'm building a web page just like a blog...

Where the user input some information... (name, website and comment)

This information is stored in a file...

And then the page displays it...

When the user access the page the first time, the information is displayed
correct...

After the user submit the information, the page become outdated... without
this last information the user submitted...

Is there a way to tell PHP to reload the page after the user submit the
information, so the page is always updated??

Thanks in advance,
Wagner.

--
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