PHP 프로그래밍

본문 바로가기
사이트 내 전체검색


Web Programming >> PHP Programming
[목차]
제21장 온라인 서점 쇼핑몰 만들기

    7. 사용자(구매자) - 제품 목록 보기

디렉토리 및 파일 구조는 다음과 같다.

/ --  shop/ -- admin/ --- product/ --(제품관리)

             |         |            |

             |         |            +-- list.html

             |         |            +-- postform.html.html

             |         |            +-- post.html

             |         |            +-- viewbody.html

             |         |            +-- modifyform.html

             |         |            +-- modify.html

             |         |            +-- deleteform.html

             |         |            +-- delete.html

             |         |

             |         +- order/ (주문관리)

             |         |          |

             |         |          +-- index.html

             |         |          +-- viewuser.html

             |         |          +-- modify.html

             |         |          +-- delete.html

             |         |

             |         +- admin.html (관리자 인증에 필요한 파일)

             |         +- index.html (아이디와 암호를 입력하는 폼)

             |         +- login_process.html (로그인 처리프로그램)

             |         +- home.html (관리자 화면)

             |         +- menu.html (메뉴)

             |         +- welcome.html (환영 메시지)

             |         +- logout.html (종료 프로그램)

             |

             +-- user_function.html (사용자 정의 함수들)

             +-- dbconn.html (DB connect에 필요한 파일)

             |

             +-- index.html (온라인 서점 처음화면)

             +-- top.html

             +-- menu.html (메뉴)

             +-- welcome.html

             +-- list.html (제품 목록 보기)

             +-- viewproduct.html (제품 세부내역 보기)

             |

             +-- save_bag.html (장바구니 담기)

             +-- list_bag.html (장바구니 보기)

             +-- modify.html (주문내역 수정하기)

             +-- delete.html (주문내역 삭제하기)

             +-- order.html (주문자 신상명세 입력 및 주문하기)

             +-- confirm.html (주문 처리하기)

 여기서 구현해야 할 기능은 장바구니 담기, 장바구니 보기, 주문하기이다. 따라가면서 작성해 보기 바란다.

 

1. 장바구니 담기

파일명 : save_bag.html

<?

session_start();

 

include "./user_function.html";

include "./dbconn.html";

 

$query = "SELECT uid,amount FROM temp_bag WHERE product_uid = $number AND uid = $user_uid";

 

$result = mysql_query($query);

if(!$result) {

    error("QUERY_ERROR");

    exit;

}

$total_record = mysql_num_rows($result);   

if($total_record > 0) {

    $row = mysql_fetch_row($result);

 

        $my_uid = $row[0];

    $my_amount = $row[1];

 

    $my_amount ++;

    $result1 = mysql_query("UPDATE temp_bag SET amount = $my_amount WHERE uid = $my_uid");

    if(!$result1) {

          error("QUERY_ERROR");

          exit;

    }    

 

}

else {

    $query = "SELECT price FROM product WHERE uid = $number";

    $result = mysql_query($query);

    if(!$result) {

          error("QUERY_ERROR");

          exit;

    }

    $row1 = mysql_fetch_object($result);

 

    $my_amount = 1;

    $query = "INSERT INTO temp_bag (product_uid,user_uid,price,amount) ";

    $query .= "VALUES ($number,'$user_uid',$row1->price,$my_amount)";

    $result = mysql_query($query);

    if (!$result) {      

           error("QUERY_ERROR");

       exit;

    }

}

 

echo ("<meta http-equiv='Refresh' content='0; URL=./list.html?part=$part'>");

 

?> 

 

2. 장바구니 보기

파일명 : list_bag.html

<?

session_start();

 

include "./user_function.html";

include "./dbconn.html";

?>

<html>

<head>

<title>온라인 서점</title>

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

<meta http-equiv='Refresh'>

 

<style type="text/css">

   <!--

   a:link,a:visited,a:active {

      text-decoration : none;

   }

   a:hover {

      text-decoration : none;

      color : red;

   }

   TABLE, TD, TR, TH {

      font-size : 10pt;

   }

   //-->

</style>

<script language="javascript">

<!--

