表单发送后显示html内容

I'm sorry, I know php so bad.

I have php script which sends my form to my email address.

<?php

    class Sendform {

    private static $from_name = 'Mysite.com';
    private static $from_email = 'mailer@Mysite.com';
    private static $to_email = 'myemail@email.com';


    public function send() {
        $name = self::getvar('name');
        $email = self::getvar('email');
        $message = self::getvar('message');


        $from_email = self::mime_encode(self::$from_name,"UTF-8")." <".self::$from_email.">";


        $subject = 'subject';

        $text = "Name: $name
    E-mail: $email

    Message: $message";


        if($fileName) {
            $un        = strtoupper(uniqid(time()));
            $head      = "From: $from_email
";
            $head     .= "To: ".self::$to_email."
";
            $head     .= "Subject: ".self::mime_encode($subject,'UTF-8')."
";
            $head     .= "X-Mailer: PHPMail Tool
";
            $head     .= "Mime-Version: 1.0
";
            $head     .= "Content-Type:multipart/mixed;";
            $head     .= "boundary=\"----------".$un."\"

";
            $zag       = "------------".$un."
Content-Type:text/plain; charset=UTF-8
";
            $zag      .= "Content-Transfer-Encoding: 8bit

$text

";
            $zag      .= "------------".$un."
";
            $zag      .= "Content-Type: application/octet-stream;";
            $zag      .= "name=\"".$fileName."\"
";
            $zag      .= "Content-Transfer-Encoding:base64
";
            $zag      .= "Content-Disposition:attachment;";
            $zag      .= "filename=\"".$fileName."\"

";
            $zag      .= chunk_split(base64_encode(file_get_contents($tmpName)))."
";

            mail(self::$to_email, self::mime_encode($subject,'UTF-8'), $zag, $head);
        } else {
            $from_email = self::mime_encode(self::$from_name,"UTF-8")." <".self::$from_email.">";
            $head="From: ".self::$from_email."
";
            $head.="X-Mailer: Sertse Mailer
";
            $head.="Content-Type: text/plain; charset=UTF-8
";
            $head.="Content-Transfer-Encoding: 8bit
";
            $head.="X-Priority: 3
";

            mail(self::$to_email, self::mime_encode($subject,'UTF-8'), $text, $head);
            echo "asdasdasdasdasd";
        }

    }


    private static function mime_encode($text,$charset) {
         return "=?".$charset."?B?".base64_encode($text)."?=";
    }


    private static function getvar($name) {
        return addslashes(htmlspecialchars(strip_tags($_POST[$name])));
    }

    }


    $reg = new Sendform;
    if(isset($_POST['name'])) $reg->send();

    ?>

I want to show an image file after form send and redirect to index page after 2 sec. I would be very grateful if you help to add this feature. Thank you!

Here, try this:

mail(self::$to_email, self::mime_encode($subject,'UTF-8'), $text, $head);
  echo "<img src=\"http://www.example.com/image.jpg\">";
  echo '<meta http-equiv="refresh" content="2;url=index.html" />';

or

echo '<META http-equiv="refresh" content="5; URL=index.html">';

You may want to increase the 2 depending on how large your image file is.

It may need additional time to load, otherwise the page will refresh to the set location without seeing the image entirely.

An additional option would be to echo a link to your website underneath the image, should people want to go directly to your index.html file instead.

mail(self::$to_email, self::mime_encode($subject,'UTF-8'), $text, $head);
  echo "<img src=\"http://www.example.com/image.jpg\">";
  echo "<br>";
  echo "<a href=\"index.html\">Click here to go to the home page</a>";
  echo '<meta http-equiv="refresh" content="2;url=index.html" />';