<kindermaxiz@yahoo.com> wrote in message
news:39615087.0409211721.318a2028@posting.google.c om...[color=blue]
>I have a php script with a form that insert data in a mysql db and
> when I click on submit I would like the page to refresh after the
> insertion, how can I do that? it's a php script that display data from
> a mysql db, and the submit button modify the content of the page yet I
> need to manually refresh to see the result of my insertion.
>
> it kinda looks like this:
>
> echo "<form method=\"post\" action=$php_self>";
> echo "<br>$dispayed_colname:<BR><INPUT TYPE=\"TEXT\" NAME=\"hey\"
> SIZE=\"40\">";
>
> echo "<p><input type=\"submit\" name=\"submit_the_values\"
> value=\"$submit\">
> </form>";
>
> if($submit_the_values){
> $sql=mysql_query("INSERT INTO $tabname($cols_to_insert)". "VALUES
> ($hey)");
>
> //I would like to refresh $php_self here, please tell me if you know
> :)
>
> }[/color]
You could move the query code to the top of the page so that the insertion
would already be done by the time the data is displayed:
<?php
if($submit_the_values){
$sql=mysql_query("INSERT INTO $tabname($cols_to_insert)". "VALUES
($hey)");
}
// ... other stuff
?>
If, for some reason, this isn't satisfactory, you can refresh with this
line:
header("Location: ".$_SERVER["PHP_SELF"]);
Chris Finke
--
I'll send you a gMail invite if you sign up for a free iPod and complete an
offer:
http://www.freeiPods.com/default.aspx?referer=9228418