-6

I have a form which actions against a php file. Once the form is completed and the data is inserted into the databse, it want it to display "Awesome". Awesome is being displayed but is above the form. I want it to replace the form and display awesome. How do i do that?

Thank You.

if($done )
{
    echo "Awesome";
}
else
{
    echo "Error";
}
kapa
  • 77,694
  • 21
  • 158
  • 175
Johnson
  • 17
  • 1
  • 1
  • 8

3 Answers3

8

You can make wonders with the if/else control structure.

kapa
  • 77,694
  • 21
  • 158
  • 175
  • thanks for the link, but that is not my question. Can i replace the msg with the input button, instead of having to display the msg on top of the button? – Johnson Nov 07 '10 at 13:39
  • @Johnson: The code you showed us doesn't even show any input button. And it doesn't have any indication of what $done represents or where it came from. – bcosca Nov 07 '10 at 13:46
  • that's just the part....i'll post the rest – Johnson Nov 07 '10 at 13:47
  • $done is passing the php query – Johnson Nov 07 '10 at 13:47
  • once the if condition is made true, awesome is displayed but above the input button.i want it to replace the button and display awesome. – Johnson Nov 07 '10 at 13:48
4

Presumably you have something along the lines of:

if (condition) {
    Awesome
} 
The Form

Change it to

if (condition) {
    Awesome
} else {
    The Form
}
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
1

If you are overwhelmed with structuring your code in a way that gives the desired result, then you should take advantage of PHPs include() capability. Put your form in a second file, then rewrite your result logic:

if($done )
{
    echo "Awesome";
    include("form.php");
}
else
{
    echo "Error";
}

Or wherever you want the form to appear.

mario
  • 144,265
  • 20
  • 237
  • 291