<?php require_once('Connections/const.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
  session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
  $_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['username'])) {
  $loginUsername=$_POST['username'];
  $password=$_POST['password'];
  $MM_fldUserAuthorization = "";
  $MM_redirectLoginSuccess = "webpage/Page2/Loginok.php";
  $MM_redirectLoginFailed = "webpage/Page2/Loginfail.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_const, $const);
  
  $LoginRS__query=sprintf("SELECT username, password FROM sell WHERE username=%s AND password=%s",
    GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); 
   
  $LoginRS = mysql_query($LoginRS__query, $const) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
     $loginStrGroup = "";
    
	if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;	      

    if (isset($_SESSION['PrevUrl']) && false) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];	
    }
    header("Location: " . $MM_redirectLoginSuccess );
  }
  else {
    header("Location: ". $MM_redirectLoginFailed );
  }
}
?>
<html>
<head>
<title>หน้าร้าน</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
body {
	background-image: url(Pictures/moon-over-mistral-sky.jpg);
}
body,td,th {
	font-size: 14px;
}
</style>
<script type="text/javascript">
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
</script>
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="MM_preloadImages('in2/images/index_04.gif','in2/images/index_05.gif','in2/images/index_06.gif','in2/images/index_08.gif','in2/images/index_09.gif','in2/images/index_12.gif','in2/images/index_16.gif','in2/images/index_17.gif')">
<table width="767" height="1027" border="0" align="center" cellpadding="0" cellspacing="0" id="Table_01">
  <tr>
    <td colspan="11"><img src="images/index_01.gif" width="768" height="153" alt="" /></td>
  </tr>
  <tr>
    <td width="1"><img src="images/index_02.gif" width="1" height="142" alt="" /></td>
    <td colspan="10"><img src="images/index_03.gif" width="767" height="142" alt="" /></td>
  </tr>
  <tr>
    <td colspan="3"><a href="index.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image32','','in2/images/index_04.gif',1)"><img src="images/index_04.gif" width="140" height="52" id="Image32" /></a></td>
    <td colspan="3"><a href="webpage/Page3/order.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image33','','in2/images/index_05.gif',1)"><img src="images/index_05.gif" width="155" height="52" id="Image33" /></a></td>
    <td width="172"><a href="webpage/Page4/Delivery_price.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image34','','in2/images/index_06.gif',1)"><img src="images/index_06.gif" width="172" height="52" id="Image34" /></a></td>
    <td width="1"><img src="images/index_07.gif" width="1" height="52" alt="" /></td>
    <td width="121"><a href="webpage/Page5/Contact.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image35','','in2/images/index_08.gif',1)"><img src="images/index_08.gif" width="121" height="52" id="Image35" /></a></td>
    <td colspan="2"><a href="webpage/Page6/Payment.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image36','','in2/images/index_09.gif',1)"><img src="images/index_09.gif" width="179" height="52" id="Image36" /></a></td>
  </tr>
  <tr>
    <td colspan="11"><img src="images/index_10.gif" width="768" height="30" alt="" /></td>
  </tr>
  <tr>
    <td rowspan="5"><img src="images/index_11.gif" width="1" height="581" alt="" /></td>
    <td colspan="4"><a href="http://track.thailandpost.co.th/tracking/default.aspx" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image37','','in2/images/index_12.gif',1)"><img src="images/index_12.gif" width="254" height="49" id="Image37" /></a></td>
    <td colspan="5" rowspan="4" bgcolor="#FF99CC"><div align="center">
      <object id="FlashID" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="472" height="348">
        <param name="movie" value="Animation/Movie_index.swf" />
        <param name="quality" value="high" />
        <param name="wmode" value="opaque" />
        <param name="swfversion" value="8.0.35.0" />
        <!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you don’t want users to see the prompt. -->
        <param name="expressinstall" value="Scripts/expressInstall.swf" />
        <param name="BGCOLOR" value="#FF99CC" />
        <!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. -->
        <!--[if !IE]>-->
        <object type="application/x-shockwave-flash" data="Animation/Movie_index.swf" width="472" height="348">
          <!--<![endif]-->
          <param name="quality" value="high" />
          <param name="wmode" value="opaque" />
          <param name="swfversion" value="8.0.35.0" />
          <param name="expressinstall" value="Scripts/expressInstall.swf" />
          <param name="BGCOLOR" value="#FF99CC" />
          <!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. -->
          <div>
            <h4>Content on this page requires a newer version of Adobe Flash Player.</h4>
            <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33" /></a></p>
          </div>
          <!--[if !IE]>-->
        </object>
        <!--<![endif]-->
      </object>
    </div></td>
    <td width="21" rowspan="5"><img src="images/index_14.gif" width="21" height="583" alt="" /></td>
  </tr>
  <tr>
    <td width="3"><img src="images/index_15.gif" width="3" height="47" alt="" /></td>
    <td colspan="3"><a href="webpage/Page7/menu_prd.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image38','','in2/images/index_16.gif',1)"><img src="images/index_16.gif" width="251" height="47" id="Image38" /></a></td>
  </tr>
  <tr>
    <td colspan="4"><a href="index.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image39','','in2/images/index_17.gif',1)"><img src="images/index_17.gif" width="254" height="43" id="Image39" /></a></td>
  </tr>
  <tr>
    <td rowspan="2"><img src="images/index_18.gif" width="3" height="442" alt="" /></td>
    <td colspan="2" rowspan="2" bgcolor="#FFFF99"><form action="<?php echo $loginFormAction; ?>" method="POST" name="form1" id="form1">
      <p align="center"> Login</p>
      <p align="center">
        <label for="username2">username
          <input type="text" name="username" id="username2" />
        </label>
      <p align="center">
        <label for="password">password</label>
        <input type="text" name="password" id="password" />
      </p>
      <p align="center">
        <input type="submit" name="save" id="save" value="เข้าสู่ระบบ" />
        <input type="reset" name="Reset" id="button" value="ยกเลิก" />
        <a href="webpage/Page1/insert.php">สมัครสมาชิก</a></p>
    </form>      <div align="center">
        <embed src=http://i245.photobucket.com/albums/gg78/looma001/lalacal001.swf
 quality="high"  width="214" height="217" wmode="transparent"></embed>
    &nbsp;ปฏิทิน<br>
    จำนวนผู้เข้าชม<br/>
