Jump to content

How can i call a function of another page on submit button of a form???


hmdnawaz

Recommended Posts

I have two pages one is db.php and another is form.php.

 

In form.php i have created a form which contains different fields and a submit button.

But i want to write the queries in db.php.

 

And when i click on the submit button the insert query in db.php should be executed and insert data in database but the focus remains on form.php.

 

How can i do this???

Any Idea?

<form action="db.php">

 

Obviously there will be more things inside the form tag, but I couldn't be bothered writing them, the action is all you need to make the form send to another php script :).

 

Denno

you can have an if statement at the top of the page, so see if anything has been posted. And then include the db.php file in that. Else, nothing.

 

You give the form no action, so that the same page is loaded, and the if condition is run. This way you can leave all of your query information in the db.php file, and you keep focus on the form.php page, as you originally asked.

 

reference: http://stackoverflow.com/questions/595358/how-can-i-execute-a-php-function-in-a-form-action

 

I found the above link doing a very simple google search....

 

Denno

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.