Hi, i would like to call a method inside of a class, with “action” tag from form

#1

I know how to do it in Codeigniter, but i’m struggling to find a solution for procedural PHP. Can’t find anything similar on net about my problem

<form action="demo.php">
    <input type="text" id="demo" name="demo"/>
</form>

demo.php page

class Test {
    function example1() {
        --some code here---
        }

    function example2() {
$db = Connection::getInstance()->conn;
	$q = $db->query("INSERT INTO test (name, lastname, text) VALUES('$name', '$lastname', '$text')");
	if($q){
		echo "Inserted";
	}
	else{
		echo "Not inserted";
	}
        }
    }

I would like to call, for example method “example2()” from my “demo.php” page that has class “Test” in it, from my form’s action tag.
How would i do this?
Thank you in advance!

#2

You need a router. CodeIgniter has the router in place to do this, since you are doing procedural, you will need to create your own or look for PHP router to see how they work.

2 Likes
#3

I figured it out already, but thank you for your answer!