how do you clear a php page

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

ukmdb
New php-forum User
New php-forum User
Posts: 7
Joined: Sat Jun 21, 2003 12:56 pm

how do you clear a php page

Postby ukmdb » Tue Jun 24, 2003 1:56 am

Hi everyone.
Is there a command to clear a page. ?

I am linking to the page itself php_self
however i would like to clear the page before the next text is
shown

How. ?

User avatar
bezmond
Moderator
Moderator
Posts: 312
Joined: Sat Apr 05, 2003 4:33 am
Location: Mansfield, UK
Contact:

Postby bezmond » Tue Jun 24, 2003 2:20 am

what do you mean clear the page? Delete all the text currently shown?

Andrew

ukmdb
New php-forum User
New php-forum User
Posts: 7
Joined: Sat Jun 21, 2003 12:56 pm

Postby ukmdb » Tue Jun 24, 2003 5:16 am

bezmond, thanks for your reply,

Yes, I have a text box where uses can submit to a database.
the page then reloads itsself and adds the submitted text to the database and thanks the user for the submission, but the text form box is still there.

How can i delete the text box so that only the thank you displayed.

I did not know if there was a simple cls, clear command or anything like that with PHP, i can not find anything.
And am sure there must be a simple answer.

Linking to a new page would not work as then the database would not be updated.

Thanks for any help you can give

NigWel
New php-forum User
New php-forum User
Posts: 2
Joined: Tue Jun 24, 2003 5:58 am
Location: Leicester (UK)

Postby NigWel » Tue Jun 24, 2003 6:13 am

Hello mate,

What you need to do is something like this:

<?php

if(!isset($_POST['submit'])) //if the form has been submitted
{
show_form();
}
else
{
process_form();
}

define two functions for each of the above like:
function process_form()
{
//processing code here, then
?>
Thanks for posting your submission
<?
}

function show_form()
{
//form html goes here
}
?>

This will basically, show the form and when the user presses submit, will process the form data as defined in the function process_form(), and display a thank you notification.

hope this helps!
Regards, Nigel

User avatar
bezmond
Moderator
Moderator
Posts: 312
Joined: Sat Apr 05, 2003 4:33 am
Location: Mansfield, UK
Contact:

Postby bezmond » Tue Jun 24, 2003 10:22 am

yeah that should work perfectly :)

ukmdb
New php-forum User
New php-forum User
Posts: 7
Joined: Sat Jun 21, 2003 12:56 pm

Postby ukmdb » Wed Jun 25, 2003 3:41 am

thanks guys,
Took a while for me to understand, but have managed it perfectly. Thank you so much


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 1 guest

cron