Note that there are some explanatory texts on larger screens.

plurals
  1. POIssue with PHP "if"
    primarykey
    data
    text
    <p>I've been having an issue with my PHP mail() script. I'm attempting to build a website for my class to use to get homework, know the dates of upcoming tests/coursework, etc.</p> <p>This script is to send data from a form to my email address. My problem is that: I had attempted to include a Field in my form to increase security, It basically said to insert "65FL7YB" to ensure that the user wasn't a bot, and in my PHP, I wrote the following:</p> <pre><code>if($_POST['valid'] = "65FL7YB") { mail($to , $subject , $message , $header); echo "Your Email Has Been Sent."; } else { echo "Your email has not been sent. Please ensure that you correctly entered the Validation Code."; } </code></pre> <p>But when I proceded to test the script the following occurred: When I typed in the Validation Code correctly, as expected, on the page was printed "Your Email Has Been Sent." But when I typed in an incorrect Validation Code still the same "Your Email Has Been Sent." came up instead of "Your email has not been sent. Please ensure that you correctly entered the Validation Code."</p> <p>Please help me, I've spent hours trying to work this out (with others who know how to code) but we have not been able the identity the problem.</p> <p>For extra reference this is the full code of the page: </p> <pre><code>&lt;?php $name = $_POST['name']; $date = $_POST['date']; $subject = $_POST['subject']; $homework = $_POST['homework']; $to = "Removed for my Privacy"; $subject = "Homework Submission"; $message = "The following has been submitted by $name. /n" . "The subject(s) is/are $subject. /n" . "Today's Homework is: /n $homework /n" . "$date"; $header = $name; if($_POST['valid'] = "65FL7YB") { mail($to , $subject , $message , $header); echo "Your Email Has Been Sent."; } else { echo "Your email has not been sent. Please ensure that you correctly entered the Validation Code."; } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload