0

I am currently attempting to run a piece of code via php which will create a table in which values can be inputted into the table and updated via an ajax call. This latter part is not the problem.

However, despite a similar style of program working in the document, the submit button doesn't actually do anything at all. I attempted to add a hidden field to the button, but nothing registered. Below is the code on the pages:

Original button, linked on an include and posting to the main page:

<form action="main.php" method="post">
 <input type="hidden" name="hidden" value="13timesasecond"/>
 <input type="button" id="clicky" value="Create" name="create"/>
</form>

main homepage, for validations' sake.

    if (isset($_POST['hidden'])) {
    include_once $includepath."module.inc.php";
    echo $_POST['hidden'];
}
else {
    echo "The button broke :(";
}

The actual module:

echo "<div class=dataset>
    <p><u>New Dataset</u></p>
    <form>
        <input type=radio name=rating value=red> Red
        <input type=radio name=rating value=amber> Amber
        <input type=radio name=rating value=green> Green
    </form>
    <table border=1 align=left>
            <tr>
                <td>Field 1</td>
                <td>Field 2</td>
                <td>Field 3</td>
                <td>Field 4</td>
            </tr>
            <tr>
                <td><input type=text/></td>
                <td><input type=text/></td>
                <td><input type=text/></td>
                <td><input type=text/></td>
            </tr>
        </table>   
 </div>";

The other stuff is currently not done, and the issue is with the button not actually causing anything to echo on click despite other pages using almost exactly the same thing in the website.

2
  • 1
    Does the page reload? Commented Jul 25, 2016 at 14:38
  • All the other ones do, except this one. Commented Jul 25, 2016 at 14:38

1 Answer 1

1

Change the type of input from button to submit:

<form action="main.php" method="post">
 <input type="submit" id="clicky" value="Create" name="create"/>
</form>
Sign up to request clarification or add additional context in comments.

2 Comments

Alright, I cannot believe I missed that. It works, and I can't believe it was that simple.
Done. Time restrictions prevented me from doing it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.