function checkInput (form) {

 

   form.submit();

}

 

function setfocus(frm) {

        frm.focus();

}

 

function setfocus1(frm) {

        frm.focus();

        frm.select();

}

-->

</script>

</head>

<body bgcolor="#ffffff" >

<table width="600" cellspacing="0" cellpadding="0" border="0" align="left">

<tr><td align="left">

<?

$TITLE_BG = "white";                    // 각 타이틀에 대한 배경색

$COLUMN_NAME = "#CFE7A0";               // 입력항목 이름에 대한 배경색

$COLUMN_VALUE = "#FAFAEE";              // 입력양식에 대한 배경색

$LIST_TH_COLOR = "#CFE7A0";

$LIST_TD_COLOR = "#FFFFFF";

 

$icon = "./icon";

?>

<table width="600" cellspacing="0" cellpadding="0" border="0" align="center">

<tr><td align="center" bgColor="#339966">

<table width="600" cellspacing="1" cellpadding="2" border="0" align="center">

<tr>

   <td align="center" bgColor=<?echo("$LIST_TH_COLOR")?> width=220>제품</td>

   <td align="center" bgColor=<?echo("$LIST_TH_COLOR")?> width=80>수량</td>

   <td align="center" bgColor=<?echo("$LIST_TH_COLOR")?> width=100>단가</td>

   <td align="center" bgColor=<?echo("$LIST_TH_COLOR")?> width=100>금액</td>

   <td align="center" width=50 bgColor=<?echo("$LIST_TH_COLOR")?>>수정</td>

   <td align="center" width=50 bgColor=<?echo("$LIST_TH_COLOR")?>>삭제</td>

</tr>

<?

$query = "SELECT count(uid) FROM temp_bag where user_uid=$user_uid ";

$result = mysql_query($query);

if (!$result) {

    error("QUERY_ERROR");

    exit;

}

$total_record = mysql_result($result,0,0);

 

$query = "SELECT uid,product_uid,price,amount FROM temp_bag where user_uid=$user_uid";

 

$result= mysql_query($query);

if (!$result) {

   error("QUERY_ERROR");

   exit;

}

 

$totalprice = 0;

 

for($i = 0; $i < $total_record; $i++) {

   $my_uid = mysql_result($result,$i,0);   

   $pro_uid = mysql_result($result,$i,1);

   $my_price = mysql_result($result,$i,2);

   $my_amount = mysql_result($result,$i,3);

 

   $query1 = "SELECT name,author FROM product where uid = '$pro_uid'";

 

   $result1 = mysql_query($query1);

   if (!$result1) {

      error("QUERY_ERROR");

      exit;

   }

 

   $cnt = mysql_num_rows($result1);   

   if($cnt) {

        $my_product_name = mysql_result($result1,0,0);

        $my_product_author = mysql_result($result1,0,0);

   }

 

   $my_totalprice = $my_price * $my_amount;

   $totalprice += $my_totalprice;

   $my_totalprice = number_format($my_totalprice);

   $my_price = number_format($my_price);

 

   echo("<tr>\n");   

   echo("   <td bgColor=$LIST_TD_COLOR align=\"left\">&nbsp;$my_product_name</td>\n");

   echo("   <td bgColor=$LIST_TD_COLOR align=\"right\">$my_amount&nbsp;</td>\n");

   echo("   <td bgColor=$LIST_TD_COLOR align=\"right\">$my_price&nbsp;</td>\n");

   echo("   <td bgColor=$LIST_TD_COLOR align=\"right\">$my_totalprice&nbsp;</td>\n");

   echo("<td bgColor=$LIST_TD_COLOR align=\"center\">

   <a href=\"modify.html?mode=form&number=$my_uid\">V</a></td>");

   echo("<td bgColor=$LIST_TD_COLOR align=\"center\" >

   <a href=\"delete.html?mode=form&number=$my_uid\">X</a></td>");

   echo("</tr>\n");   

}

echo("</table>\n");

?>

   </td>

</tr>

</table>

</td></tr>

<tr><td align="left" height=25>

</td></tr>

<tr><td align="left">

<table width="600" cellspacing="1" cellpadding="0" border="0" align="center">

