|
|
|
สอบถามเรื่อง JQuery กดปุ่มแล้วไม่โหลดเมนูครับ [Theme Bootstrap] |
|
|
|
|
|
|
|
สอบถามครับ พอดีผมสร้างทำเมนูแก้ไข
แต่เมื่อกด Edit ข้อมูลไป ระบบนิ่งอะครับ
ผมทำอะไรผิดพลาดรึเปล่าครับ
ขอบคุณครับ
หน้า page_profile.php
Code (PHP)
<?PHP
$profile = select("tb_user u inner join tb_department d on u.dept_id = d.code "," where user_id='$_SESSION[user_id]'");
?>
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
<?=$m_name;?>
<small><?=$m_detail;?></small>
</h1>
<ol class="breadcrumb">
<li><a href="main.php?page=page_home&sp="><i class="fa fa-dashboard"></i> Home</a></li>
<li class="active"><?=$m_name;?></li>
</ol>
</section>
<!-- Container -->
<!-- Main content -->
<section class="content">
<div class="row">
<div class="col-md-3">
<!-- Profile Image -->
<div class="box box-primary">
<div class="box-body box-profile">
<img class="profile-user-img img-responsive img-circle" src="<?php if($profile['avartar'] <> ""){ echo "avartar/".$profile['avartar']; }else{ echo "avartar/person.png"; } ?>" alt="User profile picture">
<h3 class="profile-username text-center"><?=$profile['firstname']." ".$profile['lastname'];?></h3>
<p class="text-muted text-center"><?=$profile['u_position'];?></p>
<!--
<a href="javascript:void(0)" class="btn btn-primary btn-block" id="btnChange_profilephoto_info" >Change Photo</a>
<a href="ajaximage/index.php" class="btn btn-primary btn-block" id="btnChange_profilephoto_info" >Change</a>
<a id="edit<?=$i;?>" class="various iframe" href="editform.php?CusID=<?=$objResult["CustomerID"];?>">Edit</a>
-->
</div><!-- /.box-body -->
</div><!-- /.box -->
</div><!-- /.col -->
<div class="col-md-9">
<div class="nav-tabs-custom">
<ul class="nav nav-tabs">
<li class="active"><a href="#activity" data-toggle="tab">About me</a></li>
<li><a href="#settings" data-toggle="tab">Change Profile</a></li>
<li><a href="#photo" data-toggle="tab">Change Photo</a></li>
<li><a href="#password" data-toggle="tab">Change Password</a></li>
</ul>
<div class="tab-content">
<div class="active tab-pane" id="activity">
</div><!-- /.tab-pane -->
<div class="tab-pane" id="photo">
</div><!-- /.tab-pane -->
<div class="tab-pane" id="settings">
<form class="form-horizontal" action="" method="post" name="profile_info" id="profile_info">
<div class="form-group">
<label for="inputName" class="col-sm-2 control-label">First Name</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputFirstName" placeholder="ชื่อ" value="<?=$profile['firstname'];?>">
</div>
</div>
<div class="form-group">
<label for="inputLastname" class="col-sm-2 control-label">Last Name</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputLastname" placeholder="นามสกุล" value="<?=$profile['lastname'];?>">
</div>
</div>
<div class="form-group">
<label for="inputDepartment" class="col-sm-2 control-label">Department</label>
<div class="col-sm-10">
<select name="ddldept" id="ddldept" class="form-control select2" style="width: 100%;">
<?php
echo "<option value ='00' >-- Please Choose --</option>";
$sql_dept = "select * from tb_department where status = 'A' order by name ASC ";
$query_dept = $connect->query($sql_dept);
//$numrows_dept = $query_dept->num_rows;
while($result_dept = $query_dept->fetch_assoc())
{ if($result_dept[code] == $profile['dept_id']){ $sel_dept = "selected='selected'"; }else{ $sel_dept = ""; }
echo "<option value ='$result_dept[code]' $sel_dept >$result_dept[name]</option>";
}
?>
</select>
</div><!-- /.form-group -->
</div>
<div class="form-group">
<label for="inputPosition" class="col-sm-2 control-label">Position</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputPosition" placeholder="ตำแหน่งงาน" value="<?=$profile['u_position'];?>">
</div>
</div>
<div class="form-group">
<label for="inputPosition" class="col-sm-2 control-label">E-mail</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputEmail" placeholder="อีเมล์" value="<?=$profile['u_email'];?>">
</div>
</div>
<div class="form-group">
<label for="inputPosition" class="col-sm-2 control-label">Telephone</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputTelephone" data-inputmask='"mask": "(999) 999-9999"' data-mask value="<?=$profile['u_tel'];?>">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-danger" id="btnSubmit_profile_info">Edit Profile</button>
</div>
</div>
</form>
</div><!-- /.tab-pane -->
<div class="tab-pane" id="password">
<form class="form-horizontal">
<div class="form-group">
<label for="inputOld-pass" class="col-sm-2 control-label">Old password</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="inputOld-pass" placeholder="รหัสผ่านเดิม">
</div>
</div>
<div class="form-group">
<label for="inputNew-pass" class="col-sm-2 control-label">New password</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="inputNew-pass" placeholder="รหัสผ่านใหม่">
</div>
</div>
<div class="form-group">
<label for="inputCon-pass" class="col-sm-2 control-label">Comfirm password</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="inputCon-pass" placeholder="ยืนยันรหัสผ่านใหม่">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-danger">Submit</button>
</div>
</div>
</form>
</div><!-- /.tab-pane -->
</div><!-- /.tab-content -->
</div><!-- /.nav-tabs-custom -->
</div><!-- /.col -->
</div><!-- /.row -->
</section>
</div>
<script>
$(function () {
//Initialize Select2 Elements
$(".select2").select2();
});
$(function() {
$('button#btnSubmit_profile_info').click(function() {
if(!confirm('ยืนยันการแก้ไข')) {
return false;
}
$.post('action.php?op=save_profile',$('#profile_info').serialize(),function(data){
$("#resp").html(data);
});
});
});
</script>
หน้า action.php
Code (PHP)
<?PHP
error_reporting(E_ALL);
session_start();
include "include/config.php";
include "include/function.php";
$op = $_GET['op'];
if($op === 'signin'){
signIn();
}else if($op === 'save_profile'){
save_profile();
}
function save_profile(){
$user_id = $_SESSION['user_id'];
$firstname = $_POST['inputFirstName'];
$lastname = $_POST['inputLastname'];
$dept_id = $_POST['ddldept'];
$u_position = $_POST['inputPosition'];
$u_email = $_POST['inputEmail'];
$u_tel = $_POST['inputTelephone'];
update("tb_user","firstname='$firstname',lastname='$lastname',dept_id='$dept_id',u_email='$u_email',u_position='$u_position',u_tel='$u_tel'","where user_id='$user_id'");
$modal=Modal("portlet-success","success","ยินดีด้วย","บันทึกข้อมูลเรียบร้อยแล้วครับ");
echo "<script>
$(function(){
$('#portlet-success').modal();
});
setTimeout('parent.location.reload(true);',2000);
</script>";
}
หน้า main.php (รวม Script ที่โหลดทั้งหมด)
Code (PHP)
chk_login();
$url = $_GET['page'];
$surl = $_GET['sp'];
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title><?=$title;?></title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<link rel="icon" href="img/faviconview.ico" type="image/x-icon"/>
<link rel="shortcut icon" href="img/faviconview.ico" type="image/x-icon" />
<!-- Bootstrap 3.3.5 -->
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<!-- Font Awesome -->
<link rel="stylesheet" href="plugins/font-awesome/css/font-awesome.min.css">
<!-- Ionicons
<link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="dist/css/AdminLTE.min.css">
<!-- AdminLTE Skins. Choose a skin from the css/skins
folder instead of downloading all of them to reduce the load. -->
<link rel="stylesheet" href="dist/css/skins/_all-skins.min.css">
<!-- iCheck -->
<link rel="stylesheet" href="plugins/iCheck/flat/blue.css">
<!-- Morris chart -->
<link rel="stylesheet" href="plugins/morris/morris.css">
<!-- jvectormap -->
<link rel="stylesheet" href="plugins/jvectormap/jquery-jvectormap-1.2.2.css">
<!-- Date Picker -->
<link rel="stylesheet" href="plugins/datepicker/datepicker3.css">
<!-- Daterange picker -->
<link rel="stylesheet" href="plugins/daterangepicker/daterangepicker-bs3.css">
<!-- bootstrap wysihtml5 - text editor -->
<link rel="stylesheet" href="plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
<!-- DataTables -->
<link rel="stylesheet" href="plugins/datatables/dataTables.bootstrap.css">
<!-- Select2 -->
<link rel="stylesheet" href="plugins/select2/select2.min.css">
<link rel="stylesheet" type="text/css" href="plugins/fancybox/jquery.fancybox-1.3.4.css" media="screen" />
<script type="text/javascript" src="ajaximage/scripts/jquery.min.js"></script>
<script type="text/javascript" src="ajaximage/scripts/jquery.form.js"></script>
<script type="text/javascript" src="plugins/fancybox/jquery.mousewheel-3.0.4.pack.js"></script>
<script type="text/javascript" src="plugins/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
<!-- jQuery 2.1.4 -->
<script src="plugins/jQuery/jQuery-2.1.4.min.js"></script>
<!-- jQuery UI 1.11.4 -->
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
<!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
<script>
$.widget.bridge('uibutton', $.ui.button);
</script>
<!-- Bootstrap 3.3.5 -->
<script src="bootstrap/js/bootstrap.min.js"></script>
<!-- DataTables -->
<script src="plugins/datatables/jquery.dataTables.min.js"></script>
<script src="plugins/datatables/dataTables.bootstrap.min.js"></script>
<!-- Morris.js charts -->
<script src="plugins/raphael/raphael-min.js"></script>
<script src="plugins/morris/morris.min.js"></script>
<!-- Sparkline -->
<script src="plugins/sparkline/jquery.sparkline.min.js"></script>
<!-- jvectormap -->
<script src="plugins/jvectormap/jquery-jvectormap-1.2.2.min.js"></script>
<script src="plugins/jvectormap/jquery-jvectormap-world-mill-en.js"></script>
<!-- jQuery Knob Chart -->
<script src="plugins/knob/jquery.knob.js"></script>
<!-- daterangepicker -->
<script src="plugins/daterangepicker/moment.min.js"></script>
<script src="plugins/daterangepicker/daterangepicker.js"></script>
<!-- datepicker -->
<script src="plugins/datepicker/bootstrap-datepicker.js"></script>
<!-- Bootstrap WYSIHTML5 -->
<script src="plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>
<!-- Slimscroll -->
<script src="plugins/slimScroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src="plugins/fastclick/fastclick.min.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/app.min.js"></script>
<!-- AdminLTE dashboard demo (This is only for demo purposes) -->
<script src="dist/js/pages/dashboard.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="dist/js/demo.js"></script>
<!-- Select2 -->
<script src="plugins/select2/select2.full.min.js"></script>
</head>
<body class="hold-transition skin-blue fixed sidebar-mini">
<div class="wrapper">
<header class="main-header">
<!-- Logo -->
<a href="main.php?page=page_home&sp=" class="logo">
<!-- mini logo for sidebar mini 50x50 pixels -->
<span class="logo-mini"><b>S</b>MS</span>
<!-- logo for regular state and mobile devices -->
<span class="logo-lg"><b>Store</b>Mana.System</span>
</a>
<!-- Header Navbar: style can be found in header.less -->
<nav class="navbar navbar-static-top" role="navigation">
<!-- Sidebar toggle button-->
<a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button">
<span class="sr-only">Toggle navigation</span>
</a>
<div class="navbar-custom-menu">
<?php
include "include/menuheader.php";
?>
</div>
</nav>
</header>
<!-- Left side column. contains the logo and sidebar -->
<aside class="main-sidebar">
<!-- sidebar: style can be found in sidebar.less -->
<section class="sidebar">
<!-- START MENULIST -->
<div class="user-panel">
<!-- Sidebar user panel -->
<div class="pull-left image">
<img src="<?=$avartar;?>" class="img-circle" alt="User Image">
</div>
<div class="pull-left info">
<p><?=$_SESSION["firstname"];?></p>
<a href="#"><i class="fa fa-circle text-success"></i> Online</a>
</div>
</div>
<!-- sidebar menu: : style can be found in sidebar.less -->
<?php include "include/menulist.php"; ?>
<!-- END MENULIST -->
</section>
<!-- /.sidebar -->
</aside>
<?php
if($url == 'page_home'){
$m_name = "Dashboard";
$m_detail = "Control panel";
$show_page = 'page_home.php';
}else if($url == 'page_profile'){
$m_name = "Profile";
$m_detail = "ข้อมูลพนักงาน";
$show_page = 'page_profile.php';
}else{
$r_menu = select("dt_menuname","where code = '$surl' ORDER BY code ASC");
$m_name = $r_menu['nameen'];
$m_detail = $r_menu['detail'];
$show_page = $r_menu['url'];
if($show_page == '#'){
$show_page = 'page/404.php';
}
}
?>
<!-- Content Wrapper. Contains page content -->
<?php
include $show_page;
?>
<!-- /.content-wrapper -->
</body>
</html>
<?php
$connect->close();
?>
Tag : PHP, JavaScript, jQuery
|
ประวัติการแก้ไข 2016-02-01 16:58:54
|
|
|
|
|
Date :
2016-02-01 16:58:13 |
By :
ohmkubpom |
View :
1487 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
code หน้า action ใช้ ajax ทำกับข้อมูล
ถ้าจะเช็ค login ก็ควร ส่งค่ากลับมา ด้วยว่า redirect ไปไหน หรือ error ก็ว่าไป
แล้วก็ ไม่น่าจะไป alert ไปใน action.php นะ เรียกใช้ ajax post อยู่ไม่ใช่หรอ มันต่อง echo json ส่งค่ากลับมาหน้าหลักแล้วค่อยใช้ java alert ซิ
|
|
|
|
|
Date :
2016-02-01 22:30:34 |
By :
progamer2000 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|