[Solved] Need preview page before send email [closed]


Further to my comment, what I mean by splitting up the sendMail.php (you will, of course, have to modify your main page javascript to accommodate a confirm response from your sendMail.php):

if(isset($_POST['data']) && is_array($_POST['data']) ) {
        foreach($_POST['data'] as $data) {   }
        $datatList = implode(', ', $_POST['data']);
    }
else
    $datatList  =   $_POST['data'];


if(!isset($_POST['confirm'])) {

        $name       =   strip_tags($_POST['name']);
        $email      =   strip_tags($_POST['mail']);
        $age        =   preg_replace('/[^0-9]/','',$_POST['age']);
        $data       =   strip_tags($datatList);
        $response="
    <h2>Preview</h2>
    <table>
        <tr>
            <td>NAME:</td><td>".$name.'</td>
        </tr>
        <tr>
            <td>EMAIL:</td><td>'.$email.'</td>
        </tr>
        <tr>
            <td>AGE:</td><td>'.$age.'</td>
        </tr>
        <tr>
            <td>DATA:</td><td>'.$data.'</td>
        </tr>
        <tr>
            <td colspan="2">
                <form id="confirm" method="post" action="">
                    <input type="hidden" name="name" value="'.$name.'" />
                    <input type="hidden" name="mail" value="'.$email.'" />
                    <input type="hidden" name="age" value="'.$age.'" />
                    <input type="hidden" name="data" value="'.$data.'" />
                    <input type="submit" name="confirm" value="Confirm" />
                </form>
            </td>
        </tr>
    </table>';
        echo json_encode(array("confirm"=>true, "message"=> $response));
    }
else {
        $send_for_address   = "[email protected]";
        $header             = "From: [email protected]";
        $messages           = "Name: $_POST[name]\n";
        $messages           .= "Email: $_POST[mail]\n";
        $messages           .= "Age : $_POST[age]\n";
        $messages           .= "Work $datatList\n";  
        mail($send_for_address, $messages,$header);
        mb_internal_encoding("UTF-8");
        if (mail($send_for_address, $messages,$header)) {
                $response = <<<HTML
<div class="alert">
    <div class="alert-header"><div class="alert-remove layerOff">×</div></div>
    <div class="alert-body fs0_7">
        Thank you for your applicaion!
    </div>
    <div class="alert-footer">
        <input type="button" value="OK" class="layerOff">
    </div>
</div>
HTML;
                echo json_encode(array("success"=>true, "message"=> $response));
            }
    }

2

solved Need preview page before send email [closed]