Jump to content

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


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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.