Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > ทำไม javascript โปรแกรมไม่แจ้งข้อความว่าไม่ได้ใส่ข้อมูลครับ



 

ทำไม javascript โปรแกรมไม่แจ้งข้อความว่าไม่ได้ใส่ข้อมูลครับ

 



Topic : 023130

Guest




คือผมใสภาษาจาวาสคลิ๊บ ถ้าไม่มีการใส่ username และ password จะมี box แจ้งว่าไม่ได้ใส่ username ถ้าไม่ใส่ password ก็จะแจ้งว่าไม่ได้ใส่ password ครับแต่รันโปรแกรม ไม่ได้แจ้งอะไรเลย ข้ามได้เฉยๆไปหน้า member.php แล้วไม่มีอะไรเกิดขึ้นหน้าว่างๆ

left_menu.php

<html>
<head>
<script Language="JavaScript">
var timerID = null;
var timerRunning = false;
function stopclock ()
{
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
}
function showtime ()
{
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds()
var timeValue = "" + ((hours >12) ? hours -12 :hours)
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += ((seconds < 10) ? ":0" : ":") + seconds
timeValue += (hours >= 12) ? " P.M." : " A.M."
window.status = timeValue;
timerID = setTimeout("showtime()",1000);
timerRunning = true;
}
function startclock ()
{
stopclock();
showtime();
}
</script>
<SCRIPT language=JavaScript>
<!--
function trim(str)
{
while (str.charAt(0) == ' ')
str = str.substring(1);
while (str.charAt(str.length - 1) == ' ')
str = str.substring(0, str.length - 1);
return str;
}
//-->

<!--
function chkValue()
{
txt = trim(document.regis.username.value)
if(txt.length < 2 ) {
alert("&iexcl;&Atilde;&Oslash;&sup3;&Ograve;&atilde;&Ecirc;&egrave; &ordf;&times;&egrave;&Iacute;-&sup1;&Ograve;&Aacute;&Ecirc;&iexcl;&Oslash;&Aring; &curren;&egrave;&ETH;");
document.regis.username.focus();
return false;
}

txt = trim(document.regis.password.value)
if(txt.length < 2) {
alert("&iexcl;&Atilde;&Oslash;&sup3;&Ograve;&atilde;&Ecirc;&egrave; &ordf;&times;&egrave;&Iacute;-&sup1;&Ograve;&Aacute;&Ecirc;&iexcl;&Oslash;&Aring; &curren;&egrave;&ETH;");
document.regis.password.focus();
return false;
}
}

return true;
}
//-->

</SCRIPT>
</head>
<body>



<form name="regis" action="../chapter19/member.php" method="post" onSubmit="return chkValue()" >
<table width="200" height="890" border=0 align="center" bgcolor="#6699CC" valign="top">
<tr>
<td width="194" height="20" align="center"><font face = "MS Sans Serif" color="#000000" size="2"><b>&nbsp;&ordf;&times;&egrave;&Iacute;&frac14;&Ugrave;&eacute;&atilde;&ordf;&eacute;</b></font></td>
</tr>
<tr><td height="26" align="center"><input name="username" id="name" type="text" maxlength="20" size="15"></td>
</tr>
<tr>
<td height="20" align="center"><font face = "MS Sans Serif" color="#000000" size="2"><b>&nbsp;&Atilde;&Euml;&Ntilde;&Ecirc;&frac14;&egrave;&Ograve;&sup1;</b></font></td>
</tr>
<tr><td height="26" align="center"><input name="password" type="password" maxlength="20" size="15"></td>
</tr>
<tr><td height="28" colspan="2" align="center">
<input name="submit" type="submit" id="submit" value="&Aring;&ccedil;&Iacute;&iexcl;&Iacute;&Ocirc;&sup1;">
</tr>
<tr><td height="44" colspan="2" align="left"><font face = "MS Sans Serif" color="#ffffff" size="2"><br>
<img src="../images/ico_m.gif" border="0">&nbsp;<b>&Acirc;&Ntilde;&sect;&auml;&Aacute;&egrave;&auml;&acute;&eacute;&agrave;&raquo;&ccedil;&sup1;&Ecirc;&Aacute;&Ograve;&ordf;&Ocirc;&iexcl; ? &curren;&Aring;&Ocirc;&ecirc;&iexcl;&middot;&Otilde;&egrave;&sup1;&Otilde;&egrave; </b></font></td></tr>
<tr><td height="18" colspan="2" align="left"><font face = "MS Sans Serif" color="#000000" size="2"><img src="../images/bullet1.gif" border="0">&nbsp;<a class ="lmenu" href = "../chapter19/forgetpassword_form.php"> <b>&Aring;&times;&Aacute;&Atilde;&Euml;&Ntilde;&Ecirc;&frac14;&egrave;&Ograve;&sup1;</b></a></font></td>
</tr><br>
<tr><td height="20" colspan="2" align="left"><font face = "MS Sans Serif" color="#000000" size="2"><img src="../images/bullet1.gif" border="0">&nbsp;<a class ="lmenu" href ="../chapter19/register_form.php"> <b>&Aring;&sect;&middot;&ETH;&agrave;&ordm;&Otilde;&Acirc;&sup1;</b></a></font></td>
</tr>
<tr>
<td height="20" colspan="2" align="left"><font face = "MS Sans Serif" color="#000000" size="2"><b><img src="../images/bullet1.gif" border="0">&nbsp;<a class ="lmenu" href="../chapter24/mailing.php">&Atilde;&Ntilde;&ordm;&cent;&egrave;&Ograve;&Ccedil;&Ecirc;&Ograve;&Atilde;&cent;&Iacute;&sect;&ordm;&Atilde;&Ocirc;&Eacute;&Ntilde;&middot;</a></b></font></td>
<tr><td height="26" align="center">----------------------------------------------</td>
</tr>
<tr><td height="55"><img src =../images/bn_applyjob.gif></td>
</tr>
<tr><td height="55"><img src =../images/bn_chulapress.jpg></td>
</tr>
<tr><td height="55"><img src =../images/bn_form.jpg></td>
</tr>
<tr><td height="55"><img src =../images/bn_library.jpg></td>
</tr>
<tr><td height="26">&nbsp;</td>
</tr>
<tr><td height="26">&nbsp;</td>
</tr>
<tr><td height="26">&nbsp;</td>
</tr>
<tr><td height="26">&nbsp;</td>
</tr>
<tr><td height="26">&nbsp;</td>
</tr>
<tr><td height="26">&nbsp;</td>
</tr>
<tr><td height="26">&nbsp;</td>
</tr>
<tr><td height="26">&nbsp;</td>
</tr>
<tr><td height="26">&nbsp;</td>
</tr>
<tr><td height="26">&nbsp;</td>
</tr>
<tr><td height="26">&nbsp;</td>
</tr>
<tr><td height="26">&nbsp;</td>
</tr>
<tr><td height="26">&nbsp;</td>
</tr>
<tr><td height="26">&nbsp;</td>
</tr>

</table>
</form>
</body>
</html>



member.php

<?
session_start();
require_once("../include/connect_db.php");
require_once("../include/function.php");
require_once("../include/header.php");
if($username && $password)
{
if(login($username,$password,'ktpbook','users'))
{
$valid_user = $username;
session_register("valid_user");
}
else
{
header_html("&agrave;&iexcl;&Ocirc;&acute;&cent;&eacute;&Iacute;&frac14;&Ocirc;&acute;&frac34;&Aring;&Ograve;&acute;");
echo "<tr><td><center><font face = \"MS Sans Serif\" color=\"#000000\" size=\"3\">&curren;&Oslash;&sup3;&auml;&Aacute;&egrave;&Ecirc;&Ograve;&Aacute;&Ograve;&Atilde;&para;&middot;&Otilde;&egrave;&uml;&ETH;&Aring;&ccedil;&Iacute;&iexcl;&Iacute;&Ocirc;&sup1;&auml;&acute;&eacute; &iexcl;&Atilde;&Oslash;&sup3;&Ograve;&micro;&Atilde;&Ccedil;&uml;&Ecirc;&Iacute;&ordm;&Iacute;&Otilde;&iexcl;&curren;&Atilde;&Ntilde;&eacute;&sect;</font></center></td></tr>";
require_once("../include/footer.php");
exit;
}
require_once("../chapter19/home.php");
}
?>



funtion.php
<?
//================================================================================
function login($username,$password,$databasename,$tablename)
/*&micro;&Atilde;&Ccedil;&uml;&Ecirc;&Iacute;&ordm; username &iexcl;&Ntilde;&ordm; password &iexcl;&Ntilde;&ordm;&deg;&Ograve;&sup1;&cent;&eacute;&Iacute;&Aacute;&Ugrave;&Aring;
&para;&eacute;&Ograve;&frac34;&ordm;&atilde;&Euml;&eacute;&curren;&times;&sup1;&curren;&egrave;&Ograve;&agrave;&raquo;&ccedil;&sup1;&uml;&Atilde;&Ocirc;&sect; &Euml;&Ograve;&iexcl;&auml;&Aacute;&egrave;&frac34;&ordm;&atilde;&Euml;&eacute;&curren;&times;&sup1;&curren;&egrave;&Ograve;&agrave;&raquo;&ccedil;&sup1;&agrave;&middot;&ccedil;&uml;
*/
{
//&agrave;&ordf;&times;&egrave;&Iacute;&Aacute;&acirc;&Acirc;&sect;&deg;&Ograve;&sup1;&cent;&eacute;&Iacute;&Aacute;&Ugrave;&Aring;
$conn = connect_db($databasename);
if(!$conn)
return 0;
//&micro;&Atilde;&Ccedil;&uml;&Ecirc;&Iacute;&ordm; username &Ccedil;&egrave;&Ograve;&laquo;&eacute;&Oacute;&iexcl;&Ntilde;&ordm;&atilde;&sup1;&deg;&Ograve;&sup1;&cent;&eacute;&Iacute;&Aacute;&Ugrave;&Aring;&Euml;&Atilde;&times;&Iacute;&auml;&Aacute;&egrave;
$sql = "select * from $tablename where username='$username' and password=password('$password')";
$result = mysql_query($sql);
if(!$result)
return 0;
if(mysql_num_rows($result)>0)
return 1;
else
return 0;
}

//================================================================================

function select_cat($key)
{
$conn=connect_db("ktpbook");
if(!$conn)
echo "&agrave;&iexcl;&Ocirc;&acute;&curren;&Ccedil;&Ograve;&Aacute;&frac14;&Ocirc;&acute;&frac34;&Aring;&Ograve;&acute;&auml;&Aacute;&egrave;&Ecirc;&Ograve;&Aacute;&Ograve;&Atilde;&para;&micro;&Ocirc;&acute;&micro;&egrave;&Iacute;&iexcl;&Ntilde;&ordm;&deg;&Ograve;&sup1;&cent;&eacute;&Iacute;&Aacute;&Ugrave;&Aring;&auml;&acute;&eacute;";
$sql="select * from categories where catid='$key' ";
$result = mysql_query($sql);
if(!$result)
return 0;
else
return $result;
}

function select_book($isbn)
{
$conn=connect_db("ktpbook");
if(!$conn)
echo "&agrave;&iexcl;&Ocirc;&acute;&curren;&Ccedil;&Ograve;&Aacute;&frac14;&Ocirc;&acute;&frac34;&Aring;&Ograve;&acute;&auml;&Aacute;&egrave;&Ecirc;&Ograve;&Aacute;&Ograve;&Atilde;&para;&micro;&Ocirc;&acute;&micro;&egrave;&Iacute;&iexcl;&Ntilde;&ordm;&deg;&Ograve;&sup1;&cent;&eacute;&Iacute;&Aacute;&Ugrave;&Aring;&auml;&acute;&eacute;";
$sql="select * from books where isbn='$isbn' ";
$result = mysql_query($sql);
if(!$result)
return 0;
else
return $result;
}

//=================================================================================
/*&iquest;&Ntilde;&sect;&iexcl;&igrave;&ordf;&Ntilde;&sup1;&agrave;&frac34;&Ocirc;&egrave;&Aacute;&Atilde;&Ograve;&Acirc;&iexcl;&Ograve;&Atilde;&Euml;&sup1;&Ntilde;&sect;&Ecirc;&times;&Iacute;*/
function insert_book($isbn,$author,$title,$price,$description,$picture,$publisher,$time,$page,$catid)
{
$con=connect_db("ktpbook");
if(!$con)
{
return "&auml;&Aacute;&egrave;&Ecirc;&Ograve;&Aacute;&Ograve;&Atilde;&para;&micro;&Ocirc;&acute;&micro;&egrave;&Iacute;&iexcl;&Ntilde;&ordm;&deg;&Ograve;&sup1;&cent;&eacute;&Iacute;&Aacute;&Ugrave;&Aring;&auml;&acute;&eacute; &iexcl;&Atilde;&Oslash;&sup3;&Ograve;&frac34;&Acirc;&Ograve;&Acirc;&Ograve;&Aacute;&Iacute;&Otilde;&iexcl;&curren;&Atilde;&Ntilde;&eacute;&sect;";
exit;
}
$sql = "select * from books where isbn='$isbn'";
$result = mysql_query($sql);
if(!$result)
return "&iexcl;&Atilde;&Oslash;&sup3;&Ograve;&micro;&Atilde;&Ccedil;&uml;&curren;&Ocirc;&Ccedil;&Atilde;&Otilde; &Iacute;&Otilde;&iexcl;&curren;&Atilde;&Ntilde;&eacute;&sect; <br>";
if(mysql_num_rows($result)>0)
return "&ordf;&times;&egrave;&Iacute;&cent;&Iacute;&sect;&frac14;&Ugrave;&eacute;&atilde;&ordf;&eacute;&laquo;&eacute;&Oacute;&iexcl;&Ntilde;&ordm;&atilde;&sup1;&deg;&Ograve;&sup1;&cent;&eacute;&Iacute;&Aacute;&Ugrave;&Aring; <br>";
$result = mysql_query("insert into books values ('$isbn','$author','$title',$price,'$description','$picture','$publisher','$time','$page',$catid)");
if(!$result)
return("&auml;&Aacute;&egrave;&Ecirc;&Ograve;&Aacute;&Ograve;&Atilde;&para;&agrave;&frac34;&Ocirc;&egrave;&Aacute;&Atilde;&Ograve;&Acirc;&iexcl;&Ograve;&Atilde;&Euml;&sup1;&Ntilde;&sect;&Ecirc;&times;&Iacute;&auml;&acute;&eacute;");
else
return true;
}

