3

I am trying to echo a submit form in my php code:

I am trying the following:

// Display results
foreach ($media->data as $data) {
echo "<a href=\"{$data->link}\"</a>";
echo "<h4>Photo by: {$data->user->username}</h6>";
echo $pictureImage = "<img src=\"{$data->images->thumbnail->url}\">";
echo "<h5>Like Count for Photo: {$data->likes->count}</h5>";
echo "<form>";
echo "<form action='tag.php' method='post'>";
echo "<input type='submit' name='submit'>";
echo "</form>";
}

Then:

if(isset($_POST['submit'])) {
echo "hello";
}

This doesn't seem to echo "hello";

Any help would be appreciated

asked Jul 31, 2013 at 18:08
3
  • 2
    if(isset($_POST['submit'])) { :P Commented Jul 31, 2013 at 18:09
  • You forgot to close a parenthesis in your if statement. Commented Jul 31, 2013 at 18:09
  • 1
    I would suggest to stop using Notepad as your IDE and choose one that would have saved you time writing this question. Commented Jul 31, 2013 at 18:12

4 Answers 4

6

You're missing a closing parenthesis:

if(isset($_POST['submit'])) {
 ^
 Here
answered Jul 31, 2013 at 18:09
Sign up to request clarification or add additional context in comments.

Comments

1

You're missing a value on the input tag. Change it to:

echo "<input type='submit' name='submit' value='Submit'>";
answered Jul 31, 2013 at 18:29

Comments

1
 echo '<input type="submit" class="btn btn-primary" value="Active">';
answered Apr 12, 2017 at 18:37

Comments

0

It should be

if(isset($_POST['submit'])) {
 ^
 echo "hello";
}

you missed a parenthesis.

Edit: Also it should be:

<input type='submit' name='submit' value='submit'>

Else $_POST['submit'] will not get set.

answered Jul 31, 2013 at 18:09

8 Comments

@asg then your submit variable contains nothing.
@JeffNoel with that form, $_POST['submit'] should return 'Submit' I believe
@asg is that your actual code? I don't the any obvious error.
@TobSpr I'm checking it right now. I doubt the input[type="submit"] elements are sent to the server. I'll edit this post in a few seconds. Edit --> You are right: array (size=1) 'submit' => string 'Submit' (length=6) That might be hell of a good way to check which form sent the data !
Yeah they are sent. I know that many sites check it, to check wheter it was actual their form, because most devs don't know it.
|

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.