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 > เรื่อง log out กับ การเพิ่มเพิ่มหมวดสินค้าและรูปแบบการแสดงผลครับ



 

เรื่อง log out กับ การเพิ่มเพิ่มหมวดสินค้าและรูปแบบการแสดงผลครับ

 



Topic : 105350



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



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




ติดอีกแล้วครับ หน้า log out
1.
คือ กด log out แล้ว มันไม่ไปหน้าแรกให้เราอ่ะครับ กลายเป็นหน้าเปล่าเลย
Code (PHP)
<?
session_start();
session_destroy();
echo "<script>alert('ขอบคุณเหล่า Admin ที่สนับสนุน shopping film ครับ'); location:'admin.php';</script>";
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>


------------------------------------------------------
2.
ในหน้าของ admin การเพิ่มหมวดสินค้าไปอ่ะครับ
แต่ขึ้น Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\project\admin\admin_country.php on line 34
เริ่มที่ว่าเมื่อเข้ามาในหน้านี้คือหน้าเพิ่มหมวดสินค้าอ่ะครับ
-------
ในหน้านี้มีแบบฟอร์ม ด้านล่างของฟอร์ม ก็จะแสดงหมวดที่มีอยู่ในปัจจุบันทั้งหมด แสดงในรูปแบบตาราง
---------------
การดำเนินงานในหน้านี้
จะมีฟอร์ม ที่ไว้ใส่ชื่อหมวดสินค้าที่อยากจะเพิ่มลงไปแล้ว กดที่ปุ่ม เิพิ่มข้อมูล จากนั้นระบบจะรันเพื่อทำการเพิ่มลงไปแล้วก็รันหน้าเดิม ก็จะโชว์หมวดสินค้าทั้งหมดในรูปแบบตารางครับ
----------------
Code (PHP)
<?
session_start();
if ($_SESSION["ad_card"]==null){
	echo "<script>alert('กรุณาทำการ Log in ครับ'); location='admin.php';</script> ";} ?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Admin_Home</title>
<link  href="style.css"  rel="stylesheet"  type="text/css" />
</head>    

<body>
<? include"../connectDB.inc"; include("setting.php") ?>
<div id="increase">
<form action="admin_add_product_type.php" method="post">
<table width="400" align="center" border="0">
<tr>
<td width="100"><font color="#FFFFFF">เพิ่มหมวดสินค้า</font></td>
<td><input type="text" name="product_type" size="30"></td>
</tr>
<tr>
<td width="150"></td>
<td><input name="Submit" type="submit" value="เพิ่มข้อมูล">
<input name="Reset" type="reset" value="ยกเลิก"></td>
</tr>
</table>
</form></div>
<div id="content">
<?
$no = 0;
$sql =mysql_query("select * from country");
$result = mysql_db_query($dbname,$sql);
$num = mysql_num_rows($result);
if($num>0){
$show = "<table width=600 cellpadding=4 align=center border>";
$show .= "<tr bgcolor=#00CCCC align=center><td>ลาดับ</td><td> ประเภทสินค้า </td><td> แก้ไข</td><td> ลบ</td></tr>";
while ($rs = mysql_fetch_array($sql)){
$show .= "<td align=center>$rs[country_code]</td>";
$show .= "<td> $rs[country_name] </td>";
$show .= "<td align=center><a href=admin_edit_country.php?id=$rs[country_code]>แก้ไข</a></td>";
$show .= "<td align=center><a href=admin_delete_country.php?id=$rs[country_code] onclick=\"return confirm('ยืนยันการลบข้อมูล?')\">ลบ</a></td>";
$show .= "</tr>";
}
$show .= "</table>";
echo $show;
}
mysql_close();
?> 
</div>


</body>
</html>




Tag : PHP, MySQL







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2014-02-02 15:56:37 By : sesepat View : 858 Reply : 13
 

 

No. 1



โพสกระทู้ ( 2,311 )
บทความ ( 1 )



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


Code (PHP)
<?
session_start();
session_destroy();
echo "<script>alert('ขอบคุณเหล่า Admin ที่สนับสนุน shopping film ครับ'); window.location:'admin.php';</script>";
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>







แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-02-02 16:13:04 By : arm8957
 


 

No. 2



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



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


ตอบความคิดเห็นที่ : 1 เขียนโดย : arm8957 เมื่อวันที่ 2014-02-02 16:13:04
รายละเอียดของการตอบ ::
ใส่เพิ่มตามไปแล้วครับ ผลออกมาคือ หน้าเปล่าเหมือนเดิมครับ

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-02-02 16:51:47 By : sesepat
 

 

No. 3



โพสกระทู้ ( 2,311 )
บทความ ( 1 )



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


อ่ะที่ผมใช้ คือเซ็คตัวแปร session ให้เป็นค่าว่าง หรือ NULL ดูเป็นแนวครับ ถ้ายังไม่ได้อีก ก็ตัวใครตัวมันครับ
Code (PHP)
<?php
ob_start();
session_start();
if(isset($_SESSION['sess_id']) || isset($_SESSION['mem_uname'])){
	$_SESSION['11111'] = NULL;
	$_SESSION['22222'] = NULL;
	$_SESSION['33333'] = NULL;
	$_SESSION['44444'] = NULL;
	session_destroy();
}
if(empty($_SESSION['1111'])){
	header('location:index.php');
	exit();
}
?>

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-02-02 21:19:10 By : arm8957
 


 

No. 4



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



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


ตอบข้อ 2 คับ

Code (PHP)
<?
session_start();
if ($_SESSION["ad_card"]==null){
	echo "<script>alert('กรุณาทำการ Log in ครับ'); location='admin.php';</script> ";} ?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Admin_Home</title>
<link  href="style.css"  rel="stylesheet"  type="text/css" />
</head>    

<body>
<? include"../connectDB.inc"; include("setting.php") ?>
<div id="increase">
<form action="admin_add_product_type.php" method="post">
<table width="400" align="center" border="0">
<tr>
<td width="100"><font color="#FFFFFF">เพิ่มหมวดสินค้า</font></td>
<td><input type="text" name="product_type" size="30"></td>
</tr>
<tr>
<td width="150"></td>
<td><input name="Submit" type="submit" value="เพิ่มข้อมูล">
<input name="Reset" type="reset" value="ยกเลิก"></td>
</tr>
</table>
</form></div>
<div id="content">
<?
$no = 0;
$sql = "select * from country";
$result = mysql_db_query($dbname,$sql);
$num = mysql_num_rows($result);
if($num>0){
$show = "<table width=600 cellpadding=4 align=center border>";
$show .= "<tr bgcolor=#00CCCC align=center><td>ลาดับ</td><td> ประเภทสินค้า </td><td> แก้ไข</td><td> ลบ</td></tr>";
while ($rs = mysql_fetch_array($sql)){
$show .= "<td align=center>$rs[country_code]</td>";
$show .= "<td> $rs[country_name] </td>";
$show .= "<td align=center><a href=admin_edit_country.php?id=$rs[country_code]>แก้ไข</a></td>";
$show .= "<td align=center><a href=admin_delete_country.php?id=$rs[country_code] onclick=\"return confirm('ยืนยันการลบข้อมูล?')\">ลบ</a></td>";
$show .= "</tr>";
}
$show .= "</table>";
echo $show;
}
mysql_close();
?> 
</div>


</body>
</html>


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-02-03 02:01:10 By : tomrambo
 


 

No. 5



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



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


ตอบความคิดเห็นที่ : 4 เขียนโดย : tomrambo เมื่อวันที่ 2014-02-03 02:01:10
รายละเอียดของการตอบ ::
แบบฟอร์มขึ้นครับ แต่ตารางไม่ขึ้นครับ แต่บอกว่าผิดบรรทัดที่ $num = mysql_num_rows($result);
แต่พอใส่ or die(mysql_error()) แล้ว ขึ้น No database selected

ฐานข้อมูล


ประวัติการแก้ไข
2014-02-03 02:56:04
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-02-03 02:42:59 By : sesepat
 


 

No. 6



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



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


แสดงว่าไม่ได้ประกาศชื่อ Database ไว้ในตัวแปร $dbname

