使用PHP&;从一个页面向另一个页面显示消息;HTML表单

使用PHP&;从一个页面向另一个页面显示消息;HTML表单,php,html,email,Php,Html,Email,我有一个问题,我是新手,我不认为我很清楚我应该怎么做 我有3个文件,contact.html,mail.php,afisare.php contact.html <form class="uk-form uk-form-stacked" method="post" action="mail.php"> <div class="uk-form-row"> <lab

我有一个问题,我是新手,我不认为我很清楚我应该怎么做

我有3个文件,contact.html,mail.php,afisare.php

contact.html

<form class="uk-form uk-form-stacked" method="post" action="mail.php">

                        <div class="uk-form-row">
                            <label class="uk-form-label">Your Name</label>
                            <div class="uk-form-controls">
                                <input type="text" name="nume" placeholder="" class="uk-width-1-1">
                            </div>
                        </div>

                        <div class="uk-form-row">
                            <label class="uk-form-label">Your Email</label>
                            <div class="uk-form-controls">
                                <input type="text" name="email" placeholder="" class="uk-width-1-1">
                            </div>
                        </div>

                        <div class="uk-form-row">
                            <label class="uk-form-label">Your Message</label>
                            <div class="uk-form-controls">
                                <textarea name="mesaj" class="uk-width-1-1" id="form-h-t" cols="100" rows="9"></textarea>
                            </div>
                        </div>

                        <div class="uk-form-row">
                            <div class="uk-form-controls">
                                <button class="uk-button uk-button-primary">Submit</button>
                            </div>
                        </div>

                    </form>
<div class="uk-vertical-align uk-text-center uk-height-1-1">
        <div class="uk-vertical-align-middle" style="width: 250px;">

            <img class="uk-margin-bottom" width="140" height="120" src="images/logo.jpg" alt="">

            <form class="uk-panel uk-panel-box uk-form">
                <div class="uk-form-row">
                    <input class="uk-width-1-1 uk-form-width-large" type="text" placeholder="Nume">
                </div>
                <div class="uk-form-row">
                    <input class="uk-width-1-1 uk-form-width-large" type="text" placeholder="Email">
                </div>
                <div class="uk-form-row">
                    <input class="uk-width-1-1 uk-form-width-large" type="text" placeholder="Mesaj">
                </div>
            </form>

        </div>
    </div>

你的名字
你的电子邮件
你的信息
提交
mail.php

<?php
$admin_email = "serbanalbertvasile@gmail.com";
$nume = $_POST['nume'];
$email = $_POST['email'];
$mesaj = $_POST['mesaj'];


if (!$nume ||!$email||!$mesaj) die ("Completati toate campurile!");

else {

echo "Numele: ".$nume."<br>";
echo "E-mail: ".$email."<br>";
echo "Mesaj: ".$mesaj."<br>";

echo "<p>Salut ".$nume."!<br>Mesajul tau: "".$mesaj."" a fost trimis la adresa ".$email.".</p>";

}


mail($admin_email, "Formular contact", $mesaj, "De la".$email);

?>

afisare.html

<form class="uk-form uk-form-stacked" method="post" action="mail.php">

                        <div class="uk-form-row">
                            <label class="uk-form-label">Your Name</label>
                            <div class="uk-form-controls">
                                <input type="text" name="nume" placeholder="" class="uk-width-1-1">
                            </div>
                        </div>

                        <div class="uk-form-row">
                            <label class="uk-form-label">Your Email</label>
                            <div class="uk-form-controls">
                                <input type="text" name="email" placeholder="" class="uk-width-1-1">
                            </div>
                        </div>

                        <div class="uk-form-row">
                            <label class="uk-form-label">Your Message</label>
                            <div class="uk-form-controls">
                                <textarea name="mesaj" class="uk-width-1-1" id="form-h-t" cols="100" rows="9"></textarea>
                            </div>
                        </div>

                        <div class="uk-form-row">
                            <div class="uk-form-controls">
                                <button class="uk-button uk-button-primary">Submit</button>
                            </div>
                        </div>

                    </form>