//=================================================================================

/*&iquest;&Ntilde;&sect;&iexcl;&igrave;&ordf;&Ntilde;&sup1;&Aring;&ordm;&Atilde;&Ograve;&Acirc;&iexcl;&Ograve;&Atilde;&Euml;&sup1;&Ntilde;&sect;&Ecirc;&times;&Iacute;*/
function delete_book($isbn)
{
$con=connect_db("ktpbook");
if(!$con)
return "&auml;&Aacute;&egrave;&Ecirc;&Ograve;&Aacute;&Ograve;&Atilde;&para;&micro;&Ocirc;&acute;&micro;&egrave;&Iacute;&iexcl;&Ntilde;&ordm;&deg;&Ograve;&sup1;&cent;&eacute;&Iacute;&Aacute;&Ugrave;&Aring;&auml;&acute;&eacute; &iexcl;&Atilde;&Oslash;&sup3;&Ograve;&frac34;&Acirc;&Ograve;&Acirc;&Ograve;&Aacute;&Iacute;&Otilde;&iexcl;&curren;&Atilde;&Ntilde;&eacute;&sect;";
$result = mysql_query("delete from books where isbn='$isbn'");
if(!$result)
return("&auml;&Aacute;&egrave;&Ecirc;&Ograve;&Aacute;&Ograve;&Atilde;&para;&Aring;&ordm;&Atilde;&Ograve;&Acirc;&iexcl;&Ograve;&Atilde;&Euml;&sup1;&Ntilde;&sect;&Ecirc;&times;&Iacute;&auml;&acute;&eacute;");
else
return true;
}

//=================================================================================

/*&iquest;&Ntilde;&sect;&iexcl;&igrave;&ordf;&Ntilde;&sup1;&iexcl;&Ograve;&Atilde;&aacute;&iexcl;&eacute;&auml;&cent;&Atilde;&Ograve;&Acirc;&Aring;&ETH;&agrave;&Iacute;&Otilde;&Acirc;&acute;&Euml;&sup1;&Ntilde;&sect;&Ecirc;&times;&Iacute;*/
function edit_book($oldisbn,$isbn,$author,$title,$price,$description,$picture,$publisher,$time,$page,$catid)
{
$con=connect_db("ktpbook");

if(!$con)
return "&auml;&Aacute;&egrave;&Ecirc;&Ograve;&Aacute;&Ograve;&Atilde;&para;&micro;&Ocirc;&acute;&micro;&egrave;&Iacute;&iexcl;&Ntilde;&ordm;&deg;&Ograve;&sup1;&cent;&eacute;&Iacute;&Aacute;&Ugrave;&Aring;&auml;&acute;&eacute; &iexcl;&Atilde;&Oslash;&sup3;&Ograve;&frac34;&Acirc;&Ograve;&Acirc;&Ograve;&Aacute;&Iacute;&Otilde;&iexcl;&curren;&Atilde;&Ntilde;&eacute;&sect;";
$sql="update books set isbn='$isbn' ,author='$author',title='$title' ,price=$price , description = '$description' , picture='$picture' , publisher='$publisher' ,time='$time' , page=$page , catid = $catid where isbn='$oldisbn' ";
$result = mysql_query($sql);
if(!$result)
return("&auml;&Aacute;&egrave;&Ecirc;&Ograve;&Aacute;&Ograve;&Atilde;&para;&agrave;&frac34;&Ocirc;&egrave;&Aacute;&Atilde;&Ograve;&Acirc;&iexcl;&Ograve;&Atilde;&Euml;&sup1;&Ntilde;&sect;&Ecirc;&times;&Iacute;&auml;&acute;&eacute;");
else
return true;
}

//=================================================================================

function insert_cat($catname)
{
$con=connect_db("ktpbook");
if(!$con)
{
return "&auml;&Aacute;&egrave;&Ecirc;&Ograve;&Aacute;&Ograve;&Atilde;&para;&micro;&Ocirc;&acute;&micro;&egrave;&Iacute;&iexcl;&Ntilde;&ordm;&deg;&Ograve;&sup1;&cent;&eacute;&Iacute;&Aacute;&Ugrave;&Aring;&auml;&acute;&eacute; &iexcl;&Atilde;&Oslash;&sup3;&Ograve;&frac34;&Acirc;&Ograve;&Acirc;&Ograve;&Aacute;&Iacute;&Otilde;&iexcl;&curren;&Atilde;&Ntilde;&eacute;&sect;";
exit;
}
$result = mysql_query("insert into categories(catname) values ('$catname')");
if(!$result)
return("&auml;&Aacute;&egrave;&Ecirc;&Ograve;&Aacute;&Ograve;&Atilde;&para;&agrave;&frac34;&Ocirc;&egrave;&Aacute;&Atilde;&Ograve;&Acirc;&iexcl;&Ograve;&Atilde;&Euml;&Aacute;&Ccedil;&acute;&Euml;&Aacute;&Ugrave;&egrave;&auml;&acute;&eacute;");
else
return true;
}

//=================================================================================