<form name="signform" method="POST" action="order.html">

<INPUT TYPE="hidden" name="task" value="order">

<INPUT TYPE="hidden" name="company_uid" value="<?echo("$company_uid");?>">

<tr><td align="center" bgColor="#339966">

<table width="600" cellspacing="1" cellpadding="5" border="0" align="center">

<tr>

   <td width="100" height=25 bgColor="<?echo("$COLUMN_NAME")?>" align="center">합계</td>

   <td width="500"  bgColor="<?echo("$COLUMN_VALUE")?>" colspan="3"><?echo("$totalprice");?>

   </td>

</tr>

<tr>

   <td align="center" colspan="4" bgColor="#FFFFFF">

      <input type="button" value="   주문하기   " onClick="checkInput(this.form)">

   </td>

</tr>

</table>

</td></tr>

</table><p>

</form>

</td></tr>

</table>

</body>

</html>

 

3. 주문내용 수정하기 및 삭제하기

파일명 : modify.html

<?

session_start();

 

include "./user_function.html";

include "./dbconn.html";

 

########## 전달된 변수 $mode의 값이 "form"일 경우 수정양식을 출력한다. ##########

if(!strcmp($mode,"form")) {

 

   ########## 현재 로그인한 사용자의 데이터를 회원테이블에서 가져온다. ##########

   $query = "SELECT product_uid,amount,price FROM temp_bag WHERE uid = $number";

   $result = mysql_query($query);

   if(!$result) {

      error("QUERY_ERROR");

      exit;

   }

   $row = mysql_fetch_object($result);

   

   $query1 = "SELECT name,price FROM product WHERE uid=$row->product_uid";

   $result1= mysql_query($query1);

   if (!$result1) {

        error("QUERY_ERROR");

        exit;

   }

 

   $my_name = mysql_result($result1,0,0);

   $my_dc_price = mysql_result($result1,0,1);

 

 

?>

<html>

<head>

<title>온라인 서점 쇼핑몰</title>

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

 

   <style type="text/css">

   <!--

   a:link,a:visited,a:active {

      text-decoration : none;

   }

   a:hover {

      text-decoration : none;

      color : red;

   }

   TABLE, TD, TR, TH {

      font-size : 10pt;

   }

   //-->

   </style>

   <script language="javascript">

   <!--

   function checkInput (form) {

      

      form.submit();

   }

   

 

   //-->

   </script>

</head>

 

<body bgcolor="white" text="black" link="blue" vlink="purple" alink="red">

 

<?

$TITLE_BG = "#CFE09F";                  // 각 타이틀에 대한 배경색

$COLUMN_NAME = "#F0F8DC";               // 입력항목 이름에 대한 배경색

$COLUMN_VALUE = "#FAFAEE";              // 입력양식에 대한 배경색

 

$php_self = basename($PHP_SELF);

?>

 

<form name="signform" method="POST" action="<?echo("$php_self")?>?mode=process&number=<?echo("$number")?>">

<input type="hidden" name="dc_price" value='<?echo("$my_dc_price")?>'>

 

<table width="500" cellspacing="1" cellpadding="0" border="0" align="left">

<tr><br><td align="center" bgColor="#ffffff">

<table width="500" cellspacing="1" cellpadding="5" border="0" align="center">

<tr>

   <td width="500" align="center" bgColor="<?echo("$TITLE_BG")?>" colspan=4>주문내용을 수정하는 곳입니다.</td>

</tr>

<tr>

   <td width="120" bgColor="<?echo("$COLUMN_NAME")?>" align="center">물품명(번호)</td>

   <td width="380" bgColor="<?echo("$COLUMN_VALUE")?>" colspan="3">

      <?echo("$my_name")?>

   </td>

</tr>

<tr>

   <td width="120" bgColor="<?echo("$COLUMN_NAME")?>" align="center">수량</td>

   <td width="380" bgColor="<?echo("$COLUMN_VALUE")?>" colspan="3">

        <input type="text" name="amount" size="3" maxlength="3" value="<?

         echo("$row->amount");

        ?>">

   </td>

</tr>

 

<tr>

   <td align="center" colspan="4" bgColor="#FFFFFF">

   <font size=2>

      <input type="button" value="주문내용 수정" onClick="checkInput(this.form)">

      <input type="reset" value="다시 입력">

   </font>

   </td>

</tr>

<tr>

        <td align="center" colspan="4">

                <p>&nbsp;</p>

        </td>

</tr>

<tr>

        <td align="center" colspan="4">

                <a href="./list_bag.html">장바구니 보기로</a>

        </td>

</tr>

</table>

 

</td></tr>

</table><p>

 

</form>

 

 

</body>

</html>

<?

########## 전달된 변수 $mode의 값이 "process"일 경우 입력양식의 값으로 회원정보를 갱신한다. ##########

} else if(!strcmp($mode,"process")) {

 

        $total_price = $amount * $dc_price;

 

   ########## 사용자가 입력양식에 입력한대로 회원정보를 갱신한다.##########

    $query  = "UPDATE temp_bag SET amount = $amount,price =$total_price WHERE uid = $number";  

//echo("$query");

   $result = mysql_query($query);

   if(!$result) {

      error("QUERY_ERROR");

      exit;

   }

   

   ########## 회원목록 출력화면으로 이동한다. ##########

   echo("<meta http-equiv='Refresh' content='0; URL=./list_bag.html'>");      

 

########## 전달된 변수 $mode의 값이 "mode"나 "process"가 아닐 경우 스크립트의 실행을 종료한다.

} else {

   error("UPDATE_MEMBER_INVALID_MODE");

   exit;

}

