Current location: Hot Scripts Forums » Programming Languages » PHP » Update Form + Update Query in one file


Update Form + Update Query in one file

Reply
  #1 (permalink)  
Old 07-20-06, 06:17 PM
sod_atticus sod_atticus is offline
Newbie Coder
 
Join Date: Jul 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Update Form + Update Query in one file

Hi,

Can anyone help me with a problem?

The thing is : I want the query & the update form in the same file.

So when there's POST data the query will run and alter the records in my database, and then show the new results
So when there IS NO POST data the page will just show the update form.

Is this possible?

// I think the form action should be something like

PHP Code:

action="<?php echo $_SERVER['PHP_SELF']?>"
But how do I tell the script only to update the records when there's POST data?
Otherwise it will empty the records when there's no data
Reply With Quote
  #2 (permalink)  
Old 07-21-06, 02:15 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
PHP Code:



if (isset($_POST))
{
    
// Update
}
else
{
   
// Show form

If you want the form to be submitted to the same page, you can either use the code you've posted, or you can just leave the action="" in blank.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
HTML code file update on the webserver using CGI script sujata_ghosh Perl 31 07-06-06 03:06 AM
Write form data to file dragge PHP 1 12-27-03 07:26 PM
Upload file to table so ONLY files tied to primary key are displayed in record? grafixDummy PHP 4 12-20-03 04:28 PM
Declared Functions skipper23 PHP 4 12-17-03 10:06 AM
index page not showing up skipper23 PHP 3 12-15-03 01:10 PM


All times are GMT -5. The time now is 07:22 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.