确认电子邮件不是从php和mysql数据发送的?

时间:2018-01-05 10:26:31

标签: php mysql forms email

所以我有一个表单,你可以通过电子邮件让某人加入你的小组,由于某种原因,它没有发送电子邮件,它昨天工作得非常好,现在似乎有些东西被打破了。这是形式:

<div class="form" style="background: white; box-shadow: 0 0px rgba(0, 0, 0, 0);">
    <form id="addmember" action="addingmember.php" method="post" autocomplete="off">
        <div class="field-wrap">
            <label style="position: relative; color: black;">
                Member Email:
            </label>
            <input type="email" required autocomplete="off" name="memberemail"
                   style="color: black; padding: 8px; height: 48px;"/>
        </div>
        <button type="submit" class="button button-block" name="submit">
            Submit
        </button>
    </form>

这是添加成员代码:

<?php

include '../db_connection.php';

session_start();

$leaguename = $_SESSION['league_name'];
$startdate = $_SESSION['start_date'];
$enddate = $_SESSION['end_date'];
$joincode = $_SESSION['joincode'];

$_SESSION['memberemail'] = $_POST['memberemail'];

$memberemail = $link->escape_string($_POST['memberemail']);

//check member Email matches
$memberemail = $link->query("SELECT Email FROM logins WHERE Email =' " . $_SESSION['memberemail'] . "'")->fetch_assoc()['memberemail'];

$to = $memberemail;
$subject = "Becoming part of $leaguename";
$body .= "So you want to become part of $leaguename?" . PHP_EOL;
$body .= "Please click the link below to join!" . PHP_EOL;
$body .= "http://www.linkhere.com/login/verify.php?memberemail=$memberemail&joincode=$joincode;" . PHP_EOL;

$headers = "From: emailhere";

mail($to, $subject, $body, $headers);
//header("location: addanothermember.php");

?>

1 个答案:

答案 0 :(得分:0)

$memberemail = $link->query("SELECT Email FROM logins WHERE Email =' " . $_SESSION['memberemail'] . "'")->fetch_assoc()['memberemail'];

你基本上选择&#34;电子邮件&#34;在查询中,但想要获得&#34; memberemail&#34;从它而来。也许这就是问题所在。

添加对$ memberemail变量的检查。

此外,在查询中使用$ _SESSION [&#39; memberemail&#39;]而不转义它有点危险。