?>

 

 

파일명 : delete.html

<?

session_start();

 

include "./user_function.html";

include "./dbconn.html";

 

########## 전달된 변수 $mode의 값이 "form"일 경우 삭제확인화면을 출력한다. ##########

if(!strcmp($mode,"form")) {

 

   ########## 현재 로그인한 사용자의 데이터를 회원테이블에서 가져온다. ##########

   $query = "SELECT product_uid,amount,price FROM temp_bag WHERE uid = $number";

   $result = mysql_query($query);

   if(!$result) {

      error("QUERY_ERROR");

      exit;

   }

   $row = mysql_fetch_object($result);

   

   $query1 = "SELECT name FROM product WHERE uid=$row->product_uid";

   $result1= mysql_query($query1);

   if (!$result1) {

        error("QUERY_ERROR");

        exit;

   }

 

   $my_name = mysql_result($result1,0,0);

 

?>

<html>

<head>

<title><?echo("$admin_head_title");?></title>

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

 

   <style type="text/css">

   <!--

   a:link,a:visited,a:active {

      text-decoration : none;

   }

   a:hover {

      text-decoration : none;

      color : red;

   }

   TABLE, TD, TR, TH {

      font-size : 10pt;

   }

   //-->

   </style>

</head>

 

<body bgcolor="white" text="black" link="blue" vlink="purple" alink="red">

 

<?

$TITLE_BG = "#CFE09F";                  // 각 타이틀에 대한 배경색

$COLUMN_NAME = "#F0F8DC";               // 입력항목 이름에 대한 배경색

$COLUMN_VALUE = "#FAFAEE";              // 입력양식에 대한 배경색

$icon = "../icon";

 

$php_self = basename($PHP_SELF);

?>

 

<form name="signform" method="POST" action="<?echo("$php_self")?>?mode=process&number=<?echo("$number")?>">

 

<table width="500" cellspacing="1" cellpadding="0" border="0" align="left">

<tr><br><td align="center" bgColor="#ffffff">

 

<table width="500" cellspacing="1" cellpadding="5" border="0" align="center">

 

<tr>

   <td width="500" align="center" bgColor="<?echo("$TITLE_BG")?>" colspan=2><?echo("<b>$my_name</b>")?> 주문 내역을 <font color=red>삭제합니다</font>.</td>

</tr>

 

<tr>

   <td width="120" bgColor="<?echo("$COLUMN_NAME")?>" align="center">물품명</td>

   <td width="380" bgColor="<?echo("$COLUMN_VALUE")?>">

      <?echo("$my_name")?>

   </td>

</tr>

<tr>

   <td width="120" bgColor="<?echo("$COLUMN_NAME")?>" align="center">수량</td>

   <td width="380" bgColor="<?echo("$COLUMN_VALUE")?>">

<? echo("$row->amount");?>

</select>

   </td>

</tr>

 

<tr>

   <td width="120" bgColor="<?echo("$COLUMN_NAME")?>" align="center">단가</td>

   <td width="380" bgColor="<?echo("$COLUMN_VALUE")?>">

      <?echo("$row->price");?>

   </td>

</tr>

 

<!------------------------- 등록버튼  --------------------------->

<tr>

   <td align="center" colspan="2" bgColor="#FFFFFF">

   <font size=2>

      <input type="submit" value='<?echo("$my_name")?> 주문 내역을 삭제합니다'>      

   </font>

   </td>

</tr>

<tr>

        <td align="center" colspan="2">

                <p>&nbsp;</p>

        </td>

</tr>

<tr>

        <td align="center" colspan="2">

                <a href="./list_bag.html" >장바구니 보기로</a>

        </td>

</tr>

</table>

 

</td></tr>

</table><p>

 

</form>

 

 

</body>

</html>

<?

########## 전달된 변수 $mode의 값이 "process"일 경우 입력양식의 값으로 회원정보를 갱신한다. ##########

} else if(!strcmp($mode,"process")) {

 

   ########## 회원데이터를 데이터베이스에서 삭제한다. ##########      

   $result = mysql_query("DELETE FROM temp_bag WHERE uid = '$number'");

   if(!$result) {

      error("QUERY_ERROR");

      exit;

   }

   

   ########## 회원목록 출력화면으로 이동한다. ##########

   echo("<meta http-equiv='Refresh' content='0; URL=./list_bag.html'>");      

 

########## 전달된 변수 $mode의 값이 "mode"나 "process"가 아닐 경우 스크립트의 실행을 종료한다. ##########   

} else {

   error("UPDATE_MEMBER_INVALID_MODE");

   exit;

}

