首页 文章

无法回应使用php在html页面中发送的消息

提问于
浏览
0

我目前正在处理此页面: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

任何帮助都会很棒!

1 回答

  • 0

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

相关问题