将html表单数据发送到发件人的电子邮件

时间:2016-12-13 09:52:12

标签: javascript php html

我已经在html中创建了一个表单,并且php脚本试图将其发送到电子邮件但是它无法正常工作。你能检查我错在哪里吗?

每当我点击发送按钮,它就会开始显示php代码,而不是将电子邮件发送到给定的电子邮件。

import PyPDF2

with open('test.pdf', 'rb') as infile:
    reader = PyPDF2.PdfFileReader(infile)
    first = reader.getPage(0)
    second = reader.getPage(1)
    target_page = PyPDF2.pdf.PageObject.createBlankPage(width=841.89, height=595.276)
    scale = 595.276/841.89
    target_page.mergeScaledTranslatedPage(first, scale, 0, 0)
    target_page.mergeScaledTranslatedPage(second, scale, 841.89/2, 0)
    writer = PyPDF2.PdfFileWriter()
    writer.addMetadata(reader.documentInfo)
    writer.addPage(target_page)
with open('wrong.pdf', 'wb') as outfile:
    writer.write(outfile)

HTML
----


<!DOCTYPE html>
<html>
<head>
<title>Form</title> <!-- Include CSS file here -->
<link href="css/form.css" rel="stylesheet">
</head>
<body onload="myFunction()">

<h1> Form Request </h1>

<form name="contactform"  action="email.php"  method="post">

  Name:  <input type="text" name="full_name"><br \><br \>
  Id:   <input type="text" id="id"><br \><br \>
  Email id: <input type="email" email="email"><br \><br \>
  <a href="Form_IP.pdf" download>Download Blank Form </a> <br \><br \><br \>
  Upload Filled Form<br \><br \>
  
  <input type="file" id="myFile" multiple size="50" onchange="myFunction()">

<p id="resellerfile"></p>
    
<script>
function myFunction(){
    var x = document.getElementById("myFile");
    var txt = "";
    if ('files' in x) {
        if (x.files.length == 0) {
            txt = "Select one or more files.";
        } else {
            for (var i = 0; i < x.files.length; i++) {
                txt += "<br><strong>" + (i+1) + ". file</strong><br>";
                var file = x.files[i];
                if ('name' in file) {
                    txt += "name: " + file.name + "<br>";
                }
                if ('size' in file) {
                    txt += "size: " + file.size + " bytes <br>";
                }
            }
        }
    } 
    else {
        if (x.value == "") {
            txt += "Select one or more files.";
        } else {
            txt += "The files property is not supported by your browser!";
            txt  += "<br>The path of the selected file: " + x.value; // If the browser does not support the files property, it will return the path of the selected file instead. 
        }
    }
    document.getElementById("resellerfile").innerHTML = txt;
}
</script>
<br \><br \>

 <input type="submit" value="Submit">



</form>
</body>
</html>

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

2 个答案:

答案 0 :(得分:2)

它显示原始php,因为浏览器不能直接执行php脚本,服务器处理并执行php scripts,然后将html响应发送到浏览器。

因此,您需要远程或本地在服务器上托管php脚本。 如果要在系统上本地设置服务器,请尝试安装XAMP或WAMP。

请参阅以下链接。

http://www.homeandlearn.co.uk/php/php1p3.html

答案 1 :(得分:0)

您是否尝试使用Xampp的htdocs文件夹来查看它是否正在响应?