?>

 

 

4. 주문하기

파일명 : order.html

<?

session_start();

 

include "./user_function.html";

include "./dbconn.html";

 

if(!$user_uid) {

   echo ("<meta http-equiv='Refresh' content='0; URL=welcome.html'>");

   exit;

}

 

if($task != "order") {

   echo ("<meta http-equiv='Refresh' content='0; URL=welcome.html'>");

   exit;

}

 

?>

<html>

<head>

   <title>온라인 쇼핑몰</title>

   <style type="text/css">

   <!--

   a:link,a:visited,a:active {

      text-decoration : none;

   }

   a:hover {

      text-decoration : none;

      color : red;

   }

   TABLE, TD, TR, TH {

      font-size : 10pt;

   }

   //-->

   </style>

 

</head>

<body bgcolor="white" text="black" link="blue" vlink="purple" alink="red">

<form name="signform" method="POST"  action="confirm.html">

<p>&nbsp;

<div align="center"><table border="0" cellpadding="0" width="500">

<tr>

<td width="500"><font size="3"><b>상품 배달 주소 및 상품 확인</b></td>

</tr>

<tr>

<td width="500"><p align="left">&nbsp;</p>

<p align="right"><b>주문번호 : <?echo("$user_uid");?></b>

<br>

<p align="left">주문한 도서 목록입니다.

<div align="center"><table border=1 width="500" bordercolor="white">

<tr>

<td align="center" width="142" height="14" bgcolor="#70FFB9" bordercolor="green">상 &nbsp;&nbsp;품</td>

<td align="center" width="142" height="14" bgcolor="#70FFB9" bordercolor="green">가 &nbsp;&nbsp;격</td>

<td align="center" width="142" height="14" bgcolor="#70FFB9" bordercolor="green">수 &nbsp;&nbsp;량</td>

<td align="center" width="142" height="14" bgcolor="#70FFB9" bordercolor="green">금 &nbsp;&nbsp;액</td>

</tr>

<?

$query="SELECT uid,product_uid,amount,price FROM temp_bag WHERE user_uid = $user_uid";

$result = mysql_query($query);

//echo("$query");

if (!$result) {

   error("QUERY_ERROR");

   exit;

}

