form 관련 질분드립니다. 특정 필드 미입력 시 경고창 띄우기... 정보
form 관련 질분드립니다. 특정 필드 미입력 시 경고창 띄우기...첨부파일
본문
안녕하세요..
저는 php는 완전 모르는 디자이너 입니다.
홈페이지를 하나 오픈했는데
알바로 프로그래머에게 의뢰를 했더니 완전 어이없게 작업을 하고
연락도 안되네요 ㅡㅡ..
질문입니다.
관련 페이지입니다.
http://bigbolt.co.kr/cost/310.html
지금 제로 보드로 연결되어있는데
입력폼에 아무것도 입력 안하고 버튼을 넘겼을때
필수로 입력을 해야하는 곳에
입력이 안되면 경고창으로 "oo"은 필수 입력하셔야합니다.
이런식으로 띄우고 싶은데요.
고수님들 보시고 답변 부탁드립니다.
예를들어 빨간 글씨로 적혀있는 곳에
input 박스에 아무것도 입력이 안되었으면
경고창 뜨게 하는겁니다.
html 파일
<? include_once "../inc_top.php" ?>
<!-- 서브 타이틀 -->
<div id="location">
<div id="category">
<img src="../images/common/img_location.gif" class="vtlm"><a href="#" class="first">Home</a>
<span title="인사말">상담 및 견적</span>
</div>
<h3><img src="../images/title/h3_310.gif"></h3>
</div><!-- // 서브 타이틀 --><!-- 각 페이지 컨텐츠 -->
<div id="corner_round_box_type01">
<h1><img src="../images/common/bx_conbody_top.gif"></h1>
<?php
if ($_POST) {
print_r($_POST);
}
?>
<div id="table_list">
<form action="./sendmail.php" method="post">
<table cellpadding="0" cellspacing="0" id="cost_form">
<tr>
<th>
구분
</th>
<td colspan="3">
<input name="type" type="radio" id="radio" value="1" checked="checked"> 주문
<input name="type" type="radio" id="radio" value="0">견적문의
</td>
</tr>
<tr>
<th>
회사명
</th>
<td>
<input name="company_name" type="text" class="inputType0" id="textfield" value="" size="24">
</td>
<th>
담당자 성명
</th>
<td>
<input name="contractor_name" type="text" class="inputType0" id="textfield11" value="" size="24">
</td>
</tr>
<tr>
<th>
전화번호
</th>
<td>
<select name="tel1" size="1" class="selectType0">
<option>02</option>
<option>031</option>
<option>032</option>
<option>041</option>
<option>042</option>
</select>
-<input name="tel2" type="text" class="inputType0" id="textfield" value="" size="6">- </td>
</tr>
-- 중략 ---
<th>
내용
</th>
<td colspan="3">
<textarea name="content" id="textarea" class="textArea01">
</textarea>
</td>
</tr>
</table>
<ul>
<li>
<!-- <a href="#"><img src="../images/btn/btn_osend.gif"></a> -->
<input type="image" src="../images/btn/btn_osend.gif" name="submit" value="submit" / >
<a href="./310.html"><img src="../images/btn/btn_rwrite.gif"></a>
</li>
</ul>
</form>
</div>
</div><!-- // 각 페이지 컨텐츠 -->
</div>
<div class="clear">
</div>
</div>
<? include_once "../inc_footer.php" ?>
php 파일
저는 php는 완전 모르는 디자이너 입니다.
홈페이지를 하나 오픈했는데
알바로 프로그래머에게 의뢰를 했더니 완전 어이없게 작업을 하고
연락도 안되네요 ㅡㅡ..
질문입니다.
관련 페이지입니다.
http://bigbolt.co.kr/cost/310.html
지금 제로 보드로 연결되어있는데
입력폼에 아무것도 입력 안하고 버튼을 넘겼을때
필수로 입력을 해야하는 곳에
입력이 안되면 경고창으로 "oo"은 필수 입력하셔야합니다.
이런식으로 띄우고 싶은데요.
고수님들 보시고 답변 부탁드립니다.
예를들어 빨간 글씨로 적혀있는 곳에
input 박스에 아무것도 입력이 안되었으면
경고창 뜨게 하는겁니다.
html 파일
<? include_once "../inc_top.php" ?>
<!-- 서브 타이틀 -->
<div id="location">
<div id="category">
<img src="../images/common/img_location.gif" class="vtlm"><a href="#" class="first">Home</a>
<span title="인사말">상담 및 견적</span>
</div>
<h3><img src="../images/title/h3_310.gif"></h3>
</div><!-- // 서브 타이틀 --><!-- 각 페이지 컨텐츠 -->
<div id="corner_round_box_type01">
<h1><img src="../images/common/bx_conbody_top.gif"></h1>
<?php
if ($_POST) {
print_r($_POST);
}
?>
<div id="table_list">
<form action="./sendmail.php" method="post">
<table cellpadding="0" cellspacing="0" id="cost_form">
<tr>
<th>
구분
</th>
<td colspan="3">
<input name="type" type="radio" id="radio" value="1" checked="checked"> 주문
<input name="type" type="radio" id="radio" value="0">견적문의
</td>
</tr>
<tr>
<th>
회사명
</th>
<td>
<input name="company_name" type="text" class="inputType0" id="textfield" value="" size="24">
</td>
<th>
담당자 성명
</th>
<td>
<input name="contractor_name" type="text" class="inputType0" id="textfield11" value="" size="24">
</td>
</tr>
<tr>
<th>
전화번호
</th>
<td>
<select name="tel1" size="1" class="selectType0">
<option>02</option>
<option>031</option>
<option>032</option>
<option>041</option>
<option>042</option>
</select>
-<input name="tel2" type="text" class="inputType0" id="textfield" value="" size="6">- </td>
</tr>
-- 중략 ---
<th>
내용
</th>
<td colspan="3">
<textarea name="content" id="textarea" class="textArea01">
</textarea>
</td>
</tr>
</table>
<ul>
<li>
<!-- <a href="#"><img src="../images/btn/btn_osend.gif"></a> -->
<input type="image" src="../images/btn/btn_osend.gif" name="submit" value="submit" / >
<a href="./310.html"><img src="../images/btn/btn_rwrite.gif"></a>
</li>
</ul>
</form>
</div>
</div><!-- // 각 페이지 컨텐츠 -->
</div>
<div class="clear">
</div>
</div>
<? include_once "../inc_footer.php" ?>
php 파일
<?php
if (isset($_POST)) {
//print_r($_POST);
require_once("../phpmailer/class.phpmailer.php");
$mailer = new PHPMailer;
$mailer->IsSMTP();
$mailer->SMTPAuth = true;
//$mailer->Host = "bigbolt.co.kr";
//$mailer->Username = "*** 개인정보보호를 위한 이메일주소 노출방지 ***";
//$mailer->Password = "bolt2009";
$mailer->Host = "ssl://smtp.gmail.com:465";
$mailer->Username = "*** 개인정보보호를 위한 이메일주소 노출방지 ***";
$mailer->Password = "Ehftmektzja";
$mailer->From = '*** 개인정보보호를 위한 이메일주소 노출방지 ***';
$mailer->AddAddress("*** 개인정보보호를 위한 이메일주소 노출방지 ***");
$mailer->AddAddress("*** 개인정보보호를 위한 이메일주소 노출방지 ***");
$mailer->AddAddress("*** 개인정보보호를 위한 이메일주소 노출방지 ***");
$mailer->FromName = $_POST['type'] ? "주문" : "견적문의";
$mailer->CharSet = 'UTF-8';
$mailer->IsHTML(true);
$mailer->Subject = ($_POST['type'] ? "[주문/" : "[견적문의/") . date("Y") . "년" . date("m") . "월" . date('d') . "일] " . ($_POST['company_name'] ? $_POST['company_name'] : "") .
($_POST['contractor_name'] ? "-" . $_POST['contractor_name'] : "");
$mailer->Body = "<html>";
$mailer->Body .= "<body>";
$mailer->Body .= "<table width='670' border='1'>";
$mailer->Body .= "<tr><th colspan=4>" . ($_POST['type'] ? "주문" : "견적문의") . "</th></tr>";
$mailer->Body .= "
<tr>
<th bgcolor='#f0f6fa'>회사명</th>
<td>" . ($_POST['company_name'] ? $_POST['company_name'] : "") . "</td>
<th bgcolor='#f0f6fa'>담당자 성명</th>
<td>" . ($_POST['contractor_name'] ? $_POST['contractor_name'] : "") . "</td>
</tr>";
$mailer->Body .= "
<tr>
<th bgcolor='#f0f6fa'>전화번호</th>
<td>" . ($_POST['tel1'] && $_POST['tel2'] && $_POST['tel3'] ? $_POST['tel1'] . "-" . $_POST['tel2'] . "-" . $_POST['tel3'] : "-") . "</td>
<th bgcolor='#f0f6fa'>핸드폰</th>
<td>" . ($_POST['hp1'] && $_POST['hp2'] && $_POST['hp3'] ? $_POST['hp1'] . "-" . $_POST['hp2'] . "-" . $_POST['hp3'] : "-") . "</td>
</tr>";
$mailer->Body .= "
<tr>
<th bgcolor='#f0f6fa'>납품처주소</th>
<td colspan='3'>" . ($_POST['address'] ? $_POST['address'] : "") . "</td>
</tr>";
$mailer->Body .= "
<tr>
<th bgcolor='#f0f6fa' colspan='4'>주문정보</th>
</tr>
<tr>
<th bgcolor='#f0f6fa' colspan='2'>품목</th><th>규격</th><th>수량</th>
</tr>";
/*for($i = 1; $i <= 10; $i++) {
if ($_POST['product_name_1'] && $_POST['product_std_1'] && $_POST['quantity_1']) {
$mailer->Body .="
<tr>
<td colspan='2'>" . $_POST['product_name_1'] . "</td>
<td>" . $_POST['product_std_1'] . "</td>
<td>" . $_POST['quantity_1'] . "</td>
</tr>";
}
}*/
if ($_POST['product_name_1'] && $_POST['product_std_1'] && $_POST['quantity_1']) {
$mailer->Body .="
<tr>
<td colspan='2'>" . $_POST['product_name_1'] . "</td>
<td>" . $_POST['product_std_1'] . "</td>
<td>" . $_POST['quantity_1'] . "</td>
</tr>";
}
if ($_POST['product_name_2'] && $_POST['product_std_2'] && $_POST['quantity_2']) {
$mailer->Body .="
<tr>
<td colspan='2'>" . $_POST['product_name_2'] . "</td>
<td>" . $_POST['product_std_2'] . "</td>
<td>" . $_POST['quantity_2'] . "</td>
</tr>";
}
if ($_POST['product_name_3'] && $_POST['product_std_3'] && $_POST['quantity_3']) {
$mailer->Body .="
<tr>
<td colspan='2'>" . $_POST['product_name_3'] . "</td>
<td>" . $_POST['product_std_3'] . "</td>
<td>" . $_POST['quantity_3'] . "</td>
</tr>";
}
if ($_POST['product_name_4'] && $_POST['product_std_4'] && $_POST['quantity_4']) {
$mailer->Body .="
<tr>
<td colspan='2'>" . $_POST['product_name_4'] . "</td>
<td>" . $_POST['product_std_4'] . "</td>
<td>" . $_POST['quantity_4'] . "</td>
</tr>";
}
if ($_POST['product_name_5'] && $_POST['product_std_5'] && $_POST['quantity_5']) {
$mailer->Body .="
<tr>
<td colspan='2'>" . $_POST['product_name_5'] . "</td>
<td>" . $_POST['product_std_5'] . "</td>
<td>" . $_POST['quantity_5'] . "</td>
</tr>";
}
$mailer->Body .="<tr><th bgcolor='#f0f6fa'>배송방법</th><td colspan='3'>" . ($_POST['delivery'] ? '소화물' : '택배') . "</td></tr>";
$mailer->Body .="<tr><th bgcolor='#f0f6fa'>내용</th><td colspan='3'>" . (nl2br($_POST['content'])) . "</td></tr>";
$mailer->Body .= "</table>";
$mailer->Body .= "</body>";
$mailer->Body .= "</html>";
if ($mailer->Send()) {
header("Location: http://bigbolt.co.kr"); exit;
/*echo "<script language='javascipt'>
alert('발송성공!');
//window.location = 'http://bigbolt.co.kr';
</script>";*/
} else {
header("Location: http://bigbolt.co.kr"); exit;
/*echo "<script language='javascipt'>
alert('발송실패!');
//window.location = 'http://bigbolt.co.kr';
</script>";*/
}
} else {
echo "자료가 없습니다!";
echo "
<html>
<body>
<script language='javascipt'>
alert('주문/문의 정보가 없습니다.');
location.href('http://bigbolt.co.kr');
</script>
</body>
</html>";
}
?>
댓글 전체