Code
$dbname = "ชื่อ Database"; //ใส่ชื่อ Database คับ ไม่ใช่ชื่อตารางนะคับ


แล้วเอาโค้ดไปใส่ในไฟล์ setting.php คับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-02-03 11:06:44 By : tomrambo
 


 

No. 7



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



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


ตอบความคิดเห็นที่ : 6 เขียนโดย : tomrambo เมื่อวันที่ 2014-02-03 11:06:44
รายละเอียดของการตอบ ::
ใส่แล้วครับ บอกว่าผิดที่
Code (PHP)
while ($rs = mysql_fetch_array($sql)){

หัวตารางขึ้นน่ะครับ แต่ฐานข้อมูลไม่มาครับ

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-02-03 12:54:02 By : sesepat
 


 

No. 8



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

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

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


echo "<script>alert('ขอบคุณเหล่า Admin ที่สนับสนุน shopping film ครับ'); location:'admin.php';</script>";

echo "<script>alert('ขอบคุณเหล่า Admin ที่สนับสนุน shopping film ครับ'); location='admin.php';</script>";


ประวัติการแก้ไข
2014-02-03 13:07:28
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-02-03 13:07:32 By : sakuraei
 


 

No. 9



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



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


ตอบความคิดเห็นที่ : 8 เขียนโดย : sakuraei เมื่อวันที่ 2014-02-03 13:07:32
รายละเอียดของการตอบ ::
ขอบคุณมากครับ ข้อ 1 ผ่านแล้วครับ เหลือข้อ 2 ครับผม

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-02-03 14:26:00 By : sesepat
 


 

No. 10



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

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

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


32.$sql =mysql_query("select * from country");
33.$result = mysql_db_query($dbname,$sql) or die(mysql_error());
34.$num = mysql_num_rows($result);


38.while ($rs = mysql_fetch_array($result)){
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-02-03 15:06:46 By : sakuraei
 


 

No. 11



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



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


คราวนี้น่าจะโอเคแล้วคับ

Code (PHP)
<?
session_start();
if ($_SESSION["ad_card"]==null){
	echo "<script>alert('กรุณาทำการ Log in ครับ'); location='admin.php';</script> ";} ?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Admin_Home</title>
<link  href="style.css"  rel="stylesheet"  type="text/css" />
</head>    

<body>
<? include"../connectDB.inc"; include("setting.php") ?>
<div id="increase">
<form action="admin_add_product_type.php" method="post">
<table width="400" align="center" border="0">
<tr>
<td width="100"><font color="#FFFFFF">เพิ่มหมวดสินค้า</font></td>
<td><input type="text" name="product_type" size="30"></td>
</tr>
<tr>
<td width="150"></td>
<td><input name="Submit" type="submit" value="เพิ่มข้อมูล">
<input name="Reset" type="reset" value="ยกเลิก"></td>
</tr>
</table>
</form></div>
<div id="content">
<?
$no = 0;
$sql = "select * from country";
$result = mysql_db_query($dbname,$sql);
$num = mysql_num_rows($result);
if($num>0){
$show = "<table width=600 cellpadding=4 align=center border>";
$show .= "<tr bgcolor=#00CCCC align=center><td>ลาดับ</td><td> ประเภทสินค้า </td><td> แก้ไข</td><td> ลบ</td></tr>";
while ($rs = mysql_fetch_array($result)){
$show .= "<td align=center>$rs[country_code]</td>";
$show .= "<td> $rs[country_name] </td>";
$show .= "<td align=center><a href=admin_edit_country.php?id=$rs[country_code]>แก้ไข</a></td>";
$show .= "<td align=center><a href=admin_delete_country.php?id=$rs[country_code] onclick=\"return confirm('ยืนยันการลบข้อมูล?')\">ลบ</a></td>";
$show .= "</tr>";
}
$show .= "</table>";
echo $show;
}
mysql_close();
?> 
</div>


</body>
</html>


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-02-03 18:57:47 By : tomrambo
 


 

No. 12



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



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


ตอบความคิดเห็นที่ : 10 เขียนโดย : sakuraei เมื่อวันที่ 2014-02-03 15:06:46
รายละเอียดของการตอบ ::
ขอบคุณมากครับ

ตอบความคิดเห็นที่ : 11 เขียนโดย : tomrambo เมื่อวันที่ 2014-02-03 18:57:47
รายละเอียดของการตอบ ::
ขอบคุณมากครับ


ได้แล้วครับ ขอบคุณทั้งสองท่านมากครับ ถ้ามีอีก จะทั้งกระทู้ใหม่ถามอีกน่ะครับ ขอบคุณจริง จริง
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-02-03 23:37:17 By : sesepat
 


 

No. 13



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



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


อันนี้จะเป็นการเพิ่มหมวดลงไปอ่ะครับ

คือ ว่าผมเขียนโค้ดตัวนี้เพื่อที่จะทำการเพิ่มหมวดสินค้าไปยังฐานข้อมูลแต่ว่าลองเพิ่มแต่กลับ error ลองใส่คำว่า "หนังอินเดีย" ก็ขึ้น
ไม่สามารถเพิ่มหมวดสินค้าได้
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'values ('','หนังอินเดีย')' at line 1

โค้ดตัวนี้เป็นโค้ดที่เชื่อมต่อกับโค้ด ข้อ2 ที่แก้ได้แล้วครับ
Code (PHP)
<?
session_start();
if ($_SESSION["ad_card"]==null){
echo "<script>alert('กรุณาทำการ Log in ครับ'); location='admin.php';</script> ";} ?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Admin_Home</title>
<link  href="style.css"  rel="stylesheet"  type="text/css" />
</head>   
 
<body>

<? include"../connectDB.inc"; include("setting.php") ?>
<div id="increase">
<form action="admin_add_country.php" method="post">
<table width="400" align="center" border="0">
<tr>
<td width="100" ><font color="#FFFFFF"><b>เพิ่มหมวดสินค้า</b></font></td>
<td><input type="text" name="country" size="30"></td>
</tr>
<tr>
<td width="150"></td>
<td><input name="Submit" type="submit" value="เพิ่มข้อมูล">
<input name="Reset" type="reset" value="ยกเลิก"></td>
</tr>
</table>
</form></div>

<div id="content">
<?
$no = 0;
$sql = "select * from country";
$result = mysql_db_query($dbname,$sql) or die(mysql_error());
$num = mysql_num_rows($result);
if($num>0){
$show = "<table width=500 cellpadding=4 align=center border bgcolor='#FFFFFF'>";
$show .= "<tr bgcolor=#00CCCC align=center><td>ลำดับ</td><td> ประเภทสินค้า </td><td> แก้ไข</td><td> ลบ</td></tr>";
while ($rs = mysql_fetch_array($result)){
$show .= "<td align=center>$rs[country_code]</td>";
$show .= "<td> $rs[country_name] </td>";
$show .= "<td align=center><a href=admin_edit_country.php?id=$rs[country_code]>แก้ไข</a></td>";
$show .= "<td align=center><a href=admin_delete_country.php?id=$rs[country_code] onclick=\"return confirm('ยืนยันการลบข้อมูล?')\">ลบ</a></td>";
$show .= "</tr>";
}
$show .= "</table>";
echo $show; }
mysql_close();
?>
</div>
</body></html>


add_country
Code (PHP)
<?
session_start();
if ($_SESSION["ad_card"]==null){
echo "<script>alert('กรุณาทำการ Log in ครับ'); location='admin.php';</script> ";} ?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<? include"../connectDB.inc"; include("setting.php") ?>
<?
$pname = $_POST["country"];
$sql = "insert into country (country_code, country_name values ('','$pname')";
mysql_query($sql, $conn)
or die ("ไม่สามารถเพิ่มหมวดสินค้าได้<br>" .mysql_error());
mysql_close($conn);
echo "<meta http-equiv='refresh' content='0;
url=admin_country.php'>";
?>
</body>
</html>



ประวัติการแก้ไข
2014-02-04 00:20:08
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-02-04 00:18:01 By : sesepat
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : เรื่อง log out กับ การเพิ่มเพิ่มหมวดสินค้าและรูปแบบการแสดงผลครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ 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 04
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 อัตราราคา คลิกที่นี่