$rows = mysql_num_rows($result);

$total_price = 0;

 

for($i=0;$i<$rows; $i++) {

   $sale_uid = (int)mysql_result($result,$i,0);

   $product_uid = (int)mysql_result($result,$i,1);

   $amount = (int)mysql_result($result,$i,2);

   $product_price = mysql_result($result,$i,3);

 

   $total_price = ($product_price * $amount) + $total_price;

   $my_price = $product_price * $amount;

 

   $query1="SELECT uid,name FROM product WHERE uid=$product_uid";

   $result1 = mysql_query($query1);

   if (!$result1) {

      error("QUERY_ERROR");

      exit;

   }     

   $rows1 = mysql_num_rows($result);

   if($rows1 > 0) {

        $product_name = mysql_result($result1,0,1);

   }

   $product_price = number_format($product_price);

   $my_price = number_format($my_price);

?>

<tr>

<td align="center" width="142" height="16" bgcolor="#70FFB9" bordercolor="green"><?echo("$product_name");?></td>

<td align="right" width="142" height="16" bordercolor="green"><?echo("$product_price");?></td>

<td align="right" width="142" height="16" bordercolor="green"><?echo("$amount");?>개

</td>

<td align="right" width="142" height="16" bordercolor="green"><?echo("$my_price");?>원

</td>

</tr>

<?

}

$total_price = number_format($total_price);

?>

</table><br>

<p align="right"><b>총합 : <?echo("$total_price");?> 원</b>

</div>

&nbsp;</p>

<p align="left">배달 주소를 입력해 주세요.

<div align="center"><table border width="500" bordercolor="white">

<tr>

<td align="center" width="120" bgcolor="#70FFB9" bordercolor="green">이 &nbsp;&nbsp;름

</td>

<td width="380"><p><input type="text" name="name" size="15"></td>

</tr>

<tr>

<td align="center" width="120" bgcolor="#70FFB9" bordercolor="green">연락처(전화번호)</td>

<td width="380"><p><input type="text" name="phone" size="15"></td>

</tr>

<tr>

<td align="center" width="120" bgcolor="#70FFB9" bordercolor="green">배달 주소</td>

<td width="380"><p><input type="text" name="address" size="50"></td>

</tr>

<tr>

<td align="center" width="120" bgcolor="#70FFB9" bordercolor="green">전하는 말</td>

<td width="380"><p align="left"><textarea name="desp" rows="4" cols="50"></textarea></td>

</tr>

</table></div>

<p>&nbsp;</td>

</tr>

<tr>

<td width="500" align="center"><font face="굴림">

<input type="submit" name="smbuit" value="확인"><font face="굴림">

<input type="reset" name="reset" value="다시작성"></td>

</tr>

</table></div>

<p>&nbsp;</p></form>

</body>

</html>

 

 

 

5. 주문 확인하기

파일명 : confirm.html

<?

session_start();

 

include "./user_function.html";

include "./dbconn.html";

 

$query="SELECT uid FROM temp_bag WHERE user_uid = $user_uid";

$result = mysql_query($query);

if (!$result) {

   error("QUERY_ERROR");

   exit;

}

$rows = mysql_num_rows($result);

 

if(!$rows) {

?>

   <script language="javascript">

   <!--

   window.alert('주문한 내용이 없습니다.')

   history.go(-1)

   -->

 </script>

<?

        exit;

}

 

if($name == "" || $phone=="" || $address =="") {

?>

   <script language="javascript">

   <!--

   window.alert('고객 입력사항 중 빠진 부분이 있습니다.\n확인하시고 빠진 부분을 입력하세요.')

   history.go(-1)

   -->

 </script>

 

<?

  exit;

}

 

 

$signdate = time();

 

$query="SELECT uid FROM sold WHERE uid=$user_uid";

$result = mysql_query($query);

 

if (!$result) {

   error("QUERY_ERROR");

   exit;

}

$rows = mysql_num_rows($result);

 

