drnl10253 2014-06-26 09:18
浏览 11
已采纳

将用户详细信息转移到新页面

I am using wordpress and have created a list of users which are all links. Once clicked I need to carry the person email address over to a form where you can send an email to them directly. So it automatically populates to send with their email address. Currently I have looped through the users I want to send to but stuck on where to go from here:

<?php
$args1 = array(
 'role' => 'committee',
 'orderby' => 'user_nicename',
 'order' => 'ASC'
);
 $committee = get_users($args1);


foreach ($committee as $user) {
echo ' 

    <a href="../contact-form?email=' . $user->user_email . '"><b style="font-size:18px;">
  <tr>
    <td style="padding: 10px;">' .$user->job_title .' - </td>
    <td style="padding: 10px;">' .$user->display_name .'</td>
  </tr></b></a><br><br>';

 }

?>

I then need to send the persons email address who the user clicked on to this send page:

<form role="form" method="post" action="">

    <div class="form-group">

    <label for="InputName">Your name</label>
    <input type="name" class="form-control" id="InputName" placeholder="Enter your name">
    </div>

    <div class="form-group">

    <label for="InputEmail">Email address</label>
    <input type="email" class="form-control" id="InputEmail" placeholder="you@example.com">
    </div>

    <div class="form-group">

   <label for="InputMsg">Message</label>
    <textarea class="form-control" rows="8" id="InputMsg" placeholder="Please begin typing your message..."></textarea>   

    </div>    

    <button type="submit" class="btn btn-primary pull-right">Send</button>

     </form>

So if you click on a persons name it will take the user to a new page with a contact form, the person who they clicked on will then receive an email once the form is submitted. I just need some advice really on where to begin?

  • 写回答

1条回答 默认 最新

  • dongta1824 2014-06-26 09:30
    关注

    Just do this...

    <td style="padding: 10px;">
        <a href="urlwheretogetform?email=<?php echo $user->user_email;?>">
          <?php echo $user->display_name;?>
        </a>
    </td>
    

    Then on your other page...

      if(isset($_GET['email'])){
         $email = $_GET['email'];
      }
      // Do wahtever afterwards
    

    In more detail

      <?php if(isset($_GET)){
               $email = $_GET['email'];
             } else {$email='';};?>
    
      <form role="form" method="post" action="">
       //Your other fields
    
       <div class="form-group">
       <label for="InputEmail">Email address</label>
        <input type="email" class="form-control" id="InputEmail" placeholder="you@example.com" value="<?php echo $email;?>">
       </div>
       <button type="submit" class="btn btn-primary pull-right">Send</button>
    
     </form>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题
  • ¥15 企业资源规划ERP沙盘模拟
  • ¥15 树莓派控制机械臂传输命令报错,显示摄像头不存在
  • ¥15 前端echarts坐标轴问题
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码
  • ¥50 silvaco GaN HEMT有栅极场板的击穿电压仿真问题