Php 基本if语句不起作用

Php 基本if语句不起作用,php,Php,为什么选择其他选项时,此代码总是将$image\u issue\u消息作为消息输出?:我还将在注释中发布表单代码,以便您可以看到如何传递值(如果有帮助的话)!我对PHP还很陌生,所以我现在对这一点很不了解 <?php if(!$_POST) exit; $name = $_POST['name']; $email = $_POST['email']; $issues = $_POST['issues']; $message = $_POST['message']

为什么选择其他选项时,此代码总是将$image\u issue\u消息作为消息输出?:我还将在注释中发布表单代码,以便您可以看到如何传递值(如果有帮助的话)!我对PHP还很陌生,所以我现在对这一点很不了解

    <?php

if(!$_POST) exit;

$name     = $_POST['name'];
$email    = $_POST['email'];
$issues  = $_POST['issues'];
$message = $_POST['message'];
$image_issue_message = "<strong>Unacceptable photo</strong> - The image that you have submitted has not met the requirements for this website. Photos must be a clear photo of your face (preferably with nobody else in the shot). Photos of cartoon characters, private body parts etc. will not be accepted.<strong> Please attach a suitable photo to your reply email.</strong>";
$description_issue_message = "<strong>Unacceptable description</strong> - The description that you have submitted has not met the requirements for this website. Profile descriptions should tell our users a little bit about yourself and what you're looking for. Descriptions that hint that you are on the site looking for sex will not be approved and profile that contain personal or sensitive information cannot be approved either.<strong> Please submit a revised profile description by replying to this email.</strong>";
$other_issue_message = "<strong>Issues</strong> - ".$message;
$issue_message = "";
if ($issues = "photo") {
    $issue_message = $image_issue_message;
} elseif($issues = "description") {
    $issue_message = $description_issue_message;
} else {
    $issue_message = $other_issue_message;
}


if(get_magic_quotes_gpc()) {
    $comments = stripslashes($comments);
}

$websitepath="http://www.gaymate.co.uk";


// Configuration option.
// Enter the email address that you want to emails to be sent to.
// Example $address = "joe.doe@yourdomain.com";

//$address = "example@themeforest.net";
$address = $email;

// Configuration option.
// i.e. The standard subject will appear as, "You've been contacted by John Doe."

// Example, $e_subject = '$name . ' has contacted you via Your Website.';

$e_subject = 'Profile rejected by GayMate.co.uk';


// Configuration option.
// You can change this if you feel that you need to.
// Developers, you may wish to add more fields to the form, in which case you must be sure to add them here.

$e_body = '
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
        <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>gaymate.co.uk</title>

        <style type="text/css">

        p {
            font-family: Arial;
            font-size: 12px;
            padding: 0 20px 0 20px; }

        .boldTitle {
            font-size: 13px;
            font-weight: bold; }

        .headerTitle {
            font-size: 16px;
            font-weight: bold; }

        .divider2 {
            padding: 0 20px 0 20px; }

        </style>

        </head>

        <body>
        <table width="500" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td>
            <!-- YOU CAN PUT AN EMAIL TITLE IMAGE HERE IF YOU WANT -->
            <p class="headerTitle">www.GayMate.co.uk</p>
            <img class="divider2" src="'.$websitepath.'/images/email/email-divider2.gif" alt="email-divider2" width="460" height="4" />
        <p>Hi,</p></br><p>Your profile has been rejected by the GayMate.co.uk Admin Team. The reasons for rejection
        are listed below. Please reply to this email with any ammendments needed so that we can make the alterations and get your
        profile activated right away!</p>
        <p>Reason(s) for rejection:</br>
        <ul>
            <li>'.$issue_message.'</li></ul></br><p class="headerTitle">The Team @ GayMate.co.uk</p></br>

       <img src="'.$websitepath.'/images/email/email-divider.gif" alt="email-divider" width="500" height="10" />
    </td>
  </tr>
</table>
<p>&nbsp;</p>
</body>
</html>
';

$msg = $e_body;

$headers = "From: admin@gaymate.co.uk" . PHP_EOL;
$headers .= "Reply-To: admin@gaymate.co.uk" . PHP_EOL;
$headers .= "MIME-Version: 1.0" . PHP_EOL;
$headers .= "Content-type: text/html;" . PHP_EOL;

if(mail($address, $e_subject, $msg, $headers)) {

    // Email has sent successfully, echo a success page.

    echo "<fieldset>";
    echo "<div id='success_page'>";
    echo "<h1>Email Sent Successfully.</h1>";
    echo "</div>";
    echo "</fieldset>";

} else {
    echo 'ERROR!';
}
表格编号:

    <form method="post" action="sendreject.php" name="contactform" id="contactform">

    <fieldset>

    <label for="name">Name</label>
    <select name="email" id="email">
        <?php
            while($row_list=mysql_fetch_assoc($list)){
                $id =  $row_list['id'];
                $name = ucwords(strtolower($row_list['firstname'])).' '.ucwords(strtolower($row_list['surname']));
                $email = $row_list['email'];
                echo "<option value='".$email."'>".$name."</option>";
            }
        ?>
    </select>

    <br />
    <label for="issues">Issue(s)</label>
    <select name="issues" id="issues">
        <option value="photo">Photo unacceptable</option>
        <option value="description">Profile description</option>
        <option value="other">Other/multiple issues</option>
    </select>

    <br />
    <label for="message">Reject message</label>
    <textarea name="message" cols="40" rows="3" id="message"></textarea>

    <br />
    <input type="submit" class="submit" id="submit" value="Submit" />

    </fieldset>

    </form>
您在ifs:if$issues=photo中使用了single=。这里的问题是,这个if不会检查$issues变量是否包含photo,但它会检查$issues是否为True

将=更改为==:如果$issues==photo,则与elseif相同。

=is赋值, ==是比较

我想你想要的是if$issues==photo,而不是if$issues=photo

列出@

如果$issues==照片

如果$issues==照片

检查比较运算符,两者都可以工作

在代码中,您将字符串photo分配给变量$issues,而不是比较它。

请将if$issues=photo更改为if$issues=photo。这肯定会解决你的问题。在每个if条件中使用==而不是=。使用single=时,为变量赋值是错误的。提及

你基本上是在讨论照片的价值。您需要将变量与字符串进行比较,因此使用double equal==

$image\u issue\u消息永远不会在代码中更改。我还将在评论中发布表单代码->请不要!将它添加到问题中,否则它将无法阅读,基本上它不是评论,而是问题的一部分
if ($issues == "photo") {
    $issue_message = $image_issue_message;
} elseif($issues == "description") {
    $issue_message = $description_issue_message;
} else {
    $issue_message = $other_issue_message;
}