폼메일 접수 버튼 클릭 후 페이지 이동

폼메일 접수 버튼 클릭 후 페이지 이동

QA

폼메일 접수 버튼 클릭 후 페이지 이동

본문

아래 소스와 같이 사용하고 있는데

접수하면 특정페이지로 이동하고 싶습니다.

방법이 있을까요?

단순 코딩만 가능한 퍼블리셔라서 어렵네요 ㅠㅠ

 

<?php
include_once('./_common.php');

$g5['title'] = 'CONTACT US';

?>
<link rel="stylesheet" type="text/css" href="/gnuboard5/css/default.css" />
<link rel="stylesheet" type="text/css" href="/gnuboard5/formmail/css/style.css" />

<link href="css/style.css" rel="stylesheet" type="text/css" />

<!-- CONTACT -->
<div>


    <form name="contactForm" id="contactForm" action="php/contact.php" method="POST" autocomplete="off">

    <div id="contactForm_form"  class="form_01">
        <div class="tbl_frm01 tbl_wrap">
            <ul>
                <li>
                    <select name="select_car" class="custom-select frm_input email full_input required" placeholder="문의방법">
                                <option value="국산차">국산차</option>
                                <option value="수입차">수입차</option>                                            
                    </select>
                </li>
                <li>
                    <label for="contact_name" class="sound_only">성함 *</label>
                    <input type="text" class="frm_input email full_input required" id="contact_name" name="contact_name" title="성함" placeholder="성함">
                </li>

                <li>
                    <label for="contact_message" class="sound_only frm_input">지역</label>
                    <input type="text" class="frm_input full_input required" id="contact_message" name="contact_message" title="지역" placeholder="지역">
                </li>
                <li>
                    <label for="contact_phone" class="sound_only">연락처</label>
                    <input type="text" class="frm_input full_input required" id="contact_phone" name="contact_phone" title="연락처" placeholder="연락처">
                </li>
                

            </ul>
            <fieldset class="contactForm_agree2">
                <label for="agree">개인정보처리방침안내의 내용에 동의합니다.</label>
                <input type="checkbox" name="agree" value="1" id="agree">
            </fieldset>
        </div>
    </div>

    <div class="btn_confirm">
        <input id="contact_submit" type="submit" class="btn_submit" value="접수하기">
    </div>

    </form>
</div>
<!-- CONTACT -->

<script type="text/javascript" src="js/contact.js"></script>

이 질문에 댓글 쓰기 :

답변 5

form 전송 후

contact.php 페이지에서 처리하는데

해당 페이지 보시면 폼 전송 후 리턴이라던가 별도의 URL 이 하단에 있을겁니다.

그 부분 채크해보세요.

답변감사합니다.

contact.php 하단에 나와있는 부분이 있네요. 이쪽 말씀하시는 걸까요?

/** **********************************
  EMAIL
/** ******************************* **/
function ckmail($email) {
$email = trim(strtolower($email));
if(preg_match('/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/',trim($email))){
return $email;
} else { return false; }
}

아뇨 올려주신 코드는 이메일 유효성 검사 채크 부분이고

스크립트가 나오기 전 코드가 있을거에요.

 

goto_url() 이나 alert() 이후 URL 이 있을겁니다.

contact.php 소스를 전체 올려보세요. 제가 봐드릴게요.

소스 올리기 부담스러우시면 쪽지로 소스를 보내주세요.

말씀 너무 감사합니다ㅠㅠ

<?php
/** ****************************************** **
 * @CONTACT FORM V1.1
 * @AUTHOR Dorin Grigoras
 * @DATE Tuesday, October 21, 2014
 ** ****************************************** **/
session_start();
@ini_set('display_errors', 0);
@ini_set('track_errors', 0);
@date_default_timezone_set('asia/korea'); // Used only to avoid annoying warnings.

