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
qweqweqwe
3435 gold badges8 silver badges19 bronze badges
4 Answers 4
You're missing a closing parenthesis:
if(isset($_POST['submit'])) {
^
Here
answered Jul 31, 2013 at 18:09
nickb
59.7k13 gold badges115 silver badges149 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
You're missing a value on the input tag. Change it to:
echo "<input type='submit' name='submit' value='Submit'>";
Comments
echo '<input type="submit" class="btn btn-primary" value="Active">';
answered Apr 12, 2017 at 18:37
Siddharth Shukla
1,14715 silver badges15 bronze badges
Comments
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
tobspr
8,4265 gold badges36 silver badges48 bronze badges
8 Comments
Jeff Noel
@asg then your
submit variable contains nothing.tobspr
@JeffNoel with that form,
$_POST['submit'] should return 'Submit' I believetobspr
@asg is that your actual code? I don't the any obvious error.
Jeff Noel
@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 !tobspr
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.
|
default
if(isset($_POST['submit'])) {:Pifstatement.