if(!$rows) {

   $query = "INSERT INTO sold (uid,name,phone,address,desp,status,signdate) ";

   $query .= "VALUES ($user_uid,'$name','$phone','$address','$desp','1',$signdate)";

   $result = mysql_query($query);

// echo("$query");

 

   if (!$result) {      

       error("QUERY_ERROR");

       exit;

   }

}

else {

   ########## 사용자가 입력양식에 입력한대로 회원정보를 갱신한다.##########

   $query  = "UPDATE sold SET name ='$name', phone = '$phone', address = '$address',";

   $query  .= "desp = '$desp',status='1',signdate=$signdate  WHERE uid = $user_uid";

   

   echo("$query");

 

   $result = mysql_query($query);

   if(!$result) {

      error("QUERY_ERROR");

      exit;

   }

}

 

if($to == "") $to = "webmaster@leelab.co.kr";

 

$subject = "온라인 주문 신청서";

$from = "jklee@leelab.co.kr";

$rn = "jklee@leelab.co.kr";

$body = "

<style type=\"text/css\">

   a:link,a:visited,a:active {

      text-decoration : none;

   }

   a:hover {

      text-decoration : none;

      color : red;

   }

   TABLE, TD, TR, TH {

      font-size : 10pt;

   }

</style>

<div align='center'><table border='0' cellpadding='0' width='600'>

<tr>

<td width='600'><p align='center'><font size='3'><b>상품 주문서 확인</b></td>

</tr>

<tr>

<td width='600'><p>&nbsp;</p>

<p align='right'><b>주문번호 : ".$user_uid."</b>

<br>

<p align='left'>상품 갯수 확인

<div align='center'><table border width='500' bordercolor=\"white\">

<tr>

<td align='center' width='142' height='14' bgcolor=\"#70FFB9\" bordercolor=\"green\">상&nbsp;&nbsp;품</td>

<td align='center' width='142' height='14' bgcolor=\"#70FFB9\" bordercolor=\"green\">단&nbsp;&nbsp;가</td>

<td align='center' width='142' height='14' bgcolor=\"#70FFB9\" bordercolor=\"green\">수&nbsp;&nbsp;량</td>

<td align='center' width='142' height='14' bgcolor=\"#70FFB9\" bordercolor=\"green\">금&nbsp;&nbsp;액</td>

</tr>";

$query="SELECT uid,product_uid,amount,price FROM temp_bag WHERE user_uid = $user_uid";

$result = mysql_query($query);

//echo("$query");

if (!$result) {

   error("QUERY_ERROR");

   exit;

}

$rows = mysql_num_rows($result);

$total_price = 0;

$body_phone = "신청하신 사항은 ";

 

for($i=0;$i<$rows; $i++) {

   $sale_uid = (int)mysql_result($result,$i,0);

   $product_uid = (int)mysql_result($result,$i,1);

   $amount = (int)mysql_result($result,$i,2);

   $product_price = (int)mysql_result($result,0,3);

   $my_total_price = $product_price * $amount;

   $total_price = $my_total_price + $total_price;

 

   $query1="SELECT uid,name FROM product WHERE uid=$product_uid";

   $result1 = mysql_query($query1);

 

   if (!$result1) {

      error("QUERY_ERROR");

      exit;

   }          

   $product_name = mysql_result($result1,0,1);

 

   $query2 = "INSERT INTO sale_bag (product_uid,user_uid,price,amount) ";

   $query2 .= "VALUES ($product_uid,'$user_uid',$product_price,$amount)";

   $result2 = mysql_query($query2);

   if (!$result2) {      

       error("QUERY_ERROR");

       exit;

   }

 

   $query2 = "DELETE FROM temp_bag where uid = $sale_uid";

   $result2 = mysql_query($query2);

   if (!$result2) {      

        error("QUERY_ERROR");

        exit;

    }

    $product_price = number_format($product_price);

    $my_total_price = number_format($my_total_price);

 

        $body_phone .= $product_name."은 ".$amount."개 입니다.";

 

$body .= "

<tr>

<td align=\"center\" width='142' height='16' bgcolor=\"#70FFB9\" bordercolor=\"green\">".$product_name."</td>

<td align=\"right\" width='142' height='16'bordercolor=\"green\">".$product_price."</td>

<td align=\"right\" width='142' height='16'bordercolor=\"green\">".$amount."개</td>

<td align=\"right\" width='142' height='16'bordercolor=\"green\">".$my_total_price."</td>

</tr>";

}

 

