|
|
|
สอบถามเกี่ยวกับ session เก็บชื่อ และข้อมูลอื่นๆ ที่ต้องการ เช่น จังหวัด เพือ่ที่เวลาที่มี user เข้าไปโพส เราสามารถดึงข้อมุลมาแสดงได้ ว่าสมาชิกนี้อยู่ที่จังหวัดอะไร.. |
|
|
|
|
|
|
|
Code (PHP)
<?php
session_start();
include("sv_site/conection2.php");
include("sv_site/function.php");
if(isset($_POST['txtUsername']) and isset($_POST['txtPassword'])){
$pass=trim($_POST['txtPassword']);
$sql = sprintf("SELECT * FROM TB_USERS WHERE USERNAME='$username'",
mysql_real_escape_string($_POST['txtUsername']));
$rs=mysql_db_query ( "ruamduay_db" ,$sql, $db );
if(!$row=mysql_fetch_array($rs))
{
echo "Username username ไม่ถูกต้อง กรุณาลองใหม่อีกครั้ง\n\r";
}elseif($row["PASSWORD"]==$pass)
{
// session_register ( "UID" );
// session_register ( "USERNAME" );
// session_register ( "Level" );
$_SESSION['UID']=$row["USER_ID"];
$_SESSION['USERNAME']=$row["USERNAME"];
$_SESSION['PROVINCE']=$row["PROVINCE"];//save จังหวัดของสมาชิกด้วย
$_SESSION['Level']=$row["LEVEL"];
redirect("MenuBackEnd.php");
}else{echo "Password Invalid\n\r";}
}else{echo "Username หรือ Password ไม่ถูกต้อง\n\r";
}
echo implode("" ,file("login.html"));
?>
<?
include("conection2.php");
include("function.php");
session_start();
if(!isset($_SESSION['USERNAME']) || $_SESSION['PASSWORD']==""){
header("Location:sv_site/q_artcles.php");
}
// ใส่ไว้ด้านบนของไฟล์สำหรับ เช็คว่าเป็น user หรือไม่
session_start();
CheckSession();
foreach($_POST as $key => $value) {
$value=mysql_real_escape_string($value);
//echo $key."/".$value."</br>";
}
//$return_to_page="../articles.php";
$return_to_page="../articles_list.php?";
if($_POST["METHOD"]=="remove_ban"){
if(unlink($_POST["IMAGE_REMOVE"])){ //DELETE IMG***********************************************************
update_pic("","BANNER",$_POST["txtARTICLES_ID"]);
}
echo "<form action='".$return_to_page."' method='post' name='frm'>";
echo '<input name="txtCATEGORY" type="hidden" id="txtCATEGORY" value="'.$_POST["txtCATEGORY"].'" />';
echo '<input name="edit_id" type="hidden" id="edit_id" value="'.$_POST["txtARTICLES_ID"].'" />';
echo "</form>";
}elseif($_POST["METHOD"]=="remove_img"){
if(unlink($_POST["IMAGE_REMOVE"])){ //DELETE IMG***********************************************************
update_pic("","IMAGE",$_POST["txtARTICLES_ID"]);
}
echo "<form action='".$return_to_page."' method='post' name='frm'>";
echo '<input name="txtCATEGORY" type="hidden" id="txtCATEGORY" value="'.$_POST["txtCATEGORY"].'" />';
echo '<input name="edit_id" type="hidden" id="edit_id" value="'.$_POST["txtARTICLES_ID"].'" />';
echo "</form>";
}elseif(trim($_POST["txtARTICLES_ID"])!=""){
$sql=" UPDATE tb_articles ";
$sql.=" SET TITLE = '".$_POST["txtTitle"]."',";
$sql.=" HILINGHT = '".$_POST["chkHilight"]."',";
$sql.=" `DESC` = '".$_POST["editor1"]."'";
$sql.=" WHERE ARTICLES_ID =".$_POST["txtARTICLES_ID"]." LIMIT 1 ;";
$rs = mysql_query($sql);
$sql="";
//Upload***********************************************************
//if($_FILES["ImageUpload"]["tmp_name"]!=""){
$Banner=GenName_Pic($_FILES["BannerUpload"],"BANNER",$_POST["txtARTICLES_ID"]);
if(copy($_FILES["BannerUpload"]["tmp_name"],$img_path.$Banner) )
{
update_pic($Banner,"BANNER",$_POST["txtARTICLES_ID"]);
}
//}
//if($_FILES["ImageUpload"]["tmp_name"]!=""){
$img=GenName_Pic($_FILES["ImageUpload"],"IMG",$_POST["txtARTICLES_ID"]);
if(copy($_FILES["ImageUpload"]["tmp_name"],$img_path.$img ))
{
update_pic($img,"IMAGE",$_POST["txtARTICLES_ID"]);
}
//}
//Upload***********************************************************
echo "<form action='".$return_to_page."' method='post' name='frm'>";
echo '<input name="txtCATEGORY" type="hidden" id="txtCATEGORY" value="'.$_POST["txtCATEGORY"].'" />';
echo '<input name="edit_id" type="hidden" id="edit_id" value="'.$_POST["txtARTICLES_ID"].'" />';
echo "</form>";
}elseif(trim($_POST["txtTitle"])!=""){
$sql="INSERT INTO tb_articles (";
$sql.=" ARTICLES_ID ,";
$sql.=" CATEGORY ,";
$sql.=" TITLE ,";
$sql.=" HILINGHT ,";
$sql.=" `DESC` ,";
$sql.=" `ACTIVE` ," ;
$sql.=" INACTIVE ,";
$sql.=" CREATE_DT";
//$sql.=" PROVINCE " ;
$sql.=" )VALUES(";
$sql.=" NULL ,";
$sql.=" '".$_POST["txtCATEGORY"]."',";
$sql.=" '".$_POST["txtTitle"]."',";
$sql.=" '".$_POST["chkHilight"]."',";
$sql.=" '".$_POST["editor1"]."',";
$sql.=" '1',";
$sql.=" NULL,";
$sql.=" now());";
//$sql.=" now(), ".$_SESSION['PROVINCE'].");";
$rs = mysql_query($sql);
$sql="";
$last_id = mysql_insert_id($db);
$Banner=GenName_Pic($_FILES["BannerUpload"],"BANNER",$last_id);
$img=GenName_Pic($_FILES["ImageUpload"],"IMG",$last_id);
//Upload***********************************************************
if(copy($_FILES["BannerUpload"]["tmp_name"],$img_path.$Banner) )
{
update_pic($Banner,"BANNER",$last_id);
}
if(copy($_FILES["ImageUpload"]["tmp_name"],$img_path.$img ))
{
update_pic($img,"IMAGE",$last_id);
}
//Upload***********************************************************
echo "<form action='".$return_to_page."' method='post' name='frm'>";
echo '<input name="txtCATEGORY" type="hidden" id="txtCATEGORY" value="'.$_POST["txtCATEGORY"].'" />';
echo '<input name="edit_id" type="hidden" id="edit_id" value="'.$last_id.'" />';
echo "</form>";
}
for($i=1;$i<10+1;$i++)
{
json_set_list_News($i);
json_set_list_Event($i);
}
json_set_list_ads();
json_set_list_ads_event();
json_set_list_ads_news();
$direc='<script language="JavaScript">document.frm.submit();</script>';
echo $direc;
?>
Tag : PHP
|
|
|
|
|
|
Date :
2015-02-08 00:05:00 |
By :
puwanet |
View :
1021 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตารางจังหวัดชื่ออะไรครับ ไป JOIN มาได้นี่ครับ
|
|
|
|
|
Date :
2015-02-08 07:48:05 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|