如何使用 php 将表单信息插入 html 按钮


How to insert form information into html button with php

这就是我想要完成的目标。当用户创建配置文件时,他们会使用表单填写一些信息。他们提交表格后,信息将显示在其个人资料中。其中一个表单字段将是一个按钮,其他用户可以通过单击该按钮来执行操作。要显示按钮,这是我目前拥有的 PHP:

add_action('kleo_bp_after_profile_name', 'my_profile_button');
function my_profile_button()
{
echo '<a href="#" class="success button radius show-for-small" rel="nofollow">Talk</a>';
}

我需要将表单信息输入到 href="#" 位置。有谁知道解决这个问题的方法?

谢谢。

听起来您只想提交用户填写的表单。 如果是这种情况,则无法使用链接,但需要使用按钮:

<form action="submitpage.php" method="post">
    Name: <input type="text" />
    <input type="submit" value="Some Text" />
</form>

<form action="submitpage.php" method="post">
    Name: <input type="text" />
    <button type="submit" class="success button radius show-for-small">Some Text</button>
</form>

当然,如果您使用名为"重定向"的 POST 变量捕获了该信息,则可以使用它来生成按钮。问题是我不太明白你的意思是放入 href="#" 点,因为按钮没有该属性,所以我编写了代码以在单击按钮时完成的重定向中使用它:

<input type="button" value="submit" onclick="location.href='<?php echo $_POST["redirect"];?>';">

如果你想在链接中使用信息,实际上有 href 属性,请使用这个:

<a id="link" href="<?php echo $_POST['redirect'];?>">Text of the link</a>