简体   繁体   English

在PHP中使用Echo Submit Button

[英]Echo Submit Button in PHP

I am trying to echo a submit form in my php code: 我试图在我的PHP代码中回显提交表单:

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 任何帮助,将不胜感激

You're missing a closing parenthesis: 你错过了一个右括号:

if(isset($_POST['submit'])) {
                          ^
                          Here

You're missing a value on the input tag. 您在输入标记上缺少值。 Change it to: 将其更改为:

echo "<input type='submit' name='submit' value='Submit'>";
  echo '<input type="submit" class="btn btn-primary" value="Active">';

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. 否则$ _POST ['submit']将无法设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM