I have a form that I need to act in specific ways. Example: User brings equipment back: I don't want that to show up in my form. User takes equipment out: I want it to generate to my form, they enters some information, form sends information to database. User takes equipment out: it too generates said form, he doesn't enter any information, form submits information after 20 sec, information is in database.
I was doing a simple page refresh to get the information into my form but that was pulling all the equipment that had been brought into the warehouse that day. So I commented that out and then I would get stuck on my ajax page.
I then tried creating a new php page that had a 301 page refresh and that worked to get the page back to my index page, however, my form wasn't working properly and so I commented out the auto submit and now my form works great... except I can't fulfill this last requirement where the page will submit the data if the user forgets to put his equipment information in.
I'm looking to do an if/then/else type of page submission. However, I can't figure out how to do one purely in either php or html. This is what I have figured out so far but it doesn't work and I know I'm way off somewhere.
<!DOCTYPE html>
<html>
<body>
<!--This is the one that is currently commented out in my code
<script type="text/javascript">
window.setTimeout(function() {
window.location = 'index.php'},1000*2);
</script>
</body>
</html> -->
//This is my pipe dream
<?php
if (isset($_POST['action'])) {
switch ($_POST['action']) {
case ‘DONE’:
document.getElement('formSubmit').submit();
break;
}
} else {
<script type="text/javascript">
window.setTimeout(function(){
document.getElement('formSubmit').submit();
},1000*30);
</script>
}
?>
I don't know that much about jQuery other than going through a codecademy, and I know even less javascript. I'm a database person that got "conned" into building an advanced form/webpage. So I'm learning PHP, CSS, jQuery and HTML as I code.
Index.php:
<!DOCTYPE html>
<html>
<head>
<meta name=“Warehouse 3962” content="width=device-width, initial-scale=1.0">
<link href="style.css" type="text/css" rel="stylesheet">
<script type="text/javascript">
<!—window.setTimeout(function(){
document.getElement(‘formSubmit').submit();
},1000*30); —>
</script>
</head>
<body>
<section class="w">
<div class="row">
<div class="small columns">
<img src="logo.png" />
<h3 class="green">Users</h3>
</div>
<h6>Warehouse 3962</h6>
</div>
<div class="row">
<div class="small columns">
<form action="ajax.php" method="post" id="formSubmit">
<table id="equipment-table">
<thead>
<tr>
<th>Equipment</th>
<th>Amount</th>
<th>Val1</th>
<th>Val2</th>
</tr>
</thead>
<tbody>
<?php foreach
($results['tags'] as $equipment) {
if ($equipment['category'] == "Part") { ?>
<tr>
<td><?= $equipment['Amount']; ?></td>
<td class="text-center"><?= $equipment[‘quantity']; ?></td>
<td><input type="text" name="val1" /></td>
<td><input type="text" name="val2" /></td>
</tr>
<?php } // end if
} // end foreach ?>
<tr>
<td colspan="4" style="text-align: right;"><input type="submit" class="button" name="DONE" value="DONE" /></td>
</tr>
</tbody>
</table>
</form>
</div>
</div>
</section>
</body>
</html>
Please try this new solution. This will send a post every 30 seconds containing only the input boxes containing text on them.
<!DOCTYPE html>
<html>
<head>
<meta name="Warehouse 3962" content="width=device-width, initial-scale=1.0">
<link href="style.css" type="text/css" rel="stylesheet">
</head>
<body>
<section class="w">
<div class="row">
<div class="small columns">
<img src="logo.png" />
<h3 class="green">Users</h3>
</div>
<h6>Warehouse 3962</h6>
</div>
<div class="row">
<div class="small columns">
<form action="ajax.php" method="post" id="formSubmit">
<table id="equipment-table">
<thead>
<tr>
<th>Equipment</th>
<th>Amount</th>
<th>Val1</th>
<th>Val2</th>
</tr>
</thead>
<tbody>
<?php
foreach ($results['tags'] as $equipment) :
if ($equipment['category'] === "Part") :
?>
<tr>
<td>
<?php echo $equipment['Amount']; ?>
</td>
<td class="text-center">
<?php echo $equipment['quantity']; ?>
</td>
<td>
<input id="<?php echo $equipment['number'];?>-val1" type="text" name="<?php echo $equipment['number'];?>-val1"/>
</td>
<td>
<input id="<?php echo $equipment['number'];?>-val2" type="text" name="<?php echo $equipment['number'];?>-val2"/>
</td>
</tr>
<?php
endif;
endforeach;
?>
<tr>
<td colspan="4" style="text-align: right;">
<input type="submit" class="button" name="DONE" value="DONE" />
</td>
</tr>
</tbody>
</table>
</form>
</div>
</div>
</section>
<script type="text/javascript">
function sendData() {
var inputs = document.getElementById('equipment-table').getElementsByTagName('input'),
data = [],
name, val1, val2;
for (var i = 0; i < inputs.length; i++) {
if ( inputs[i].type === 'submit') {
continue;
}
if ( inputs[i].value ) {
name = inputs[i].name.split('-val');
val1 = inputs[i].name.split('val1');
if (val1.length > 1) {
data.push({name: name[0], val1: inputs[i].value});
}
else {
data.push({name: name[0], val2: inputs[i].value});
}
}
}
window.setTimeout(function() {
sendData();
},30000);
}
sendData();
</script>
</body>
</html>
You cannot mix PHP with JavaScript and why you set a timeout to 1000*30, that is equal to set a timeout to 30000 which means 30 seconds.
Then, you can use the 'require' attribute in the input filed to force the user to fill the required information.
<!DOCTYPE html>
<html>
<head>
<meta name="Warehouse 3962” content="width=device-width, initial-scale=1.0">
<link href="style.css" type="text/css" rel="stylesheet">
</head>
<body>
<section class="w">
<div class="row">
<div class="small columns">
<img src="logo.png" />
<h3 class="green">Users</h3>
</div>
<h6>Warehouse 3962</h6>
</div>
<div class="row">
<div class="small columns">
<form action="ajax.php" method="post" id="formSubmit">
<table id="equipment-table">
<thead>
<tr>
<th>Equipment</th>
<th>Amount</th>
<th>Val1</th>
<th>Val2</th>
</tr>
</thead>
<tbody>
<?php
foreach ($results['tags'] as $equipment) :
if ($equipment['category'] == "Part") : ?>
<tr>
<td><?= $equipment['Amount']; ?></td>
<td class="text-center">
<?php echo $equipment[‘quantity']; ?>
</td>
<td>
<input id="val1" type="text" name="val1”/>
</td>
<td>
<input id="val2" type="text" name="val2"/>
</td>
</tr>
<?php
endif;
endforeach;
?>
<tr>
<td colspan="4" style="text-align: right;">
<input type="submit" class="button" name="DONE" value="DONE" />
</td>
</tr>
</tbody>
</table>
</form>
</div>
</div>
</section>
<script type="text/javascript">
window.setTimeout(function(){
var val1 = document.getElementById("val1").value,
val2 = document.getElementById("val1").value;
if ( ! val1 && ! val2 ) document.getElement('formSubmit').submit();
},30000);
</script>
</body>
</html>
Related
In my old code the user can buy as many as he wants to , but in the new code the user must input only numbers less than the stocks.
I am not sure whether this is the problem or not.
Somehow the purchase does not go to the sales total in sales table.
In history.php the total purchase price does not show up , but when you click the view full details button you can see the total purchase.
History.php
View Full Detail
Sales table.
This is my old code add_cart.php code
In here it inserts fine.
<?php
include('session.php');
if(isset($_POST['cart'])){
$id=$_POST['id'];
$qty=$_POST['qty'];
$query=mysqli_query($conn,"select * from cart where productid='$id' and userid='".$_SESSION['id']."'");
if (mysqli_num_rows($query) > ($qty)){
echo "Input must be lower than the quantity!";
}
else{
mysqli_query($conn,"insert into cart (userid, productid, qty) values ('".$_SESSION['id']."', '$id', '$qty')");
}
}
?>
This is my new code add_cart.php code
In here it does not insert properly.
include('session.php');
if(isset($_POST['cart'])){
$id=$_POST['id'];
$qty=$_POST['qty'];
if($qty>0){//This Condition work for you
$query=mysqli_query($conn,"select product_qty from product where productid='$id'");
$result=mysqli_fetch_object($query);
if($result->product_qty < $qty){
echo 'Input must be lower than the stocks';
} else{
$query=mysqli_query($conn,"select * from cart where productid='$id' and userid='".$_SESSION['id']."'");
if (mysqli_num_rows($query)>0){
echo "Product already on your cart!";
}
else{
mysqli_query($conn,"insert into cart (userid, productid, qty) values ('".$_SESSION['id']."', '$id', '$qty')");
}
}
}
}
?>
history.php where the table are listed
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$( function() {
$( "#datepicker" ).datepicker();
} );
</script>
</head>
<body>
<p>Date: <input type="text" id="datepicker"></p>
</body>
</html>
<?php include('session.php'); ?>
<?php include('header.php'); ?>
<body>
<?php include('navbar.php'); ?>
<div class="container">
<?php include('cart_search_field.php'); ?>
<div style="height: 50px;"></div>
<div class="row">
<div class="col-lg-12">
<center> <h1 class="page-header">Purchase History</h1></center>
</div>
</div>
<!-- /.row -->
<div class="row">
<div class="col-lg-12">
<center>
<form action="total_sales.php" method="post">
From: <input type="text" class="datepicker" placeholder="E.G.(2018-01-14)" name="dayfrom" required pattern="[0-9]{4}+[0-9]+[0-9]"> To: <input type="text" class="datepicker" placeholder="E.G.(2018-02-11)" name="dayto" required pattern="[0-9]{4}+[0-9]+[0-9]">
<input type="submit" value="Show Purchases" name="salesbtn" ></form></center>
<table width="100%" class="table table-striped table-bordered table-hover" id="historyTable">
<thead>
<tr>
<th class="hidden"></th>
<th>Purchase Date</th>
<th>Total Amount</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$h=mysqli_query($conn,"select * from sales where userid='".$_SESSION['id']."' order by sales_date desc");
while($hrow=mysqli_fetch_array($h)){
?>
<tr>
<td class="hidden"></td>
<td><?php echo date("M d, Y - h:i A", strtotime($hrow['sales_date']));?></td>
<td><?php echo number_format($hrow['sales_total'],2); ?></td>
<td>
<span class="glyphicon glyphicon-fullscreen"></span> View Full Details
<?php include ('modal_hist.php'); ?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<!-- /.table-responsive -->
</div>
<!-- /.panel-body -->
</div>
</div>
<?php include('script.php'); ?>
<?php include('modal.php'); ?>
<script src="custom.js"></script>
<script>
$(document).ready(function(){
$('#history').addClass('active');
$('#historyTable').DataTable({
"bLengthChange": true,
"bInfo": true,
"bPaginate": true,
"bFilter": true,
"bSort": true,
"pageLength": 7
});
});
</script>
</body>
</html>
I have a eshop. in user basket the user added some products. now he/she wants to change(increase or decrease) the number(count) of the products. I have wrriten this part with ajax but it doesn't work. every thing seems right! I don't know whats wrong! please help me...
"at the end I have added "update_order.php" page's code."
<?php
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
include('database.php');
$object=new myclass_parent;
?>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<link href="css/bootstrap.min.css" rel="stylesheet"/>
<link href="css/bootstrap.rtl.min.css" rel="stylesheet"/>
<script type="text/javascript">
$(document).ready(function () {
$(".navbar-right li .navbar-brand").hide();
});
</script>
<title></title>
</head>
<body>
<?php
include('header.php');
?>
<!--------------------------------->
<!--------------------------------->
<!--------------------------------->
<!--------------------------------->
<!--------------------------------->
<div class="container content info">
<h4>سبد خرید</h4>
<div class="row">
<div style="display:none;margin-top:10px;" id="err_alert" class="alert alert-danger ">
<span id="empty_err"> </span>
</div>
<div class="table-responsive">
<table class="table my_table">
<thead>
<tr>
<th>فروشنده</th>
<th>توضیحات کالا</th>
<th>تعداد</th>
<th>قیمت واحد</th>
<th colspan="2">قیمت کل</th>
</tr>
</thead>
<tbody>
<?php
if(isset($_COOKIE['mybasket'])){
$query="select * from tblbasket where cookiename=? and payment=0";
$array=[$_COOKIE['mybasket']];
$result_array=$object->select($query,$array);
foreach($result_array as $result){
$productid=$result['productid'];
$count=$result['count'];
$query2="select * from tblproducts where id=?";
$array2=[$productid];
$result_array2=$object->select($query2,$array2);
$img=$result_array2[0]['img'];
$title=$result_array2[0]['title'];
$price=$result_array2[0]['price'];
$info=$result_array2[0]['info'];
?>
<tr id="<?php echo $productid; ?>" class="pitem">
<td rowspan=''>amazoon.com</td>
<td>
<img src="<?php echo $img; ?>" width="100" height="80"/>
<div>
<strong><?php echo $title; ?></strong>
<p><?php echo $info; ?></p>
</div>
</td>
<td>
<input style="width:50px" type="number" id="pcount" class="pcount"
onKeyDown="return checknumber(event);" min="1" value="<?php echo $count; ?>">
</td>
<td><span id="pprice"><?php echo $price; ?></span> تومان</td>
<td><span id="kol_price"><?php echo $count*$price; ?></span> تومان</td>
<td><a style="cursor:pointer;" class="remove"><img src="images/delete.png" alt="حذف محصول" title="حذف محصول"/></a></td>';
<?php
}//foreach
?>
</tr><!--basket_items-->
</tbody>
</table>
<br/>
</div>
</div>
<?php
}//isset cookie
?>
<div class="row">
<div class="col-12">
<table class="table-responsive tbl jamkharid">
<thead>
<tr><th>پیش فاکتور خرید</th></tr>
<tr><th>مبلغ کل</th><th>مالیات 9%</th><th>هزینه ارسال</th> <th>مبلغ پرداختی نهایی</th></tr>
</thead>
<tbody>
<td><span id="jam_kharid"></span> تومان</td><td><span id="maliat"></span> تومان</td>
<td><span id="delivery">0</span> تومان</td><td><span id="jam_kharid_final"></span> تومان</td>
</tbody>
</table>
</div><!--col12-->
</div><!--row-->
<div class="row">
<?php if(isset($_SESSION['email'])){ ?>
مرحله بعد
<?php }//if
else{
?>
مرحله بعد
<?php }//else ?>
</div>
</div>
<!--------------------------------->
<!--------------------------------->
<!--------------------------------->
<!--------------------------------->
<!--------------------------------->
<?php
include('footer.php');
?>
</body>
</html>
<script>
var timer;
function jam_kharid(){
var amount=0;
var buy_amount=0;
clearTimeout(timer);
timer=setTimeout(function(){
$(".pitem").each(function(index, element) {
var pcount=$(this).find("#pcount").val();
var pprice=$(this).find("#pprice").text();
amount=amount+parseInt(pcount)*parseInt(pprice);
buy_amount=(1.09*amount).toFixed(0);
});//each pitem function
$(".pitem .pcount").change(function(){
var pcount=$(this).val();
var pprice=$(this).parents(".pitem").find("#pprice").text();
var kol_price=parseInt(pcount)*parseInt(pprice);
$(this).parents(".pitem").find("#kol_price").text(kol_price);
jam_kharid();
//****************************************************************************************************************
var productcount=pcount;
var productid=$("#pcount").parents(".pitem").attr('id');
alert(productid);
$.ajax({
url:'update_order.php',
type:'POST',
data:{productid:productid,cookiename:<?php echo $_COOKIE['mybasket']; ?>,productcount:productcount}
})//ajax
.done(function(msg){
alert(msg);
})//done
//****************************************************************************************************************
});//change
$(".jamkharid").find("#jam_kharid").html(amount);
$('.jamkharid').find("#maliat").text(amount*0.09);
$('.jamkharid').find("#jam_kharid_final").text((1.09*amount).toFixed(0));
},600);
}//jam_kharid
jam_kharid();
function khali(){
var l=$('.pitem').length;
if(l==0){
$('#err_alert').show(300); $('#err_alert #empty_err').show(); $('#err_alert #empty_err').html('هیچ محصولی در سبد خرید شما موجود نمی باشد!');
$('.my_table').hide();
$('.jamkharid').hide();
}
}//function p_length
khali();
$(".remove").click(function(){
var id_pitem=$(this).parents(".pitem").attr('id');
var pitem_parent=$(this).parents(".pitem");
$.ajax({
url:'delete.php',
type:'POST',
data:{id:id_pitem}
})//ajax
.done(function(){
pitem_parent.remove();
alert('محصول مورد نظر حذف شد');
jam_kharid();
khali();
})//done
})//remove click function
function checknumber(e){
if( (e.keyCode==65 && e.ctrlKey) || (e.keyCode>=35 && e.keyCode<=40) || ($.inArray(e.keyCode,[8,46])!=-1) ){
return;
}//if
if( e.shiftKey || ((e.keyCode<48 || e.keyCode>57) && (e.keyCode<96 || e.keyCode>105)) ){
e.preventDefault();
}//if
}//checknumber
</script>
////////////////////////////////////////////////////////////////////////////////
update_order.php :
////////////////////////////////////////////////////////////////////////////////
<?php
include('database.php');
$object=new myclass_parent;
$product_id=intval($_POST['productid']);
$cookie_name=$_POST['cookiename'];
$product_count=intval($_POST['productcount']);
$query_update="update tblbasket set count=? where cookiename=? and productid=? and payment=0";
$array=array($product_count,$cookie_name,$product_id);
$object->myquery($query_update,$array); echo $product_id;
?>
i actually want to use ajax in CodeIgniter to update value in the database.
below is the code given:
views/list_user.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Admin Panel</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>css/screen.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
$('.round_button_circle').click(function() {
//Now just reference this button and change CSS
//$(this).css('background','green');
var id=this.value;//Getting the id of the user to update the status from unpublish to publish
var url='<?php echo base_url(); ?>index.php/ajax_controller/user_status';
alert(id+url);
$.ajax({
type: 'POST',
url: 'url', //We are going to make the request to the method "list_dropdown" in the match controller
data: 'id='+id, //POST parameter to be sent with the tournament id
success: function(data)
{
}
});
});
});
</script>
</head>
<body>
<div id="page-heading">
<div class="button">Create User</div><!--create category-->
<h1>USERS</h1><!--users's list-->
</div>
<!-- end page-heading -->
<table border="0" style="width:97%;margin:0px auto" cellpadding="0" cellspacing="0" id="content-table">
<tr>
<td>
<!-- start content-table-inner START -->
<div id="content-table-inner">
<div class="stdiv"><div class="msg1">
<?php
if(isset($_GET['msg']))
{
$msg=$_GET['msg'];
if($msg=="usertype")
{
echo "User has been Created";
}
if($msg=="create")
{
echo "User has been Created";
}
if($msg=="delete")
{
echo "User has been Deleted";
}
if($msg=="update")
{
echo "User has been Updated";
}
}
?>
</div>
</div>
<!-- start category-table -->
<table border="0" cellpadding="0" style="width:100%;margin:0px auto" cellspacing="0" id="product-table">
<tr>
<tr>
<th class="tbl_hdr">USER ID</th> <!--ID-->
<th class="tbl_hdr">NAME</th> <!--Name-->
<th class="tbl_hdr">EMAIL</th> <!--Email-->
<th class="tbl_hdr">PHONE NUMBER</th> <!--ph number-->
<th class="tbl_hdr">STATUS</th> <!--publish/unpublish-->
<th class="tbl_hdr" colspan="2">ACTION</th> <!--edit/delte-->
</tr>
<?php foreach($users as $user){?>
<tr>
<td><?php echo $user->id;?></td>
<td><?php echo $user->username;?></td>
<td><?php echo $user->email;?></td>
<td><?php echo $user->contact;?></td>
<td ><button id="status" class="round_button_circle" value="<?php echo $user->id;?>"></button></td>
</tr>
<?php }?>
</table>
<!-- end product-table................................... -->
</div>
<!-- end content-table -->
<!-- start paging..................................................... -->
<!-- end paging................ -->
<div class="clear"></div>
<!-- end content-table-inner ............................................END -->
</td>
</tr>
</table>
<div class="clear"> </div>
</div>
<!-- end content -->
<div class="clear"> </div>
</div>
<!-- end content-outer........................................................END -->
<div class="clear"> </div>
<!-- start footer -->
</body>
</html>
controller/ajax_controller.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Ajax_Controller extends CI_Controller {
// Show view Page
// This function call from AJAX
public function user_status()
{
$id=$this->input->post('id');
$data = array(
'status' => 1
);
$this->db->where('id', $id);
$this->db->update('tbl_users', $data);
echo "1";
}
}
Its giving me the url and the id which i want to update in the database in the alert box...but its not updating the value in the database once the button is clicked..
Can anyone help???
There is one mistakes in your code.
Change
url: 'url', // in ajax call
To
url: url, // do not use quotes with url variable
I'm using Agile Toolkit version 4.2.4 trying to implement the Exchanging rows between grids example found here: https://agiletoolkit.org/doc/grid/interaction
I have created the TSGrid class with the following code:
class TSGrid extends Grid {
function setReloadThis($view){
if($id=$_GET[$this->name.'_chsex']){
// do note, usually we supply 2 arguments for set() function. Second
// argument is being properly quoted (or parametrized), however in this
// case no quoting is required. Hence all the statement goes into first
// argument.
$this->dq->set('gender=if(gender="M","F","M")')
->where('id',$id)
->do_update();
// univ()->page() method updates page content through AJAX. In this case each
// grid is unaware of other objects on the page. So to keep it safe, we will refresh
// page completely.
$view->js()->reload()->execute();
}
return $this;
}
function init(){
parent::init();
$g=$this;
// When you are making your own classes, you must always keep in mind
// that those objects must be just as re-usable as original grids. In our case
// we do set the table and fields, however we leave it up to parent to set the
// additional conditions on our query. This is a major reason for the philosophy
// of Agile Toolkit saying to keep properties public.
$g->addColumn('text','name');
$g->addColumn('text','surname');
$g->addColumn('text','gender');
$g->addColumn('button','chsex','Change Sex');
$g->setSource('test');
}
function defaultTemplate(){
return array('grid_striped');
}
}
and inserted it in the lib folder of the agile toolkit installation.
I have created a test page with the following code:
class page_test extends Page {
function init(){
parent::init();
$p=$this;
$c=$p->add('View_Columns');
$col=$c->addColumn();
$col->add('H3')->set('Male list');
$col->add('TSGrid')
->setReloadThis($c)
->dq
->where('gender','M');
$col=$c->addColumn();
$col->add('H3')->set('Female list');
$col->add('TSGrid')
->setReloadThis($c)
->dq
->where('gender','F');
}
}
In my database, I have made the "test" table with id, name, surname and gender fields.
When I click the "Change sex" button, I get this:
"Error in AJAXec response: SyntaxError: Unexpected token <"
The AJAX response from the server is:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Agile Toolkit</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="./atk4/templates/shared/images/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="./atk4/templates/shared/css/jquery-ui.css" />
<link rel="stylesheet" type="text/css" href="./atk4/templates/shared/css/atk-main.css" />
<link rel="stylesheet" type="text/css" href="./atk4/templates/default/css/atk-custom.css" />
<script type="text/javascript" src="./atk4/templates/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="./atk4/templates/js/start-atk4.js"></script>
<script type="text/javascript" src="./atk4/templates/js/jquery-ui-1.9.2.min.js"></script>
<script type="text/javascript" src="./atk4/templates/js/ui.atk4_loader.js"></script>
<script type="text/javascript" src="./atk4/templates/js/ui.atk4_notify.js"></script>
<script type="text/javascript" src="./atk4/templates/js/atk4_univ.js"></script>
<!--[if IE 8]>
<link rel="stylesheet" type="text/css" href="./atk4/templates/shared/css/ie8.css"/>
<script type="text/javascript" src="./atk4/templates/shared/css/ie8.js"></script>
<![endif]-->
<script type="text/javascript">
$(function(){
$.atk4.includeJS("./atk4/templates/js/atk4_univ.js");
$.atk4.includeJS("./atk4/templates/js/ui.atk4_notify.js");
$.atk4.includeJS("./atk4/templates/js/ui.atk4_grid.js");
$.atk4.includeJS("./atk4/templates/js/ui.atk4_grid.js");
$.atk4(function(){ $('#agiletoolkit_test_view_columns_view_columns_column_tsgrid').find('.button_chsex').button();
$('#agiletoolkit_test_view_columns_view_columns_column_tsgrid').atk4_grid([]);
$('#agiletoolkit_test_view_columns_view_columns_column_2_tsgrid').find('.button_chsex').button();
$('#agiletoolkit_test_view_columns_view_columns_column_2_tsgrid').atk4_grid([]);
; });
});
</script>
</head>
<body>
<div id="atk-layout" class="atk-wrapper">
<div id="header">
<div id="atk-logo" class="ui-widget-header float-left"><img src="./atk4/templates/shared/images/logo.png" /></div>
<div id="header-right">
<script>
$(document).ready(function(){
$('.atk-menu-horizontal>ul>li:first-child').addClass("ui-corner-left");
$('.atk-menu-horizontal>ul>li:last-child').addClass("ui-corner-right");
$('.atk-menu-vertical>ul>li:first-child').addClass("ui-corner-top");
$('.atk-menu-vertical>ul>li:last-child').addClass("ui-corner-bottom");
$('.atk-menu .ui-state-default').hover(function() {
$(this).addClass("ui-state-hover");
}, function() {
$(this).removeClass("ui-state-hover");
});
});
</script>
<div id="agiletoolkit_menu" class="atk-menu atk-menu-horizontal ui-widget">
<ul>
<li class="ui-state-default">Welcome</li>
<li class="ui-state-default">Test1</li>
<li class="ui-state-default">Test2</li>
<li class="ui-state-active">Test3</li>
<li class="ui-state-default">Logout</li>
</ul>
</div>
<div id="atk-version"><b>Agile Toolkit™</b><br/><i><div id="agiletoolkit_licensor_upgradechecker" class="" style="">4.2.4 unlicensed</div>
</i></div>
</div>
</div>
<div id="agiletoolkit_test" class="page_test">
<div id="agiletoolkit_test_view_columns" class="atk-flexy">
<div id="agiletoolkit_test_view_columns_view_columns_column" class="" style=";width:50%"><H3 id="agiletoolkit_test_view_columns_view_columns_column_h3" class="" style="">Male list</H3>
<div id="agiletoolkit_test_view_columns_view_columns_column_tsgrid" class="atk-grid ">
<div class="atk-grid-panel"></div>
<table width="100%">
<thead class="ui-widget-header"><tr>
<th id="" class="ui-widget-header" nowrap >Name</th>
<th id="" class="ui-widget-header" nowrap >Surname</th>
<th id="" class="ui-widget-header" nowrap >Gender</th>
<th id="" class="ui-widget-header" nowrap style="width: 40px; text-align: center">Change Sex</th>
</tr></thead>
<tbody class="grid_body">
<tr class="" data-id="0" rel="0">
<td style="white-space: nowrap">stef</td>
<td style="white-space: nowrap">stefanel</td>
<td style="white-space: nowrap">M</td>
<td style="white-space: nowrap"><button type="button" class="button_chsex" onclick="$(this).univ().ajaxec('/agiletoolkit/?page=test&chsex=0&agiletoolkit_test_view_columns_view_columns_column_tsgrid_chsex=0')">Change Sex</button></td>
</tr>
</tbody>
</table>
</div>
</div>
<div id="agiletoolkit_test_view_columns_view_columns_column_2" class="" style=";width:50%"><H3 id="agiletoolkit_test_view_columns_view_columns_column_2_h3" class="" style="">Female list</H3>
<div id="agiletoolkit_test_view_columns_view_columns_column_2_tsgrid" class="atk-grid ">
<div class="atk-grid-panel"></div>
<table width="100%">
<thead class="ui-widget-header"><tr>
<th id="" class="ui-widget-header" nowrap >Name</th>
<th id="" class="ui-widget-header" nowrap >Surname</th>
<th id="" class="ui-widget-header" nowrap >Gender</th>
<th id="" class="ui-widget-header" nowrap style="width: 40px; text-align: center">Change Sex</th>
</tr></thead>
<tbody class="grid_body">
<tr class="" data-id="0" rel="0">
<td style="white-space: nowrap">eu</td>
<td style="white-space: nowrap">eueu</td>
<td style="white-space: nowrap">F</td>
<td style="white-space: nowrap"><button type="button" class="button_chsex" onclick="$(this).univ().ajaxec('/agiletoolkit/?page=test&chsex=0&agiletoolkit_test_view_columns_view_columns_column_2_tsgrid_chsex=0')">Change Sex</button></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div id="atk-footer-guard"></div>
</div>
<div id="footer" class="atk-wrapper">
This system is implemented using Agile Toolkit. © 1999–2012. See License
</div>
<div id="atk-growl-holder" class="atk-growl"></div>
</body>
</html>
Demo page is using older toolkit version, than in master branch. If you use example with master branch, you need following change:
$this->dq
->set('gender', $this->api->db->dsql()->expr('if(gender="M","F","M")'))
->where('id',$id)
->do_update();
this is due to change in dsql object.
here is working example with latest toolkit version
I have a lot going on in my header so I am hoping it is makes some sense. My Header does not render at all. The only part that shows up is the loginfrom2.inc.php I was wondering if anyone can let me know what is wrong
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel=stylesheet type="text/css" href="style.css">
<style type="text/css">
.headerfont {
color: #FFF;
}
</style>
<?php
/*Login Logout*/
if(isset($_SESSION['currentMember'])) {
$currentMember=unserialize($_SESSION['currentMember']);
?>
</head>
<body>
<table width="764" height="97" cellpadding="0" cellspacing="0" border="0">
<tr valign="top">
<td width="248"></td>
<td width="100%" background="img/faddedbanner3.png"> <img src="../img/star3.png" width="94" height="104" alt="Star"> <span class="headerfont" align="center"><strong>The Unofficial Bank of Mike</strong></span></td><td background="../assign4/img/faddedbanner3.png"></td>
<td>
</td>
</tr>
<div id="logout">
<span id="user_session">VALUED CUSTOMER: <strong>
<?=$currentMember->firstname?>
<?=$currentMember->lastname?>
</strong></span>
<a id="logout" href="<?=URL_ROOT?>logout.php" title="logout">LOGOUT</a>
<?php
}else{
require_once('loginform2.inc.php');
}
?>
</table>
</body>
</html>
//////////////////////////////////////////
This is my Loginform2.inc.php You can see the include statement above
<div id="login_form">
<form id="login" method="post" action="processlogin.php">
<p>
<label for="emailaddress">E-Mail Address:</label>
<input type="text" name="emailaddress" id="emailaddress" size="15">
</p>
<p>
<label for="password">Password: </label>
<input type="password" name="password" id="email" size="15">
</p>
<p>
<input type="submit" name="submit" id="login_submit" value="Login"></p>
</form>
</div>
///////////////////////processlogin.php
/*start session*/
session_start();
$_SESSION['currentMember'] = serialize($currentMember);
note the screen shots of my my web page
<?php
/*Login Logout*/
if(isset($_SESSION['currentMember'])) {
$currentMember=unserialize($_SESSION['currentMember']);
?>
Move that block to at least be inside the <body> tag.
When $_SESSION['currentMember'] is not set, the <head> element is never closed.
You also shouldn't be putting anything between the last <tr> and closing </table> tag. Your HTML is a bit of a mess.
Here's how you should probably structure it
<?php session_start() ?>
<!DOCTYPE html>
<html>
<head>
<!-- link / style elements, etc -->
</head>
<body>
<table>
<!-- table contents -->
</table>
<?php if (isset($_SESSION['currentMember'])) :
$currentMember=unserialize($_SESSION['currentMember']); ?>
<div id="logout">
<!-- etc -->
</div>
<?php else : require_once 'loginform2.inc.php'; endif ?>
</body>
</html>
First move that if block inside your body tag, as others have suggested. That means replace this:
<?php
if(isset($_SESSION['currentMember'])) {
$currentMember=unserialize($_SESSION['currentMember']);
?>
</head>
<body>
With this:
</head>
<body>
<?php
if(isset($_SESSION['currentMember'])) {
$currentMember=unserialize($_SESSION['currentMember']);
?>
If that doesn't fix it, take a look at this line:
if(isset($_SESSION['currentMember'])) {
It checks if $_SESSION['currentMember'] has a value other than NULL. If not, loginform2 is displayed instead of your header. I can't see anywhere in the code you've pasted where $_SESSION['currentMember'] is being given a value.
I'm guessing that it should be set in processlogin.php once a user successfully logs in. Perhaps some part of the login process is broken.