【问题标题】:unable to echo message sent in html page using php无法回显使用 php 在 html 页面中发送的消息
【发布时间】:2013-09-18 21:52:21
【问题描述】:

我目前正在处理这个页面: http://www.webauthorsgroup.com/new/template/index3.html

右下角是一个表单(php),但我无法在提交后“回显”一条短信(无论出于何种原因)。

我的表格是:

<form id="contact" method="post" action="">
<fieldset>  

<label for="name">Name</label>
<input type="text" name="name" placeholder="Full Name" title="Enter your name" class="required">

<label for="email">E-mail</label>
<input name="hidden" class="required email" onblur="if(value=='<?php echo htmlentities($_POST['email']); ?>') value = 'Your Email'" onfocus="if(value=='Your Email') value = ''" type="email" value="Your Email" placeholder="yourname@domain.com">

<label for="phone">Phone</label>
<input name="phone" onblur="if(value=='<?php echo htmlentities($_POST['phone']); ?>') value = 'phone'" onfocus="if(value=='phone') value = ''" type="tel" value="phone" placeholder="ex. (555) 555-5555">
<input type="hidden" name="phone" placeholder="ex. (555) 555-5555">

<label for="message">Question/Comment</label>
<textarea name="message" onblur="if(value=='<?php echo htmlentities($_POST['message']); ?>') value = 'message'" onfocus="if(value=='message') value = ''" value="message" placeholder="Message"></textarea>

<input type="submit" name="submit" class="button" id="submit" value="Send Message" />

</fieldset>
</form>

================================================ ==========

process.php 是:

<?php

if(isset($_POST['submit']))
{

// Get Data 
$name = strip_tags($_POST['name']);
$email = strip_tags($_POST['email']);
$phone = strip_tags($_POST['phone']);
$url = strip_tags($_POST['url']);
$message = strip_tags($_POST['message']);
echo "Thank You!";
}
// Send Message
mail( "bruce@webauthorsgroup.com", "Inquiry From WebAuthorsGroup",
"Name: $name\nEmail: $email\nPhone: $phone\nWebsite: $url\nMessage: $message\n",
"From: Forms <forms@example.net>" );
?>

================================================ ==

我需要在提交表单后在同一个 div 中回显“发送的消息”文本,我不想将我的索引页面转换为 index.php

任何帮助都会很棒!

【问题讨论】:

  • 您的表单缺少action 属性。

标签: php forms contact


【解决方案1】:

页面 index3.html 上的 PHP 代码没有被服务器上的 PHP 解释器解析或执行,因为文件扩展名为 .html。继续并在浏览器中查看该页面上的源代码。请注意,您可以看到 PHP 代码。您应该无法在 HTML 源代码中看到 PHP 代码。您应该只看到 PHP 呈现的 HTML。请将文件扩展名更改为 .php,以便您的服务器可以执行它而不是将其作为文本输出。

【讨论】:

    猜你喜欢
    • 2016-12-06
    • 2015-02-02
    • 1970-01-01
    • 1970-01-01
    • 2018-07-25
    • 2014-04-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多