<?php
ini_set("date.timezone","Asia/Bangkok");
//data base
$link = mysql_connect("127.0.0.1","root","") or die (mysql_error);
mysql_select_db("icecream",$link) or die (mysql_error());
mysql_query("SET NAMES UTF8");
?>
edit.php
<?php
session_start();
$ebits = ini_get('error_reporting');
error_reporting($ebits ^ E_NOTICE);
$user_id=$_SESSION['user_id'];
$username=$_SESSION['username'];
$firstnamee=$_SESSION['firstname'];
$role=$_SESSION['role'];
include("connect.php");
$ok=$_POST['edit'];
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
$email=$_POST['email'];
$pass=$_POST['pass'];
$con_pass=$_POST['con_pass'];
$gender=$_POST['gender'];
$area=$_POST['area'];
$province=$_POST['province'];
$postcode=$_POST['postcode'];
$tel=$_POST['tel'];
$date=$_POST['BD_date'];
$month=$_POST['BD_month'];
$year=$_POST['year'];
$dob=$year."-".$month."-".$date;
$sql="SELECT * FROM member WHERE user_id=$user_id";
$result=mysql_query($sql);
$row = mysql_fetch_array($result);
if(isset($ok)){
if($firstname!=$row['firstname'])
{
$up="UPDATE member SET firstname='$firstname' WHERE user_id=$user_id";
mysql_query($up);
}
if($lastname!=$row['lastname'])
{
$up="UPDATE member SET lastname='$lastname' WHERE user_id=$user_id";
mysql_query($up);
}
if($gender!=$row['gender'])
{
$up="UPDATE member SET gender='$gender' WHERE user_id=$user_id";
mysql_query($up);
}
if($email!=$row['e-mail'])
{
$up="UPDATE member SET e-mail='$email' WHERE user_id=$user_id";
mysql_query($up);
}
if($area!=$row['address'])
{
$up="UPDATE member SET address='$area' WHERE user_id=$user_id";
mysql_query($up);
}
if($province!=$row['province'])
{
$up="UPDATE member SET province='$province' WHERE user_id=$user_id";
mysql_query($up);
}
if($postcode!=$row['postcode'])
{
$up="UPDATE member SET postcode='$postcode' WHERE user_id=$user_id";
mysql_query($up);
}
if($tel!=$row['telephone'])
{
$up="UPDATE member SET telephone='$tel' WHERE user_id=$user_id";
mysql_query($up);
}
if($pass!=$row['password'] && $pass!="")
{ if($pass!=$con_pass){
echo"<script>
alert(\"Password and Confrim-password invalid\");
</script>";
}else{
$up="UPDATE member SET password='$pass' WHERE user_id=$user_id";
mysql_query($up);
}
}
if($dob!=$row['dob'])
{
$up="UPDATE member SET dob='$dob' WHERE user_id=$user_id";
mysql_query($up);
}
header("location:profile.php");
}
?>