I created an HTML form that, on submit, opens submit_form.php. Inside, I process the data entered into the form and send a confirmation email. I wrote a function for the mail-sending-process.
Inside the .php file, I have PHP, as well as HTML code. The important parts of the file look like this:
<?php
$success = "undefined";
/* ... */
function send_mail($to, $from, $fromName, $subject, $message) {
/* headers, etc. */
if (mail($to, $subject, "", $header)) {
$success = "true";
} else {
$success = "false";
}
}
?>
<html>
<body>
success? <?php echo $success; ?>
</body
</html>
Now, when loading the HTML on the success site (HTML code below the .php script, in the same file), I put this code to verify whether the email was sent successfully:
success? <?php echo $success; ?>
...which presents the following output: success? undefined
mailtoin the same file as thesuccess? <?php echo $success; ?>?