//&aacute;&iexcl;&eacute;&auml;&cent;&Euml;&Aacute;&Ccedil;&acute;&Euml;&Aacute;&Ugrave;&egrave;&Euml;&sup1;&Ntilde;&sect;&Ecirc;&times;&Iacute;
function edit_cat($catid,$catname)
{
$con=connect_db("ktpbook");

if(!$con)
return "&auml;&Aacute;&egrave;&Ecirc;&Ograve;&Aacute;&Ograve;&Atilde;&para;&micro;&Ocirc;&acute;&micro;&egrave;&Iacute;&iexcl;&Ntilde;&ordm;&deg;&Ograve;&sup1;&cent;&eacute;&Iacute;&Aacute;&Ugrave;&Aring;&auml;&acute;&eacute; &iexcl;&Atilde;&Oslash;&sup3;&Ograve;&frac34;&Acirc;&Ograve;&Acirc;&Ograve;&Aacute;&Iacute;&Otilde;&iexcl;&curren;&Atilde;&Ntilde;&eacute;&sect;";
$sql="update categories set catname='$catname' where catid = $catid ";
$result = mysql_query($sql);
if(!$result)
return("&auml;&Aacute;&egrave;&Ecirc;&Ograve;&Aacute;&Ograve;&Atilde;&para;&agrave;&frac34;&Ocirc;&egrave;&Aacute;&Atilde;&Ograve;&Acirc;&iexcl;&Ograve;&Atilde;&Euml;&sup1;&Ntilde;&sect;&Ecirc;&times;&Iacute;&auml;&acute;&eacute;");
else
return true;
}

//=================================================================================

function delete_cat($catid)
{
$con=connect_db("ktpbook");
if(!$con)
return "&auml;&Aacute;&egrave;&Ecirc;&Ograve;&Aacute;&Ograve;&Atilde;&para;&micro;&Ocirc;&acute;&micro;&egrave;&Iacute;&iexcl;&Ntilde;&ordm;&deg;&Ograve;&sup1;&cent;&eacute;&Iacute;&Aacute;&Ugrave;&Aring;&auml;&acute;&eacute; &iexcl;&Atilde;&Oslash;&sup3;&Ograve;&frac34;&Acirc;&Ograve;&Acirc;&Ograve;&Aacute;&Iacute;&Otilde;&iexcl;&curren;&Atilde;&Ntilde;&eacute;&sect;";
$result = mysql_query("delete from categories where catid='$catid'");
if(!$result)
return("&auml;&Aacute;&egrave;&Ecirc;&Ograve;&Aacute;&Ograve;&Atilde;&para;&Aring;&ordm;&Atilde;&Ograve;&Acirc;&iexcl;&Ograve;&Atilde;&Euml;&Aacute;&Ccedil;&acute;&Euml;&Aacute;&Ugrave;&egrave;&auml;&acute;&eacute;");
else
return true;
}

//=================================================================================

/*&iquest;&Ntilde;&sect;&iexcl;&igrave;&ordf;&Ntilde;&sup1;&Ecirc;&Oacute;&Euml;&Atilde;&Ntilde;&ordm;&sup1;&Oacute;&cent;&eacute;&Iacute;&Aacute;&Ugrave;&Aring;&atilde;&sup1;&deg;&Ograve;&sup1;&cent;&eacute;&Iacute;&Aacute;&Ugrave;&Aring;&agrave;&iexcl;&ccedil;&ordm;&auml;&Ccedil;&eacute;&atilde;&sup1;&Iacute;&ETH;&agrave;&Atilde;&Acirc;&igrave;*/
function db_to_array($result)
{
$result_array=array();
for($count=0;$row=@mysql_fetch_array($result);$count++)
$result_array[$count]=$row;
return $result_array;
}

//=================================================================================

/*&iquest;&Ntilde;&sect;&iexcl;&igrave;&ordf;&Ntilde;&sup1;&curren;&Oacute;&sup1;&Ccedil;&sup1;&Atilde;&Ograve;&curren;&Ograve;&iexcl;&Ograve;&Atilde;&Ecirc;&Ntilde;&egrave;&sect;&laquo;&times;&eacute;&Iacute;*/
function calculate_price($cart)
{
$price = 0.0;
if(is_array($cart))
{
$conn = connect_db("ktpbook");
foreach($cart as $isbn => $qty)
{
$query = "select price from books where isbn='$isbn'";
$result = mysql_query($query);
if ($result)
{
$item_price = mysql_result($result, 0, "price");
$price +=$item_price*$qty;
}
}
}
return $price;
}

//=================================================================================

/*&iquest;&Ntilde;&sect;&iexcl;&igrave;&ordf;&Ntilde;&sup1;&curren;&Oacute;&sup1;&Ccedil;&sup3;&Atilde;&Ograve;&Acirc;&iexcl;&Ograve;&Atilde;&Ecirc;&Ntilde;&egrave;&sect;&laquo;&times;&eacute;&Iacute;*/
function calculate_items($cart)
{
// &frac14;&Aring;&Atilde;&Ccedil;&Aacute;&cent;&Iacute;&sect;&Atilde;&Ograve;&Acirc;&iexcl;&Ograve;&Atilde;&Ecirc;&Ntilde;&egrave;&sect;&laquo;&Ouml;&eacute;&Iacute;
$items = 0;
if(is_array($cart))
{
foreach($cart as $isbn => $qty)
{
$items += $qty;
}
}
return $items;
}

//=================================================================================

//&aacute;&Ecirc;&acute;&sect;&Atilde;&Ograve;&Acirc;&iexcl;&Ograve;&Atilde;&Ecirc;&Ocirc;&sup1;&curren;&eacute;&Ograve;&middot;&Otilde;&egrave;&agrave;&Aring;&times;&Iacute;&iexcl;&laquo;&times;&eacute;&Iacute;
function display_cart($cart,$change)
{
global $items;
global $total_price;
echo "<table border = 0 width = 100% cellspacing = 0 align=center>
<form action = ../chapter20/show_cart.php method = post>
<tr bgcolor=FFBBBB>
<th><font face=MS Sans Serif size=3>&ordf;&times;&egrave;&Iacute;&Euml;&sup1;&Ntilde;&sect;&Ecirc;&times;&Iacute;</font></th>
<th><font face=MS Sans Serif size=3>&ordf;&times;&egrave;&Iacute;&frac14;&Ugrave;&eacute;&aacute;&micro;&egrave;&sect;</font></th>
<th><font face=MS Sans Serif size=3>&Atilde;&Ograve;&curren;&Ograve;</font></th>
<th><font face=MS Sans Serif size=3>&uml;&Oacute;&sup1;&Ccedil;&sup1;</font></th>
<th><font face=MS Sans Serif size=3>&Atilde;&Ograve;&curren;&Ograve;&Atilde;&Ccedil;&Aacute;</font></th>
</tr>";
foreach ($cart as $isbn => $qty)
{
$book = get_book_details($isbn);
echo "<tr>";
echo "<td>";
echo "<a href = \"../chapter20/detailbook.php?isbn=".$isbn."\"><font face=\"MS Sans Serif\" size=2>".$book["title"]."</font></a></td>" ;
echo "<td><font face=\"MS Sans serif\" size=2>".$book["author"]."</font></td>";
echo "<td align = center><font face=\"MS Sans Serif\" size=2>".number_format($book["price"], 2) ."</font></td>";
echo "<td align = center>";
if ($change == true)
echo "<input type = text name = \"$isbn\" value = $qty size = 2>";
else
echo "<font face=\"MS Sans serif\" size=2>".$qty."</font>";
echo "</td><td align = right><font face=\"MS Sans Serif\" size=2>" .number_format($book["price"]*$qty,2). " &ordm;&Ograve;&middot;</font></td></tr>\n";
}
// &aacute;&Ecirc;&acute;&sect;&frac14;&Aring;&Atilde;&Ccedil;&Aacute;&cent;&Iacute;&sect;&Atilde;&Ograve;&curren;&Ograve;
echo "<tr bgcolor=#FFAAAA>
<th align = left colspan=3>&frac14;&Aring;&Atilde;&Ccedil;&Aacute;&Atilde;&Ograve;&curren;&Ograve;&Ecirc;&Ocirc;&sup1;&curren;&eacute;&Ograve;&middot;&Ntilde;&eacute;&sect;&Euml;&Aacute;&acute;</th>
<th align = center>$items</th>
<th align = right>".number_format($total_price, 2)." &ordm;&Ograve;&middot;</th></tr>";
if($change == true)
{
echo "<tr>
<td colspan =4>&nbsp;</td>
<td align = center>
<input type = hidden name = new value =0 >
<input type = hidden name = save value = true>
<input type = submit value = \"&ordm;&Ntilde;&sup1;&middot;&Ouml;&iexcl;&iexcl;&Ograve;&Atilde;&agrave;&raquo;&Aring;&Otilde;&egrave;&Acirc;&sup1;&aacute;&raquo;&Aring;&sect;\">
</td>
<td>&nbsp;</td>
</tr>";
}
echo "</form></table>";
}

//=================================================================================

function checkout_form()
{
//&aacute;&Ecirc;&acute;&sect;&Atilde;&Ugrave;&raquo;&aacute;&ordm;&ordm;&Ecirc;&Oacute;&Euml;&Atilde;&Ntilde;&ordm;&raquo;&eacute;&Iacute;&sup1;&Atilde;&Ograve;&Acirc;&Aring;&ETH;&agrave;&Iacute;&Otilde;&Acirc;&acute;&Aring;&Ugrave;&iexcl;&curren;&eacute;&Ograve;
?>
<br>
<table border = "0" width = "100%" cellspacing = "0" bgcolor="#FFEEEE" align="center">
<form action = "../chapter20/purchase.php" method = "post">
<tr><th colspan = "2" bgcolor="#FFBBBB">&Atilde;&Ograve;&Acirc;&Aring;&ETH;&agrave;&Iacute;&Otilde;&Acirc;&acute;&cent;&Iacute;&sect;&Aring;&Ugrave;&iexcl;&curren;&eacute;&Ograve;</th></tr>
<tr>
<th align="left"><font face="Ms sans serif" size="3" style="margin: 2cm">&ordf;&times;&egrave;&Iacute;</font></th>
<td><input type = "text" name = "name" value = "" maxlength = "40" size = "30"></td>
</tr>
<tr>
<th align="left"><font face="Ms sans serif" size="3" style="margin: 2cm">&sup1;&Ograve;&Aacute;&Ecirc;&iexcl;&Oslash;&Aring;</font></th>
<td><input type = "text" name = "surname" value = "" maxlength = "20" size = "30"></td>
</tr>

<tr>
<th align="left"><font face="Ms sans serif" size="3" style="margin: 2cm">&agrave;&ordm;&Iacute;&Atilde;&igrave;&acirc;&middot;&Atilde;&Egrave;&Ntilde;&frac34;&middot;&igrave; </font></th>
<td><input type = "text" name = "phone" value = "" maxlength = "20" size = 20></td>
</tr>

<tr>
<th align="left"><font face="Ms sans serif" size="3" style="margin: 2cm">&middot;&Otilde;&egrave;&Iacute;&Acirc;&Ugrave;&egrave; </font></th>
<td><input type = "text" name = "address" value = "" maxlength = "100" size = "40"></td>
</tr>
<tr>
<th align="left"><font face="Ms sans serif" size="3" style="margin: 2cm">&Iacute;&Oacute;&agrave;&Agrave;&Iacute;/&agrave;&cent;&micro;</font></th>
<td><input type = "text" name = "district" value = "" maxlength = "20" size = "20"></td>
</tr>
<tr>
<th align="left"><font face="Ms sans serif" size="3" style="margin: 2cm">&uml;&Ntilde;&sect;&Euml;&Ccedil;&Ntilde;&acute;</font></th>
<td><input type = "text" name = "province" value = "" maxlength = "20" size = "20"></td>
</tr>
<tr>
<th align="left"><font face="Ms sans serif" size="3" style="margin: 2cm">&Atilde;&Euml;&Ntilde;&Ecirc;&auml;&raquo;&Atilde;&Eacute;&sup3;&Otilde;&Acirc;&igrave;</font></th>
<td><input type = "text" name = "zip" value = "" maxlength = "10" size = "10"></td>
</tr>
<tr>
<th align="left"><font face="Ms sans serif" size="3" style="margin: 2cm">&raquo;&Atilde;&ETH;&agrave;&middot;&Egrave;</font></th>
<td><input type = text name = "country" value = "" maxlength = "20" size = "20"></td>
</tr>
<tr>
<td colspan = "2" align = "center">
<font face="Ms Sans serif" size="2"><b>&Euml;&Ograve;&iexcl;&micro;&Atilde;&Ccedil;&uml;&Ecirc;&Iacute;&ordm;&cent;&eacute;&Iacute;&Aacute;&Ugrave;&Aring;&agrave;&Atilde;&Otilde;&Acirc;&ordm;&Atilde;&eacute;&Iacute;&Acirc;&aacute;&Aring;&eacute;&Ccedil;&atilde;&Euml;&eacute;&curren;&Aring;&Ocirc;&iexcl;&middot;&Otilde;&egrave;&raquo;&Oslash;&egrave;&Aacute; &Ecirc;&Ocirc;&eacute;&sup1;&Ecirc;&Oslash;&acute;&iexcl;&Ograve;&Atilde;&laquo;&times;&eacute;&Iacute; &agrave;&frac34;&times;&egrave;&Iacute;&laquo;&times;&eacute;&Iacute;&Ecirc;&Ocirc;&sup1;&curren;&eacute;&Ograve; &Euml;&Atilde;&times;&Iacute;&curren;&Aring;&Ocirc;&iexcl;&middot;&Otilde;&egrave;&raquo;&Oslash;&egrave;&Aacute; &agrave;&Aring;&times;&Iacute;&iexcl;&Ecirc;&Ocirc;&sup1;&curren;&eacute;&Ograve;&micro;&egrave;&Iacute; &agrave;&frac34;&times;&egrave;&Iacute;&agrave;&Aring;&times;&Iacute;&iexcl;&laquo;&times;&eacute;&Iacute;&Euml;&Atilde;&times;&Iacute;&aacute;&iexcl;&eacute;&auml;&cent;&Atilde;&Ograve;&Acirc;&iexcl;&Ograve;&Atilde;&Ecirc;&Ntilde;&egrave;&sect;&laquo;&times;&eacute;&Iacute;</b></font>
</td>
</tr>
<tr>
<td align="center"><input type="submit" value="&Ecirc;&Ocirc;&eacute;&sup1;&Ecirc;&Oslash;&acute;&iexcl;&Ograve;&Atilde;&laquo;&times;&eacute;&Iacute;"></td>
</form>
<td align="center"><form action="../chapter19/home.php" method="post"><input type="submit" value="&agrave;&Aring;&times;&Iacute;&iexcl;&Ecirc;&Ocirc;&sup1;&curren;&eacute;&Ograve;&micro;&egrave;&Iacute;"></form></td>
</tr>
</table>
<?
}

//=================================================================================

function display_shipping($shipping)
{
// &aacute;&Ecirc;&acute;&sect;&Atilde;&Ograve;&curren;&Ograve;&Atilde;&Ccedil;&Aacute;&curren;&egrave;&Ograve;&cent;&sup1;&Ecirc;&egrave;&sect;
global $total_price;
global $items;
?>
<table border = 0 width = "100%" cellspacing = "0" align="center">
<tr><td align = left><font face="MS Sans Serif" size=3>&curren;&egrave;&Ograve;&uml;&Ntilde;&acute;&Ecirc;&egrave;&sect;</font></td>
<td align = right><font face="MS Sans Serif" size=3><?=number_format($shipping, 2); ?> &ordm;&Ograve;&middot;</font></td></tr>
<tr bgcolor="#FF7777"><th align = "left"><font face=MS Sans Serif size=3>&Atilde;&Ccedil;&Aacute;&Atilde;&Ograve;&curren;&Ograve;&middot;&Ntilde;&eacute;&sect;&Euml;&Aacute;&acute;</font></th>
<th align = "right"><font face=MS Sans Serif size=3><?=number_format($shipping+$total_price, 2); ?> &ordm;&Ograve;&middot;</font></th>
</tr>
</table><br>
<?
}

//=============================================================================

function card_form($name)
{
//&uml;&Iacute;&Agrave;&Ograve;&frac34;&Ecirc;&Oacute;&Euml;&Atilde;&Ntilde;&ordm;&raquo;&eacute;&Iacute;&sup1;&Atilde;&Ograve;&Acirc;&Aring;&ETH;&agrave;&Iacute;&Otilde;&Acirc;&acute;&cent;&Iacute;&sect;&agrave;&curren;&Atilde;&acute;&Ocirc;&micro;&iexcl;&Ograve;&Atilde;&igrave;&acute; &aacute;&Ecirc;&acute;&sect;&Ccedil;&Ocirc;&cedil;&Otilde;&iexcl;&Ograve;&Atilde;&ordf;&Oacute;&Atilde;&ETH;&agrave;&sect;&Ocirc;&sup1;&frac14;&egrave;&Ograve;&sup1;&middot;&Ograve;&sect;&ordm;&Ntilde;&micro;&Atilde; &agrave;&Iacute;&middot;&Otilde;&agrave;&Iacute;&ccedil;&Aacute;
extract($name);
?>
<form id="form1" name="form1" method="post" action="../chapter20/process.php">
<table width="704" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#FF3300" bgcolor="#FFFFCC">
<tr>
<td width="700"><table width="629" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><span class="style1">&Ccedil;&Ocirc;&cedil;&Otilde;&iexcl;&Ograve;&Atilde;&ordf;&Oacute;&Atilde;&ETH;&agrave;&sect;&Ocirc;&sup1;</span></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>&ordf;&Oacute;&Atilde;&ETH;&agrave;&sect;&Ocirc;&sup1;&agrave;&cent;&eacute;&Ograve;&ordm;&Ntilde;&shy;&ordf;&Otilde; (&iexcl;&Atilde;&Oslash;&sup3;&Ograve;&agrave;&Aring;&times;&Iacute;&iexcl;&ordm;&Ntilde;&shy;&ordf;&Otilde;&atilde;&Euml;&eacute;&para;&Ugrave;&iexcl;&micro;&eacute;&Iacute;&sect;) <span class="style3">** </span></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><label>
<input name="radiobutton" type="radio" value="radiobutton" />
(360-2-14988-4) &cedil;&sup1;&Ograve;&curren;&Ograve;&Atilde; &auml;&middot;&Acirc;&frac34;&Ograve;&sup3;&Ocirc;&ordf;&Acirc;&igrave; (&Ecirc;&Ograve;&cent;&Ograve; &Acirc;&egrave;&Iacute;&Acirc;&iquest;&Ocirc;&Ccedil;&agrave;&uml;&Iacute;&Atilde;&igrave;&frac34;&Ograve;&Atilde;&igrave;&curren; &Atilde;&Ntilde;&sect;&Ecirc;&Ocirc;&micro;) </label></td>
</tr>
<tr>
<td><label>
<input name="radiobutton" type="radio" value="radiobutton" />
(148-1-34037-9) &cedil;&sup1;&Ograve;&curren;&Ograve;&Atilde; &iexcl;&Atilde;&Oslash;&sect;&auml;&middot;&Acirc; (&Ecirc;&Ograve;&cent;&Ograve; &Atilde;&Ntilde;&sect;&Ecirc;&Ocirc;&micro;-&sup1;&curren;&Atilde;&sup1;&Ograve;&Acirc;&iexcl; &curren;&Aring;&Iacute;&sect; 4)
</label></td>
</tr>
<tr>
<td><label>
<input name="radiobutton" type="radio" value="radiobutton" />
(026-0-37230-5) &cedil;&sup1;&Ograve;&curren;&Ograve;&Atilde; &iexcl;&Atilde;&Oslash;&sect;&agrave;&middot;&frac34; (&Ecirc;&Ograve;&cent;&Ograve; &Acirc;&egrave;&Iacute;&Acirc;&iquest;&Ocirc;&Ccedil;&agrave;&uml;&Iacute;&Atilde;&igrave;&frac34;&Ograve;&Atilde;&igrave;&curren; &Atilde;&Ntilde;&sect;&Ecirc;&Ocirc;&micro;)</label></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>&agrave;&Atilde;&Ograve;&atilde;&ordf;&eacute;&iexcl;&Ograve;&Atilde;&micro;&Atilde;&Ccedil;&uml;&Ecirc;&Iacute;&ordm;&agrave;&sect;&Ocirc;&sup1;&frac14;&egrave;&Ograve;&sup1;&Atilde;&ETH;&ordm;&ordm;&Iacute;&Ocirc;&sup1;&agrave;&micro;&Iacute;&Atilde;&igrave;&agrave;&sup1;&ccedil;&micro; &middot;&egrave;&Ograve;&sup1;&auml;&Aacute;&egrave;&Ecirc;&Ograve;&Aacute;&Ograve;&Atilde;&para;&aacute;&Iacute;&ordm;&Iacute;&eacute;&Ograve;&sect;&iexcl;&Ograve;&Atilde;&ordf;&Oacute;&Atilde;&ETH;&agrave;&sect;&Ocirc;&sup1;&middot;&Otilde;&egrave;&auml;&Aacute;&egrave;&agrave;&raquo;&ccedil;&sup1;&uml;&Atilde;&Ocirc;&sect;&auml;&acute;&eacute;&aacute;&micro;&egrave;&Iacute;&Acirc;&egrave;&Ograve;&sect;&atilde;&acute; </td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>&uml;&Oacute;&sup1;&Ccedil;&sup1;&agrave;&sect;&Ocirc;&sup1; <span class="style3">*</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; <label>
<input type="text" name="textfield" />
&nbsp; &ordm;&Ograve;&middot; </label></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>&ordf;&Oacute;&Atilde;&ETH;&agrave;&Aacute;&times;&egrave;&Iacute;&Ccedil;&Ntilde;&sup1;&middot;&Otilde;&egrave; <span class="style3">*&nbsp;</span>&nbsp;&nbsp; <label>
<input type="text" name="textfield2" />
&nbsp; (&agrave;&ordf;&egrave;&sup1; 12 &Aacute;&iexcl;&Atilde;&Ograve;&curren;&Aacute; 2551) </label></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>&agrave;&Aacute;&times;&egrave;&Iacute;&agrave;&Ccedil;&Aring;&Ograve; <span class="style3">*&nbsp;</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; <label>
<input type="text" name="textfield3" />
&nbsp;(&agrave;&ordf;&egrave;&sup1; 12.30 &sup1;. &raquo;&Atilde;&ETH;&Aacute;&Ograve;&sup3;&agrave;&Iacute;&Ograve;&curren;&Atilde;&Ntilde;&ordm;)</label></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>&Euml;&Aacute;&Ograve;&Acirc;&agrave;&Euml;&micro;&Oslash;&Iacute;&times;&egrave;&sup1; &aelig;&nbsp;&nbsp;&nbsp;&nbsp; <label>
<textarea name="textfield4" cols="40" rows="6"></textarea>
</label></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><div align="center">&curren;&Aring;&Ocirc;&ecirc;&iexcl;&middot;&Otilde;&egrave;&raquo;&Oslash;&egrave;&Aacute; <span class="style4">&Ecirc;&Ocirc;&eacute;&sup1;&Ecirc;&Oslash;&acute;&iexcl;&Ograve;&Atilde;&Ecirc;&Ntilde;&egrave;&sect;&laquo;&times;&eacute;&Iacute;</span> &agrave;&frac34;&times;&egrave;&Iacute;&Ecirc;&Ntilde;&egrave;&sect;&laquo;&times;&eacute;&Iacute;&Ecirc;&Ocirc;&sup1;&curren;&eacute;&Ograve; &Euml;&Atilde;&times;&Iacute;&curren;&Aring;&Ocirc;&ecirc;&iexcl;&raquo;&Oslash;&egrave;&Aacute; <span class="style6">&Ecirc;&Ntilde;&egrave;&sect;&laquo;&times;&eacute;&Iacute;&Ecirc;&Ocirc;&sup1;&curren;&eacute;&Ograve;&micro;&egrave;&Iacute;</span> &agrave;&frac34;&times;&egrave;&Iacute;&agrave;&Aring;&times;&Iacute;&iexcl;&laquo;&times;&eacute;&Iacute;&Ecirc;&Ocirc;&sup1;&curren;&eacute;&Ograve;&micro;&egrave;&Iacute; </div></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><div align="center">
<input type="submit" name="Submit" value="&Ecirc;&Ocirc;&eacute;&sup1;&Ecirc;&Oslash;&acute;&iexcl;&Ograve;&Atilde;&Ecirc;&Ntilde;&egrave;&sect;&laquo;&times;&eacute;&Iacute;" />
</div></td>
</tr>
<tr>
<td><label></label></td>
</tr>
<form id="form1" name="form1" method="post" action="../chapter20/process.php">
<tr>
<td><label>
<div align="center">
<input type="submit" name="Submit2" value="&Ecirc;&Ntilde;&egrave;&sect;&laquo;&times;&eacute;&Iacute;&Ecirc;&Ocirc;&sup1;&curren;&eacute;&Ograve;&micro;&egrave;&Iacute;." />
</div>
</label></td>
</tr></form>
<tr>
<td>&nbsp;</td>
</tr>
</table></td>
</tr>
</table>




<?
}

//=============================================================================

