테스트 사이트 - 개발 중인 베타 버전입니다

폼메일 이름/연락처만 뽑아서 하는 방법이 있을까요? 채택완료

춘여사 7년 전 조회 2,349

관련링크 스킨을 사용하는데 이름과 연락처만 사용하고 싶은데..

어떻게 해야할까요 ㅠㅠㅠ 죄송한 말씀이지만 알려주시면 너무 감사하겠습니당 ㅠㅠㅠ

댓글을 작성하려면 로그인이 필요합니다.

답변 1개

채택된 답변
+20 포인트
7년 전

이름/연락처만 사용하도록 변경했습니다.

send.php에서 아래 두개는 변경하셔야 합니다.

$email_to = "받을 메일주소"; $email_from = "보내는 메일주소";

 

formmail.php

</p>

<p><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "<a href="<a href="http://www.w3.org/TR/html4/loose.dtd" target="_blank" rel="noopener noreferrer">http://www.w3.org/TR/html4/loose.dtd</a>"><a href="http://www.w3.org/TR/html4/loose.dtd" target="_blank" rel="noopener noreferrer">http://www.w3.org/TR/html4/loose.dtd</a></a>">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>폼메일보내기</title>

<style>

table {width:100%;border:1px solid #C4C4C4;border-collapse: collapse;}

th {width:20%;border:1px solid #c4c4c4;background:#ebebeb;color:#383838;text-align:center;font-size:1.083em;}

td {border:1px solid #dfdfdf;padding:17px 5px;font-size:1.083em;color:#666}

btn_submit {border-radius:3px;background:#3c95d5;border:1px solid #3c95d5;padding:10px 20px;font-size:1.083em}

</style>

</head></p>

<p><body>

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

<table>

<tr>

<th scope="row">

<label for="first_name">이름</label></th>

<td width="80%">

<input name="first_name"  type="text" class="ipt" style="height:20px" size="30" maxlength="50" required >

</td>

</tr></p>

<p><tr>

<th scope="row">

<label for="telephone">연락처</label></th>

<td>

<input name="telephone"  type="text" class="ipt" style="height:20px" size="30" maxlength="30" required >

</td>

</tr></p>

<p><tr>

<td height="40" colspan="2" style="text-align:center">

<input type="submit" value="전송하기" class="btn_submit">

<input name="재설정" type="reset" value="다시작성" class="btn_submit"></td>

</tr>

</table>

</form>

</body>

</html></p>

<p>

 

send.php

</p>

<p><meta charset="utf-8">

<?php</p>

<p>$email_to = "받을 메일주소";

$email_from = "보내는 메일주소";

$email_subject = "[폼메일] 문의사항입니다.";

$email_subject = '=?UTF-8?B?'.base64_encode($email_subject).'?=';

 

function died($error) {

 // your error code can go here

 echo "<script> alert('메일발송을 실패하였습니다.');";

 echo "history.go(-1);";

 echo "</script>";

 die();

}

 

// validation expected data exists

if(!isset($_POST['first_name']) ||

 !isset($_POST['telephone'])) {

 died('We are sorry, but there appears to be a problem with the form you submitted.');      

}

 

$first_name = $_POST['first_name']; // required

$telephone = $_POST['telephone']; // not required

 

$error_message = "";

$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+.[A-Za-z]{2,4}$/';</p>

<p>if(!preg_match($email_exp,$email_from)) {

 $error_message .= 'The Email Address you entered does not appear to be valid.
';

}</p>

<p>if(strlen($error_message) > 0) {

 died($error_message);

}

$email_message = "";

 

function clean_string($string) {

  $bad = array("content-type","bcc:","to:","cc:","href");

  return str_replace($bad,"",$string);

}

 

$email_message .= "이름 : ".clean_string($first_name)."\n\n";

$email_message .= "연락처 : ".clean_string($telephone)."\n\n";

    

// create email headers

$headers = 'From: '.$email_from;

// 제목이 깨질경우 아래 캐릭터셋 적용</p>

<p>@mail($email_to, $email_subject, $email_message, $headers); 

?>

 

<!-- include your own success html here -->

 

<script>

alert ("메일이 발송되었습니다.\n빠른 시일안에 답변드리겠습니다.");

location.href='../';

</script></p>

<p>

로그인 후 평가할 수 있습니다

답변에 대한 댓글 2개

춘여사
7년 전
정말 감사합니다 ㅠㅠㅠ 생명의 은인이에요
배모씨
7년 전
생명의 은인까지 ㅎㅎㅎ 잘되셨다니 다행입니다^^

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인