douquan2023 2011-01-29 16:57
浏览 38
已采纳

是否可以发送单页电子邮件

My php form`s action goes to another page and it doesnt look good, I want to show form and whenever user fills out the form send it from same page is some inputs are empty I want to give an error.

Here is my from;

       <form method="post" action="#" name="emailform">
                <div class="rel">
            <div class="confor nab"><input class="cname" type="text" name="name"  value=""/></div>
            <div class="confor emb"><input class="cmail" type="text" name="email"  value=""/></div>
            <div class="confor phb"><input class="cphone" type="text" name="phone"  value=""/></div>
            <div class="confor evb"><input class="ceven" type="text" name="event"  value=""/></div>
            <div class="confor wdb"><input class="cwed" type="text" name="wdate"  value=""/></div>
            <div class="confor whb"><input class="chow" type="text" name="where"  value=""/></div>
            <div class="confort nob"><textarea class="ctho" name="notes" cols="" rows=""></textarea></div>
            <input name="submit" class="contactsend" type="submit" value="SEND" /></div>
         </form> 
  • 写回答

4条回答 默认 最新

  • dongshi1102 2011-01-29 17:02
    关注

    Simply change action to:

    <?=$_SERVER['PHP_SELF'];?>
    

    As this will send the form to the same page it's on and you can do your PHP validation and email sending code at the top, like so:

    <?
    // Here's your PHP validation and email sending code
    ?>
    <!DOCTYPE html>
    <html>
        <head>
            <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
            <meta name="description" content="" />
            <meta name="keywords" content="" />
            <link type="text/css" rel="stylesheet" href="/assets/css/styles.css" />
            <title></title>
        </head>
        <body>
            <form action="<?=$_SERVER['PHP_SELF'];?>" method="post">
                <!-- Here's all your form items -->
            </form>
        </body>
    </html>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应