Jump to content

Submit form to php function.


President Obama

Recommended Posts

Is it possible to link action in the form to a function thats included from a functions file? Like so:

 
        <form action="<?php add($text); ?>" >
        <input type="text" name="text"   />
        <input type="submit" />
        </form>

What I want to do is add a block of text to the database. The add function does that. So ideas? I have like 9 of these forms on the same page they all do different things though but all involve modify the database.

Link to comment
Share on other sites

The action="" attribute is the URL that the form data will be submitted to. Forms only exist in the browser/client and the only thing the client can do is make HTTP/HTTPS requests to the server. You cannot 'call' php functions from the browser.

 

You would need to specify, either by using completely different URLs/pages for each different operation, a GET parameter on the end of one URL, or using a hidden form field value what you want the php code to do when the form is submitted to whatever URL you put into the action="" attribute.

Link to comment
Share on other sites

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.