php PHP中的回声提交按钮

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17977739/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 16:44:49  来源:igfitidea点击:

Echo Submit Button in PHP

phphtmlforms

提问by qweqweqwe

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

任何帮助,将不胜感激

回答by nickb

You're missing a closing parenthesis:

你缺少一个右括号:

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

回答by bikefever

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

您在输入标签上缺少一个值。将其更改为:

echo "<input type='submit' name='submit' value='Submit'>";

回答by Siddharth Shukla

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

回答by tobspr

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'] 将不会被设置。