묻고답하기
[폼메일] 서버를 이전했더니 폼메일이 작동안합니다.
2009.05.29 14:17
서버를 이전했더니 폼메일이 작동안합니다.
외국에서 받던 호스팅을 가비아로 옮겼는데 동작을 안하네요.
가비아에서는 소스는 수정해주지 않는다고 하고, 난감하네요.
따로 수정을 맡겨야 하나요? 아니면 간단히 해결되나요?
알고계신분 답변좀 부탁드릴께요 ^^
좋은 하루 되세요.
<?php
//VARIABLES
//$name = $_POST['name'];
//$query = "INSERT INTO phoneCounseling (name, email, message, contact_date) VALUES ('$name', '$email', '$message', NOW())";
//$result = mysql_query($query) or trigger_error("Query: $query\n<br />MySQL Error: ".mysql_error());
function redirect($page) {
//set url
$url = 'http://' . $_SERVER['HTTP_HOST'+
'+
'] . dirname($_SERVER['PHP_SELF']);
//check for trailing slash
if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\')) {
$url = substr ($url, 0, -1);
}
//add the page
$url .= '/'.$page;
//clear buffering
ob_end_clean();
header("Location: $url");
exit();
}
$errors = false;
//$errors = array():
if (isset($_POST['submit'])) {
//variables
$name = $_POST['name'+
'];
$pn_area = (int)$_POST['phone_area'];
$pn_pfx = (int)$_POST['phone_pfx'];
$pn_num = (int)$_POST['phone_num'];
$interest = $_POST['interest'];
$hour = $_POST['+
'hour'];
$to = 'line@nemonan.co.kr';
//$to = 'line@nemonan.co.kr';
$subject = 'Phone Counseling';
//form validation-------------------------------------------
if (empty($name)) {$errors = true;$errorName = 'Please enter your name';}
if (empty($pn_area)) {$errors = true;$errorPhone = 'Please enter your phone number';}
if (empty($pn_pfx)) {$errors = true;$errorPhone = 'Please enter your phone number';}
if (empty($pn_num)) {$errors = true;$errorPhone = 'Please enter your phone number';}
if (!$pn_area) {$errors = true;$errorPhone = 'Only numbers are allowed for phone number';}
if (!$pn_pfx) {$errors = true;$errorPhone = 'Only numbers are allowed for phone number';}
if (!$pn_num) {$errors = true;$errorPhone = 'Only numbers are allowed for phone number'+
';}
if ($interest=="select") {$errors = true;}
if ($hour=="select") {$errors = true;}
//if there are no errors, e-mail the value
if (!$errors) {
$headers = "From: ".$to."\n";
$headers .= "Reply-To: ".$to."\n";
$headers .= "Mailed-By: ".$to."\n";
$headers .= "MIME-Version: 1.0\n";
$body = "$mime_boundary\n";
$body .= "Customer Name: $name\n";
$body .= "Phone Number: $pn_area-$pn_pfx-$pn_num\n";
$body .= "Type of Interest: $interest\n";
$body .= "Desired Hour: $hour\n";
$sendEmail = mail($to, $subject, $body, $headers);
if ($sendEmail) {
$sendMail = 0;
$name = '';
$pn_area = '';
$pn_pfx = '';
$pn_num = '';
$interest = '';
$hour = '';
//echo 'email success';
} else {
$sendMail = 1;
//echo 'email failed';
}
}
//if there are errors, display error message
else {
echo 'error: true';
}
}
?>
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
<div id="pcFormWrapper">
<div class="formDesc">Our medical professional will contact your for phone counseling at your convenience hours</div>
<?php if ($sendMail=='0') { ?>
<div class="phoneResultSuccess"><img src="images/ico_phone_success.gif" alt="Success" />Your request has been sent successfully</div>
<?php } if ($sendMail=='1') { ?>
<div class="phoneResultFailed"><img src="images/ico_phone_failed.gif" alt="Failed" />We'+
're sorry. Your request has been failed due to system error.</div>
<?php } ?>
<?php //foreach ($errors as $msg) {echo $msg.'<br />';} ?>
<div class="pcForm">
<p>
<label>Name</label><br />
<input type="text" name="name" value="<?php echo $name;?>" />
<?php if ($errors) {if ($errorName) { echo '<span class="error"><img src="images/error.gif" alt="Error" />'.$errorName.'</span>';}} ?>
</p>
<p>
<label>Phone#</label><br />
<input type="text" name="phone_area" value="<?php echo $pn_area;?>" size="2" maxlength="3" /> -
<input type="text" name="phone_pfx" value="<?php echo $pn_pfx;?>" size="2" maxlength="3" /> -
<input type="text" name="phone_num" value="<?php echo $pn_num;?>" size="2" maxlength="4" />
<?php if ($errors) {if ($errorPhone) { echo '<span class="error"><img src="images/error.gif" alt="Error" />'.$errorPhone.'</span>';}} ?>
</p>
<p>
<label>Type of Interest</label><br />
<select name="interest">
<option value="select">Select Interest</option>
<option value="acne" <?php if ($interest == 'acne') { ?> selected="selected" <?php } ?>>Acne</option>
<option value="laser hair removal" <?php if ($interest == 'laser hair removal') { ?> selected="selected" <?php } ?>>Laser Hair Removal</option>
<option value="melasma" <?php if ($interest == 'melasma') { ?> selected="selected" <?php } ?>>Melasma</option>
<option value="rosacea" <?php if ($interest == 'rosacea') { ?> selected="selected" <?php } ?>>Rosacea</option>
<option value="scars" <?php if ($interest == 'scars') { ?> selected="selected" <?php } ?>>Scars</option>
<option value="skin tightening and toning" <?php if ($interest == 'skin tightening and toning') { ?> selected="selected" <?php } ?>>Skin Tightening &Toning</option>
<option value="overall complexion" <?php if ($interest == 'overall complexion') { ?> selected="selected" <?php } ?>>Overall Complexion</option>
<option value="product recommendations" <?php if ($interest == 'product recommendations') { ?> selected="selected" <?php } ?>>Product Recommendations</option>
</select>
<?php if($interest=="select"){?><span class="error"><img src="images/error.gif" alt="Error" />Please select your interest</span><?php }?>
</p>
<p>
<label>Desired Hours</label><br />
<select name="hour">
<option value="select">Select Hour</option>
<option value="morning" <?php if ($hour == 'morning') { ?> selected="selected" <?php } ?>>Morning</option>
<option value="afternoon" <?php if ($hour == 'afternoon') { ?> selected="selected" <?php } ?>>Afternoon</option>
<option value="evening" <?php if ($hour == 'evening') { ?> selected="selected" <?php } ?>>Evening</option>
</select>
<?php if($hour=="select"){?><span class="error"><img src="images/error.gif" alt="Error" />Please select your desired hour</span><?php }?>
</p>
<p class="buttonCenter"><input type="image" src="images/btn_submit.png" alt="Submit" value="SUBMIT" name="submit" /></p>
</div>
</div>
</form>
가비아에 문의를 하시면 사용할 수 있는 간단한 폼메일 폼을 보내주더군요..
그 소스로 한번 작성해보세요...
제가 만들었던 것은....php5환경에서는 작동하지 않더라구요..