如何将所有详细信息发送到网站上的电子邮件ID? (联系我们表格) [英] How do I send all the details to the email id from the website? (Contact us form)

查看:107
本文介绍了如何将所有详细信息发送到网站上的电子邮件ID? (联系我们表格)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法将所有详细信息发送到此联系表单中的电子邮件ID,我不知道我是否在正确的位置放置了正确的代码,我只提到了以下php文件中的标签那些我能发送的。请有人帮我解释一下代码,我该把它放在哪里?我的公司真的落后于我的屁股。我想这是我的最后一个选择:'(



我尝试了什么:



PHP文件

I cannot send all the details to the email id in this contact form, i don't know if i'm putting the right code at the right place or not, I have only mentioned the labels in the php file below for the ones which i am able to send. Please can someone help me with the code, and where do i put it? My company is really behind my ass for this one. and i suppose this is my last option :'(

What I have tried:

PHP FILE

<?php
	$msg = "";

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

		require 'phpmailer/PHPMailerAutoload.php';

		function sendemail($to, $from, $fromName, $body, $attachment = "") {
			$mail = new PHPMailer();
			$mail->setFrom($from, $fromName);
			$mail->addAddress($to);
			$mail->addAttachment($attachment);
			$mail->Subject = 'Contact Form - Email';
			$mail->Body = $body;
			$mail->isHTML(false);

			return $mail->send();
		}

		$name = $_POST['username'];
		$email = $_POST['email'];
		$body = $_POST['body'];

		$file = "attachment/" . basename($_FILES['attachment']['name']);
		if (move_uploaded_file($_FILES['attachment']['tmp_name'], $file)) {
		    if (sendemail('info@alabdouligroup.com', $email, $name, $body, $file)) {
				$msg = 'Email sent!';
				
			} else
				$msg = 'Email failed!';
		} else
			$msg = "Please check your attachment!";
	}
?>





HTML文件





HTML FILE

<h3>Your Personal Details</h3>

<form method="post" enctype="multipart/form-data">
<table border="0" cellpadding="5" cellspacing="0">
<tr> <td style="width: 50%">
<label for="First_Name">First name *</label><br />
<input name="username" type="text" maxlength="50" style="width: 260px" />
</td> <td style="width: 50%">
<label for="Last_Name">Last name *</label><br />
<input name="Last_Name" type="text" maxlength="50" style="width: 260px" />
</td> </tr> <tr> <td colspan="2">
<label for="Email_Address">Email *</label><br />
<input name="email" type="text" maxlength="100" style="width: 535px" />
</td> </tr> <tr> <td colspan="2">
<label for="Portfolio">Portfolio website</label><br />
<input name="Portfolio" type="text" maxlength="255" value="http://" style="width: 535px" />
</td> </tr> <tr> <td colspan="2">
<label for="Position">Position you are applying for *</label><br />
<input name="body" type="text" maxlength="100" style="width: 535px" />
</td> </tr> <tr> <td>
<label for="Salary">Salary requirements</label><br /> <input name="Salary" type="text" maxlength="50" style="width: 260px" /> </td> <td>
<label for="StartDate">When can you start?</label><br />
<input name="StartDate" type="text" maxlength="50" style="width: 260px" />
</td> </tr> <tr> <td>
<label for="Phone">Phone *</label><br />
<input name="Phone" type="text" maxlength="50" style="width: 260px" />
</td> <td>
<label for="Fax">Fax</label><br />
<input name="Fax" type="text" maxlength="50" style="width: 260px" />
</td> </tr> <tr> <td colspan="2">
<label for="Relocate">Are you willing to relocate?</label><br />
<input name="Relocate" type="radio" value="Yes" checked="checked" /> Yes      
<input name="Relocate" type="radio" value="No" /> No      
<input name="Relocate" type="radio" value="NotSure" /> Not sure
</td> </tr> <tr> <td colspan="2">
<label for="Organization">Last company you worked for</label><br />
<input name="Organization" type="text" maxlength="100" style="width: 535px" />
</td> </tr> <tr> <td colspan="2">
<label for="Reference">Reference / Comments / Questions</label><br />
<textarea name="Reference" rows="7" cols="40" style="width: 535px"></textarea>
</td> </tr> <tr> <td colspan="2" style="text-align: center;">
			<input type="file" name="attachment" required><br>
			<input type="submit" name="submit" value="Send Email">
		</td> </tr>
</table>
</form>
		<br><br>
		<?php echo $msg; ?>

推荐答案

msg =;

if(isset(
msg = ""; if (isset(


_POST ['submit'])){

require'phpmailer / PHPMailerAutoload.php';

函数sendemail(
_POST['submit'])) { require 'phpmailer/PHPMailerAutoload.php'; function sendemail(


to,


这篇关于如何将所有详细信息发送到网站上的电子邮件ID? (联系我们表格)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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