为什么表单不适用于localhost? [英] Why forms don't work on localhost ?

查看:126
本文介绍了为什么表单不适用于localhost?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在HTML和PHP中创建了一个表单,用于将填充的数据发送到电子邮件地址。



当我尝试填写表格并在localhost上提交时,表单已提交,但填好的数据未发送到电子邮件地址。



但是当在主机帐户上再次尝试时,数据被发送到电子邮件地址。



为什么?我正在使用LAMP。我是否需要下载SMTP服务器才能从localhost发送电子邮件?



I made a form in HTML and PHP that sends the filled up data to an email address.

When I tried filling up the form and submitting on localhost, the form was submitted but the filled up data wasn't sent to the email address.

But when tried again on an hosting account, the data was sent to the email address.

Why ?? Im using LAMP. Do I need to download an SMTP server to send email from localhost ?

Here is the code:

form1.html

<html>
<head>
<title>Form</title>
</head>
<body>

<form method = "post" action = "process.php">
Enter your name <input type = "text" name = "namee" id = "namee" value = "enter your name" />
Enter your phone number <input type = "text" name = "phone" id = "phone" />
<br>
<input type  = "submit" value = "post it!" />










process.php

<?php

$person_name = $_POST["namee"];
$person_number = $_POST["phone"];

$to = "example234671_1@gmail.com";
$subject = "form filled up";

$body = $person_name . $person_number. $person_name ;

mail($to, $subject, $body);

echo "Thank you!" ;
?>

推荐答案

person_name =
person_name =


_POST [ namee];
_POST["namee"];


person_number =
person_number =


这篇关于为什么表单不适用于localhost?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