Php 我想让我的输入在点击按钮时得到它的值

Php 我想让我的输入在点击按钮时得到它的值,php,Php,我需要帮助:如何在我的输入中获取按钮的名称。我有两个文件(index.php,contact.php)。我的按钮在index.php中,表单在contact.php中 contact.php file <form class="form" id="contactPage"> <div class="labelBlock contactPageLabel"> <label for="n

我需要帮助:如何在我的输入中获取按钮的名称。我有两个文件(index.php,contact.php)。我的按钮在index.php中,表单在contact.php中

contact.php file

<form class="form" id="contactPage">
  <div class="labelBlock contactPageLabel">
    <label for="name">Name *</label>
    <div>
      <input id="name" type="text" name="name" required>
    </div>
  </div>
  <div class="labelBlock contactPageLabel">
    <label for="email">E-mail *</label>
    <div>
      <input id="email" type="email" name="email" required>
    </div>
  </div>
  <div class="labelBlock contactPageLabel">
    <label for="subject">Subject</label>
    <div>
      <input id="subject" type="text" name="subject">
    </div>
  </div>
  <div class="labelBlock contactPageLabel">
    <label for="message">Message *</label>
    <div>
      <textarea name="textarea" id="message" required></textarea>
    </div>
  </div>
  <div class="labelBlock contactPageLabel">
    <div>
      <button>Send</button>
    </div>
  </div>
</form>                  

contact.php文件
名字*
电子邮件*
主题
信息*
发送
下一个文件:

index.php file

<button name="contracted_instructor">Contracted instructor</button>
<button name="talented-people">Talented people</button>
index.php文件
合同教员
人才
我希望在点击其中一个按钮后,我的按钮名称会显示在主题中。例如,如果我点击

<button name = "contracted_instructor"> Contracted instructor </button>
合同讲师
然后表单将显示

<input id = "subject" type = "text" name = "subject" value = "contracted_instructor">

您可以将按钮放在表单中,并使该表单的操作=contact.php和method=GET 然后在contact.php上,您收到单击按钮的值并相应地加载内容 您可以添加如下php代码:

$clicked_button = $_GET['b'];
在您的输入元素中:

<input id="subject" type="text" name="subject" value="<?= $clicked_button ?>">

但是有两个不同的文件,在js/jquery中有可能实现吗?看我的编辑,我解释了一般的想法,也许你可以实现一个实现类似东西的代码好的,我试试thx