tags:

views:

60

answers:

4

hey guys

im using a form in php to submit some information into my database

so i used two function to do this

but how to show the result in th same page that has the form

A: 

Forgive me if I am wrong. I think you have copied the code from some where and using it without understanding how forms work.

<form action='index.php?op=ban' method='post'>

The above code says to which page the values should be submitted. As you can see above the values in the form will be submitted to index.php. So the DB operations will(should) happen in index.php and the Thank you message can be shown in index.php.

If you want to show your result in the same page then you will have to submit to the page in which the form resides. But in this case you should have a logic in the page to decide whether the form was submitted or was it loaded first time.

The code snippet in your question does not tell us name of the file the code exists so we wont be able to tell you whether the result will be shown in the same page. Aslo the source code is not complete.

Post a detailed source code and we will be able to help. Hope it helps.

Shoban
Nice one. Somewhat more detailed than mine ;) +1
Franz
i forgive u , and i found out the solution by myself ,
Mac Taylor
A: 

It's as easy as this:

if (isset($_POST['submit']))
{
    // do something with your data
}

form();
Franz
+1  A: 

To load the same page you have to assign the variable $_SERVER[PHP_SELF] for the form action field.

<form action='$_SERVER[PHP_SELF]?op=ban' method='post'>

then when the page get load you just check the post variable ,if it contains the appropriate data then print the result with the form.(Normally people using div tag to print the results )

karthi_ms
A: 

it should be shown on the next request.
because your app should perform an HTTP redirect after POST request. it can be same page though

Col. Shrapnel