if($_REQUEST['action'] = 'email_send') {

// BEGIN
require('config.inc.php');
$array['select_car'] = isset($_REQUEST['select_car']) ? strip_tags(trim($_REQUEST['select_car'])) : '';
$array['contact_name'] = isset($_REQUEST['contact_name']) ? strip_tags(trim($_REQUEST['contact_name'])) : '';
//$array['contact_email'] = isset($_REQUEST['contact_email']) ? strip_tags(trim($_REQUEST['contact_email'])) : '';
$array['contact_phone'] = isset($_REQUEST['contact_phone']) ? strip_tags(trim($_REQUEST['contact_phone'])) : '-';
$array['contact_subject'] = isset($_REQUEST['contact_subject']) ? strip_tags(trim($_REQUEST['contact_subject'])) : $config['subject'];
$array['contact_message'] = isset($_REQUEST['contact_message']) ? trim(strip_tags($_REQUEST['contact_message'], '<b><a><strong>')) : '';
$array['contact_captcha'] = isset($_REQUEST['contact_captcha']) ? strip_tags(trim($_REQUEST['contact_captcha'])) : '-';

// Check email
//if(ckmail($array['contact_email']) === false)
// die('_invalid_email_');

// Check required fields
if($array['contact_name'] == '' || $array['contact_phone'] == '')
die('_required_');

/*
if($array['contact_captcha'] != $_SESSION['captcha'])
die('_invalid_captcha_');
*/

// Visitor IP:
$ip = ip();

// DATE
$date = date('l, d F Y');

// Optional - if completed!
$PHONE = ($array['contact_phone'] != '') ? "<b>연락처:</b> {$array['contact_phone']} <br>" : null;
$SUBJECT = ($array['contact_subject'] != '') ? "<b>Subject:</b> {$array['contact_subject']} <br>" : null;

$mail_body = "
<h2><b>홈페이지 구매상담 문의<b></h2><br>
<b>접수날짜:</b> {$date} <br>
--------------------------------------------------- <br><br>
<b>문의내용:</b> {$array['select_car']} <br>
<b>성함:</b> {$array['contact_name']} <br>

{$PHONE}
{$문의내용}
<b>지역</b> {$array['contact_message']} <br>
--------------------------------------------------- <br><br>

";


// SMTP ENABLED [isset = for old versions]
if(!isset($config['use_smtp']) || isset($config['use_smtp']) && $config['use_smtp'] === true) {

require('phpmailer/5.1/class.phpmailer.php');

$m = new PHPMailer();
$m->IsSMTP();
$m->SMTPDebug  = false; // enables SMTP debug information (for testing) [default: 2]
$m->SMTPAuth  = true; // enable SMTP authentication
$m->Host      = $config['smtp_host']; // sets the SMTP server
$m->Port      = $config['smtp_port']; // set the SMTP port for the GMAIL server
$m->Username  = $config['smtp_user']; // SMTP account username
$m->Password  = $config['smtp_pass']; // SMTP account password
$m->SingleTo  = true;
$m->CharSet    = "UTF-8";
$m->Subject = $array['contact_subject'];
$m->AltBody = 'To view the message, please use an HTML compatible email viewer!';

$m->AddAddress($config['send_to'], 'Contact Form');
$m->AddReplyTo($array['contact_email'], $array['contact_name']);
$m->SetFrom($config['smtp_user'], 'Contact Form');
$m->MsgHTML($mail_body);

if($config['smtp_ssl'] === true)
$m->SMTPSecure = 'ssl'; // sets the prefix to the server

// @SEND MAIL
if($m->Send()) {
die('접수되었습니다.');
} else {
die($m->ErrorInfo);
}

unset($array, $m);

}

// mail()
else {

// mail( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )
mail(
$config['send_to'] ,
$array['contact_subject'],
$mail_body
);

}
}

/** **********************************
 @CHECK EMAIL
/** ******************************* **/
function ckmail($email) {
$email = trim(strtolower($email));
if(preg_match('/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/',trim($email))){
return $email;
} else { return false; }
}

 /** **********************************
 @VISITOR IP
/** ******************************* **/
function ip() {
if    (getenv('HTTP_CLIENT_IP'))      { $ip = getenv('HTTP_CLIENT_IP');      }
elseif (getenv('HTTP_X_FORWARDED_FOR')) { $ip = getenv('HTTP_X_FORWARDED_FOR'); }
elseif (getenv('HTTP_X_FORWARDED'))    { $ip = getenv('HTTP_X_FORWARDED');    }
elseif (getenv('HTTP_FORWARDED_FOR'))  { $ip = getenv('HTTP_FORWARDED_FOR');  }
elseif (getenv('HTTP_FORWARDED'))      { $ip = getenv('HTTP_FORWARDED');      }
  else { $ip = $_SERVER['REMOTE_ADDR'];        }
return $ip;
}
?>

저 같은경우 조금 귀차니즘이 있어서

php/contact.php으로 처리가 완료된 후

다시 goto_url()으로 폼으로 되돌아오게 하되 쿼리스트링으로 result=true or result=false으로

화면을 재구성합니다. 성공or실패

 

특정페이지 보내고싶으면 goto_url()만 쓰면되구요.

 

goto_url()은 common.lib.php에 있습니다.

 

die('접수되었습니다.');

die('<script>alert("접수되었습니다");self.location.href="이동할주소입력";');

수정해주세요.

답변을 작성하시기 전에 로그인 해주세요.
전체 4

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT