dongyi6195 2014-05-08 12:00
浏览 24

在点击时回显电子邮件地址到下一页,并使用$ _GET将电子邮件发送到该电子邮件

i am trying to echo an email address onto the next page 'send_email.php' through a link using the url.

The idea is that send_email.php sends out an email to the specific email address for which that link belongs.

i am currently getting undefined index 'contact_email' errors and i am not sure what i am doing wrong, i am trying to use $_GET as a means to retrieve the email address from the url and add this to the email to/recipient line in send_email.php

our link is on 'page1' where we use a mysql query to pull details from the database like so:

$myId2 = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT);
        $query2 = mysql_query(" SELECT supplier_registration.contact_name, 
                               supplier_registration.contact_email, supplier_registration.contact_number, supplier_registration.company_address, supplier_registration.company_postcode
                        FROM supplier_registration 
                        INNER JOIN supplier_stats
                        ON supplier_registration.company_reg_number = supplier_stats.company_reg_number
                        WHERE supplier_stats.id = $myId2 AND supplier_stats.insurance_date = DATE(NOW())");
        while($row2 = mysql_fetch_array( $query2 )) {
        echo "<div class=\"contact_details\">Contact Details:<br/>";    
        echo "<p><font color=\"#999\">Contact Name:</font> ".$row2['contact_name']."<br/>";
        echo "<font color=\"#999\">Contact Number:</font> ".$row2['contact_number']."<br/>";
        echo "<p><font color=\"#999\">Contact Email:</font> ".$row2['contact_email']."<br/></p>";

        echo "<p><font color=\"#999\">Postal Address:</font> ".$row2['company_address']."</br>";
        echo "<font color=\"#999\">Contact Name:</font> ".$row2['company_postcode']."</p>";
        echo "</div>";

        echo "<a href=\"send_email.php?email=".$row2['contact_email']."\"\"><div class=\"buttons\">Send Reminder Email</div> </a>";

then when we click the link we go to send_email.php which looks like this:

<?php
$_GET['contact_email'];
$myEmail = $_GET['contact_email'];

 $to = $myEmail;
 $subject = "Hi!";
 $body = "Hi,

How are you?";
 if (mail($to, $subject, $body)) {
   echo("<p>Email successfully sent!</p>");
  } else {
   echo("<p>Email delivery failed…</p>");
  }
 ?>

but i am getting these errors:

Notice: Undefined index: contact_email in C:\xampp\htdocs\hewden_spms\send_email.php on line 2

Notice: Undefined index: contact_email in C:\xampp\htdocs\hewden_spms\send_email.php on line 3
Email successfully sent!

can someone please show me where the problem is and how i can get this to work thanks

  • 写回答

4条回答 默认 最新

  • dongtu1357 2014-05-08 12:03
    关注

    <a href="send_email.php?email=" your query string paramter name is email not contact_email

    It should be,

    $_GET['email'];
    $myEmail = $_GET['email'];
    

    instead of

    $_GET['contact_email'];
    $myEmail = $_GET['contact_email'];
    
    评论

报告相同问题?

悬赏问题

  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口