2

I have a table and use the following to create a button inside one of the cells:

print("<td> <input type=\"submit\" name=\"toedit\" value=\"Submit\" >
    <form action=\"Manage_Customer_Information_refined_list.php\" method=\"post\">
        <input type=\"hidden\" value=\"Submit\" name =\"submit_button\" >
    </form>
</td>");

When i go to call upon the button (press it) using

if(print_r($_POST["\"submit_button\""]))
{
    print "button pressed";
}

It says

undefined index "submit_button"

Please Help :/

1
  • There are so many things wrong here. But lets stick to the obvious. print_r is a function with highly mixed return values, it can return a bool, a string, an int, a float, god knows what, it depends on the context. However, to keep this simple, print_r doesn't belong in that if. It should be something like this if(isset($_POST['submit_button'])) Commented Aug 31, 2015 at 11:28

4 Answers 4

2

try this

print("<td> 
    <form action=\"Manage_Customer_Information_refined_list.php\" method=\"post\">
        <input type=\"hidden\" value=\"Submit\" name =\"submit_button\" >
        <input type=\"submit\" name=\"toedit\" value=\"Submit\" >
    </form>
</td>");

and if you want to submit on same page then remove Manage_Customer_Information_refined_list.php form form.

Sign up to request clarification or add additional context in comments.

Comments

1

Change

<input type=\"hidden\" value=\"Submit\" name =\"submit_button\" >

to

<input type=\"submit\" value=\"Submit\" name =\"submit_button\" >

Remove

<input type=\"submit\" name=\"toedit\" value=\"Submit\" >

Comments

1

Change your condition to this

if(isset($_POST["submit_button"]))
{
   print "button pressed";
}

Comments

1

The code you write <input type=\"hidden\" value=\"Submit\" name =\"submit_button\" > will be evaluated to ... name="submit_button" which means you should access this input value from the server side using $_POST["submit_button"].

The way you did write $_POST["\"submit_button\""] expect the input field to be written as <input type=\"hidden\" value=\"Submit\" name =\"\"submit_button\"\" > and i don't think that this is a valid syntax, also you should put the submit button inside the form not outside of it.

Comments

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.