<div class="uk-vertical-align uk-text-center uk-height-1-1">
        <div class="uk-vertical-align-middle" style="width: 250px;">

            <img class="uk-margin-bottom" width="140" height="120" src="images/logo.jpg" alt="">

            <form class="uk-panel uk-panel-box uk-form">
                <div class="uk-form-row">
                    <input class="uk-width-1-1 uk-form-width-large" type="text" placeholder="Nume">
                </div>
                <div class="uk-form-row">
                    <input class="uk-width-1-1 uk-form-width-large" type="text" placeholder="Email">
                </div>
                <div class="uk-form-row">
                    <input class="uk-width-1-1 uk-form-width-large" type="text" placeholder="Mesaj">
                </div>
            </form>

        </div>
    </div>

我想做的是在afisare.html中使用mail.php显示contact.html中的信息

我很困惑。。。我不认为我完全理解我如何能做到这一点

这样试试: 填写contact.html…将变量和数据发送到asfire.html运行asfire.html顶部的邮件程序

<?php
$admin_email = "serbanalbertvasile@gmail.com";
$nume = $_POST['nume'];
$email = $_POST['email'];
$mesaj = $_POST['mesaj'];


if (!$nume ||!$email||!$mesaj) die ("Completati toate campurile!"){

else {

echo "Numele: ".$nume."<br>";
echo "E-mail: ".$email."<br>";
echo "Mesaj: ".$mesaj."<br>";

echo "<p>Salut ".$nume."!<br>Mesajul tau: "".$mesaj."" a fost trimis la adresa ".$email.".</p>";

}


mail($admin_email, "Formular contact", $mesaj, "De la".$email);

?>
<div class="uk-vertical-align uk-text-center uk-height-1-1">
        <div class="uk-vertical-align-middle" style="width: 250px;">

            <img class="uk-margin-bottom" width="140" height="120" src="images/logo.jpg" alt="">

            <form class="uk-panel uk-panel-box uk-form">
                <div class="uk-form-row">
                    <input class="uk-width-1-1 uk-form-width-large" type="text" placeholder="Nume" value='<?php echo $nume; ?>'>
                </div>
                <div class="uk-form-row">
                    <input class="uk-width-1-1 uk-form-width-large" type="text" placeholder="Email" value='<?php echo $email; ?>' >
                </div>
                <div class="uk-form-row">
                    <input class="uk-width-1-1 uk-form-width-large" type="text" placeholder="Mesaj"value='<?php echo $mesaj; ?>'>
                </div>
            </form>

        </div>
    </div>
将文件扩展名更改为.php

或者,您也可以包含“email.php”;在asfire.html的顶部,如
,而不是将代码放在asfire.html的顶部

<?php
$admin_email = "serbanalbertvasile@gmail.com";
$nume = $_POST['nume'];
$email = $_POST['email'];
$mesaj = $_POST['mesaj'];


if (!$nume ||!$email||!$mesaj) die ("Completati toate campurile!"){

else {

echo "Numele: ".$nume."<br>";
echo "E-mail: ".$email."<br>";
echo "Mesaj: ".$mesaj."<br>";

echo "<p>Salut ".$nume."!<br>Mesajul tau: "".$mesaj."" a fost trimis la adresa ".$email.".</p>";

}


mail($admin_email, "Formular contact", $mesaj, "De la".$email);

?>
<div class="uk-vertical-align uk-text-center uk-height-1-1">
        <div class="uk-vertical-align-middle" style="width: 250px;">

            <img class="uk-margin-bottom" width="140" height="120" src="images/logo.jpg" alt="">

            <form class="uk-panel uk-panel-box uk-form">
                <div class="uk-form-row">
                    <input class="uk-width-1-1 uk-form-width-large" type="text" placeholder="Nume" value='<?php echo $nume; ?>'>
                </div>
                <div class="uk-form-row">
                    <input class="uk-width-1-1 uk-form-width-large" type="text" placeholder="Email" value='<?php echo $email; ?>' >
                </div>
                <div class="uk-form-row">
                    <input class="uk-width-1-1 uk-form-width-large" type="text" placeholder="Mesaj"value='<?php echo $mesaj; ?>'>
                </div>
            </form>

        </div>
    </div>
Contact.html->Contact.php

<form class="uk-form uk-form-stacked" method="post" action="asfire.html">

                            <div class="uk-form-row">
                                <label class="uk-form-label">Your Name</label>
                                <div class="uk-form-controls">
                                    <input type="text" name="nume" placeholder="" class="uk-width-1-1">
                                </div>
                            </div>

                            <div class="uk-form-row">
                                <label class="uk-form-label">Your Email</label>
                                <div class="uk-form-controls">
                                    <input type="text" name="email" placeholder="" class="uk-width-1-1">
                                </div>
                            </div>

                            <div class="uk-form-row">
                                <label class="uk-form-label">Your Message</label>
                                <div class="uk-form-controls">
                                    <textarea name="mesaj" class="uk-width-1-1" id="form-h-t" cols="100" rows="9"></textarea>
                                </div>
                            </div>

                            <div class="uk-form-row">
                                <div class="uk-form-controls">
                                    <button class="uk-button uk-button-primary">Submit</button>
                                </div>
                            </div>

                        </form>

你的名字
你的电子邮件
你的信息
提交
asfire.html->asfire.html

<?php
$admin_email = "serbanalbertvasile@gmail.com";
$nume = $_POST['nume'];
$email = $_POST['email'];
$mesaj = $_POST['mesaj'];


if (!$nume ||!$email||!$mesaj) die ("Completati toate campurile!"){

else {

echo "Numele: ".$nume."<br>";
echo "E-mail: ".$email."<br>";
echo "Mesaj: ".$mesaj."<br>";

echo "<p>Salut ".$nume."!<br>Mesajul tau: "".$mesaj."" a fost trimis la adresa ".$email.".</p>";

}


mail($admin_email, "Formular contact", $mesaj, "De la".$email);

?>
<div class="uk-vertical-align uk-text-center uk-height-1-1">
        <div class="uk-vertical-align-middle" style="width: 250px;">

            <img class="uk-margin-bottom" width="140" height="120" src="images/logo.jpg" alt="">

            <form class="uk-panel uk-panel-box uk-form">
                <div class="uk-form-row">
                    <input class="uk-width-1-1 uk-form-width-large" type="text" placeholder="Nume" value='<?php echo $nume; ?>'>
                </div>
                <div class="uk-form-row">
                    <input class="uk-width-1-1 uk-form-width-large" type="text" placeholder="Email" value='<?php echo $email; ?>' >
                </div>
                <div class="uk-form-row">
                    <input class="uk-width-1-1 uk-form-width-large" type="text" placeholder="Mesaj"value='<?php echo $mesaj; ?>'>
                </div>
            </form>

        </div>
    </div>


解释你的意思,显示接触。Contact只是一个html文件,没有填充任何内容?Contact.html是一个页面,我在其中完成信息,如发件人电子邮件、发件人姓名和发件人消息,我想使用mail.php将这些信息打印在afisare.html中…它实际上不起作用…您可以将Contact.html表单的操作设置为转到afisare,发送那些$u POST变量,然后通过包含它来运行mail.php?我是在尝试一些不可能或愚蠢的事情吗??我在这里需要一些帮助,因为我被af弄糊涂了。你能用一个例子给我解释一下解决这个问题的方法吗?我还修正了一个问题{在您的if语句中,它是一个;那太尴尬了……我不能使用它:)它在我的.html文件中不识别它是php……我没有在xampp或其他东西上运行它,我忘了提到它php不会自己运行。它是一种服务器语言。@我正在安装xampp atm,我将在2分钟后发布响应。