//&iquest;&Ntilde;&sect;&iexcl;&igrave;&ordf;&Ntilde;&sup1;&Ecirc;&Oacute;&Euml;&Atilde;&Ntilde;&ordm;&agrave;&frac34;&Ocirc;&egrave;&Aacute;&Atilde;&Ograve;&Acirc;&iexcl;&Ograve;&Atilde;&Ecirc;&Ntilde;&egrave;&sect;&laquo;&times;&eacute;&Iacute;
function insert_order($order_details)
{
global $total_price;
global $cart;
extract($order_details);
//&atilde;&sup1;&iexcl;&Atilde;&sup3;&Otilde;&middot;&Otilde;&egrave;&Atilde;&Ograve;&Acirc;&Aring;&ETH;&agrave;&Iacute;&Otilde;&Acirc;&acute;&cent;&Iacute;&sect;&frac14;&Ugrave;&eacute;&Ecirc;&egrave;&sect;&iexcl;&Ntilde;&ordm;&frac14;&Ugrave;&eacute;&laquo;&times;&eacute;&Iacute;&agrave;&Euml;&Aacute;&times;&Iacute;&sup1;&iexcl;&Ntilde;&sup1;
if(!$ship_name&&!$ship_surname&&!$ship_address&&!$ship_phone&&!$ship_district&&!$ship_province&&!$ship_zip&&!$ship_country)
{
$ship_name = $name;
$ship_surname = $surname;
$ship_address = $address;
$ship_phone =$phone;
$ship_district = $district;
$ship_province = $province;
$ship_zip = $zip;
$ship_country = $country;
}
$conn = connect_db("order_book");
//&micro;&Atilde;&Ccedil;&uml;&Ecirc;&Iacute;&ordm;&Atilde;&Ograve;&Acirc;&Aring;&ETH;&agrave;&Iacute;&Otilde;&Acirc;&acute;&cent;&Iacute;&sect;&Aring;&Ugrave;&iexcl;&curren;&eacute;&Ograve;
$sql = "select customerid from customer where name = '$name' and surname = '$surname' and address = '$address' and district = '$district' and province = '$province' and zip = '$zip' and country = '$country' and phone='$phone' ";
$result = mysql_query($sql);
if(!$result)
return "&iexcl;&Atilde;&Oslash;&sup3;&Ograve;&micro;&Atilde;&Ccedil;&uml;&curren;&Ocirc;&Ccedil;&Atilde;&Otilde; &Iacute;&Otilde;&iexcl;&curren;&Atilde;&Ntilde;&eacute;&sect; <br>";
if(mysql_num_rows($result)>0)
{
$customer_id = mysql_result($result, 0, "customerid");
}
else
{

$sql = "insert into customer(name,surname,address,district,province,zip,country,phone) values ( '$name','$surname','$address','$district','$province','$zip','$country','$phone')";
$result = mysql_query($sql);
if (!$result)
return false;
}
$sql = "select customerid from customer where name = '$name' and surname = '$surname' and address = '$address' and district = '$district' and province = '$province' and zip = '$zip' and country = '$country' and phone='$phone'";
$result = mysql_query($sql);
if(!$result)
return "&iexcl;&Atilde;&Oslash;&sup3;&Ograve;&micro;&Atilde;&Ccedil;&uml;&curren;&Ocirc;&Ccedil;&Atilde;&Otilde; &Iacute;&Otilde;&iexcl;&curren;&Atilde;&Ntilde;&eacute;&sect; <br>";
if(mysql_num_rows($result)>0)
$customerid = mysql_result($result, 0, "customerid");
else
return false;
$date = date("Y-m-d");
$sql = "insert into orders values
('', $customerid, $total_price, '$date', '$ship_name','$ship_surname',
'$ship_address','$ship_district','$ship_province','$ship_zip',
'$ship_country','$ship_phone')";
$result = mysql_query($sql);
if (!$result)
return false;

$sql = "select orderid from orders where customerid = $customerid and amount > $total_price-.001 and amount < $total_price+.001 and date = '$date' and ship_name = '$ship_name' and ship_surname = '$ship_surname' and ship_address = '$ship_address' and ship_district = '$ship_district' and ship_province = '$ship_province' and ship_zip = '$ship_zip' and ship_country = '$ship_country' and ship_phone ='$ship_phone'";
$result = mysql_query($sql);
if(mysql_num_rows($result)>0)
$orderid = mysql_result($result, 0, "orderid");
else
return false;
// &raquo;&eacute;&Iacute;&sup1;&Atilde;&Ograve;&Acirc;&Aring;&ETH;&agrave;&Iacute;&Otilde;&Acirc;&acute;&cent;&Iacute;&sect;&Euml;&sup1;&Ntilde;&sect;&Ecirc;&times;&Iacute;&aacute;&micro;&egrave;&Aring;&ETH;&agrave;&Aring;&egrave;&Aacute;
foreach ($cart as $isbn => $qty)
{
$book = get_book_details($isbn);
$price = $book["price"];
$conn = connect_db("order_book");
$sql="insert into order_items values ($orderid,'$isbn',$price,$qty)";
$result = mysql_query($sql);
if(!$result)
return false;
}
return $orderid;
}

//=============================================================================

function get_book_details($isbn)
{
if (!$isbn || $isbn=="")
return false;
$con=connect_db("ktpbook");
$query = "select * from books where isbn='$isbn'";
$result = mysql_query($query);
if (!$result)
return false;
$result = mysql_fetch_array($result);
return $result;
}

//=================================================================================

function process_card($detailcart)
{
extract($detailcart); if($card_name&&$card_type&&$card_number&&$card_code&&$card_month&&$card_year)
return true;
else
return false;
}

function ship_cost()
{
return 50;
}

//=================================================================================

function register($username,$password,$answer,$email)
{
$con=connect_db("ktpbook");
if(!$con)
return "&auml;&Aacute;&egrave;&Ecirc;&Ograve;&Aacute;&Ograve;&Atilde;&para;&micro;&Ocirc;&acute;&micro;&egrave;&Iacute;&iexcl;&Ntilde;&ordm;&deg;&Ograve;&sup1;&cent;&eacute;&Iacute;&Aacute;&Ugrave;&Aring;&auml;&acute;&eacute; &iexcl;&Atilde;&Oslash;&sup3;&Ograve;&frac34;&Acirc;&Ograve;&Acirc;&Ograve;&Aacute;&Iacute;&Otilde;&iexcl;&curren;&Atilde;&Ntilde;&eacute;&sect;";
$sql = "select * from users where username='$username'";
$result = mysql_query($sql);
if(!$result)
return "&iexcl;&Atilde;&Oslash;&sup3;&Ograve;&micro;&Atilde;&Ccedil;&uml;&curren;&Ocirc;&Ccedil;&Atilde;&Otilde; &Iacute;&Otilde;&iexcl;&curren;&Atilde;&Ntilde;&eacute;&sect; <br>";
if(mysql_num_rows($result)>0)
return "&ordf;&times;&egrave;&Iacute;&cent;&Iacute;&sect;&frac14;&Ugrave;&eacute;&atilde;&ordf;&eacute;&laquo;&eacute;&Oacute;&iexcl;&Ntilde;&ordm;&atilde;&sup1;&deg;&Ograve;&sup1;&cent;&eacute;&Iacute;&Aacute;&Ugrave;&Aring; <br>";
$result = mysql_query("insert into users values ('$username',password('$password'),'$answer','$email')");
if(!$result)
return("&auml;&Aacute;&egrave;&Ecirc;&Ograve;&Aacute;&Ograve;&Atilde;&para;&Aring;&sect;&middot;&ETH;&agrave;&ordm;&Otilde;&Acirc;&sup1;&auml;&acute;&eacute;");
else
return true;
}

//=============================================================================
function


Tag : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 22 พ.ย. 2551 15:40:47 By : badboy2 View : 878 Reply : 1
 

 

No. 1



โพสกระทู้ ( 3,468 )
บทความ ( 0 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter

ทำไม txt ไม่ประกาศตัวแปลล่ะครับ






Date : 22 พ.ย. 2551 20:28:57 By : เอี่ยว
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ทำไม javascript โปรแกรมไม่แจ้งข้อความว่าไม่ได้ใส่ข้อมูลครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 01
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่