Search code examples
phphtmlwebsubmitforum

Executing a php method when submit is pressed


Here is my php code, which isn't working:

<?php

echo('
<forum>
    <input type = "submit" value = "Previous" name = "Previous"/>
    <input type = "submit" value = "Next" name = "Next"/>
</forum>');

if(isset($_POST['Previous']))
    echo("Previous");

if(isset($_POST['Next']))
    echo("Next");

?>

When I press the buttons, nothing happens.

Is it possible to do such things in PHP? If not, what would be a good alternative to achieve the same outcome?


Solution

    1. it's form, not forum
    2. if you want it to do post request you need to add method attribute: <form method="post">