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
https://forums.phpfreaks.com/topic/224314-submit-form-to-php-function/
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.

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.