$query="SELECT uid,name,phone,address,desp FROM sold WHERE uid=$user_uid";

$result = mysql_query($query);

 

if (!$result) {

   error("QUERY_ERROR");

   exit;

}

$name = mysql_result($result,0,1);

$phone = mysql_result($result,0,2);

$address = mysql_result($result,0,3);

$desp = mysql_result($result,0,4);

 

$body_phone .= "신청자의 성명은".$name."이고, 주소는".$address."입니다.

        전화번호는 ".$phone."입니다.남기신글은 ";

 

if($desp == "") $body_phone .= "없습니다.";

else $body_phone .= $desp."입니다.";

 

$total_price = number_format($total_price);

 

$body .= "

</table><br>

<p align='right'><b>총합 : ".$total_price." 원</b>

</div>

<p align='center'>&nbsp;</p>

<p align='left'>배달 주소 확인

<div align='center'><table border width='500'  bordercolor=\"white\">

<tr>

<td align='center' width='120' bgcolor=\"#70FFB9\" bordercolor=\"green\">이 &nbsp;&nbsp;름</td>

<td width='380' bordercolor=\"green\"><p>&nbsp;".$name."</td>

</tr>

<tr>

<td align='center' width='120' bgcolor=\"#70FFB9\" bordercolor=\"green\">연락처(전화번호)</td>

<td width='380' bordercolor=\"green\"><p>&nbsp;".$phone."</td>

</tr>

<tr>

<td align='center' width='120' bgcolor=\"#70FFB9\" bordercolor=\"green\">배달 주소

</td>

<td width='380' bordercolor=\"green\"><p>&nbsp;".$address."</td>

</tr>

<tr>

<td align='center' width='120' height='23' bgcolor=\"#70FFB9\" bordercolor=\"green\">E-mail</td>

<td width='380' height='23' bordercolor=\"green\"><p>&nbsp;".$email."</td>

</tr>

<tr>

<td align='center' width='120' height='95' bgcolor=\"#70FFB9\" bordercolor=\"green\">전하는 말</td>

<td width='380' height='95' bordercolor=\"green\"><palign='left'>&nbsp;".$desp."</td>

</tr>

</table></div>

<p>&nbsp;</td>

</tr>

<tr>

<td width='600'><p align='center'><font face='굴림'></td>

</tr>

<tr>

<td width='600'><p><font face='굴림'><hr width='80%' with='80%'></td>

</tr>

<tr>

<td width='600'><p align='center'><font face='굴림' size='2'>Copyrightⓒ 2000

<a href='mailto:jklee@leelab.co.kr'><font face='굴림' size='2'><b>LeeLAB's 온라인 서점</b></a>

<font face='굴림' size='2'> All Rights Reserved.<br></td>

</tr>

</table></div>";            

 

$mailheaders .=  "Return-Path: $from\r\n";

$mailheaders .=  "From: $rn <$from>\r\n";

$mailheaders .=  "X-Mailer: Gfew Interface\r\n";

$mailheaders .=  "Content-Type: text/html; charset=euc-kr\r\n";

 

$bodytext  = stripslashes($body);

 

mail($to,$subject,$bodytext,$mailheaders);

?>

 

<html>

<head>

<title>온라인 주문 신청서</title>

</head>

 

<body bgcolor="white" text="black" link="blue" vlink="purple" alink="red">

<?

echo("$body");

?>

 

<p>&nbsp;</p>

<center>

<font size=2>

<a href="./main.html" >홈으로  돌아가기</a>

</center>

</body>

</html>

<?

if($user_uid) {

        $user_uid = null;

        $HTTP_SESSION_VARS["user_uid"] = null;

}

?>

 

 

 

[목차]

개인정보취급방침 서비스이용약관 모바일 버전으로 보기 상단으로

TEL. 063-469-4551 FAX. 063-469-4560 전북 군산시 대학로 558
군산대학교 컴퓨터정보공학과

Copyright © www.leelab.co.kr. All rights reserved.