<script type="text/javascript" src="https://counter4.01counter.com/private/counter.js?c=703b01fbfd708a1e4cb0bd54fc0d0df1"></script>
<noscript><a href="http://www.freecounterstat.com" title="free web counter"><img src="https://counter4.01counter.com/private/freecounterstat.php?c=703b01fbfd708a1e4cb0bd54fc0d0df1" border="0" title="free web counter" alt="free web counter"></a>
</noscript>
       
    </div></td>
    <td width="16"><img src="images/index_20.gif" width="16" height="233" alt="" /></td>
  </tr>
  <tr>
    <td height="211" colspan="6" bgcolor="#CC99FF"><div align="center">
      <object id="FlashID2" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="508" height="210">
        <param name="movie" value="Animation/Movie_index2.swf" />
        <param name="quality" value="high" />
        <param name="wmode" value="opaque" />
        <param name="swfversion" value="8.0.35.0" />
        <!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you don’t want users to see the prompt. -->
        <param name="expressinstall" value="Scripts/expressInstall.swf" />
        <!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. -->
        <!--[if !IE]>-->
        <object type="application/x-shockwave-flash" data="Animation/Movie_index2.swf" width="508" height="210">
          <!--<![endif]-->
          <param name="quality" value="high" />
          <param name="wmode" value="opaque" />
          <param name="swfversion" value="8.0.35.0" />
          <param name="expressinstall" value="Scripts/expressInstall.swf" />
          <!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. -->
          <div>
            <h4>Content on this page requires a newer version of Adobe Flash Player.</h4>
            <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33" /></a></p>
            </div>
          <!--[if !IE]>-->
          </object>
        <!--<![endif]-->
        </object>
    </div></td>
  </tr>
  <tr>
    <td colspan="11"><img src="images/index_23.gif" width="768" height="66" alt="" /></td>
  </tr>
  <tr>
    <td><img src="images/spacer.gif" width="1" height="1" alt="" /></td>
    <td><img src="images/spacer.gif" width="3" height="1" alt="" /></td>
    <td width="136"><img src="images/spacer.gif" width="136" height="1" alt="" /></td>
    <td width="99"><img src="images/spacer.gif" width="99" height="1" alt="" /></td>
    <td><img src="images/spacer.gif" width="16" height="1" alt="" /></td>
    <td width="40"><img src="images/spacer.gif" width="40" height="1" alt="" /></td>
    <td><img src="images/spacer.gif" width="172" height="1" alt="" /></td>
    <td><img src="images/spacer.gif" width="1" height="1" alt="" /></td>
    <td><img src="images/spacer.gif" width="121" height="1" alt="" /></td>
    <td width="158"><img src="images/spacer.gif" width="158" height="1" alt="" /></td>
    <td><img src="images/spacer.gif" width="21" height="1" alt="" /></td>
  </tr>
</table>
</body>
</html>