ok here is my issue, this code worked for me before but my server ended up updating php from 5.2 to 5.5 then it all messed up/
soon as i made it back 5.2 it worked again but now my checkout.php wont capture the values from managecart.php
any help would be appreciated.
below = managecart.php code
<?
session_start();
include("includes/db.php");
include("includes/phpscripts.php");
include('includes/settings.php');
if($_GET["action"] == "addcat")
{
$GETCATNAME = str_replace("'","''",$_REQUEST['CATNAME']);
$dbh=mysql_connect ("localhost", "florida_fields", "fields321") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("florida_fields");
$query = "INSERT INTO SHOPCAT VALUES ('','$GETCATNAME','0')";
mysql_query($query);
}
if($_GET["action"] == "editcat")
{
$GETCATNAME2 = str_replace("'","''",$_REQUEST['CATNAME2']);
$GETSHOPCAT2 = str_replace("'","''",$_REQUEST['SHOPID2']);
$GETSOLDOUT2 = str_replace("'","''",$_REQUEST['SOLDOUT2']);
$dbh=mysql_connect ("localhost", "florida_fields", "fields321") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("florida_fields");
$query = "UPDATE SHOPCAT SET CATNAME = '$GETCATNAME2', SOLDOUT = '$GETSOLDOUT2' WHERE SHOPID = '$GETSHOPCAT2'";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
}
if($_GET["action"] == "saveproduct")
{
$SAVEPID = str_replace("'","''",$_REQUEST['PID']);
unset($imagename);
if(!isset($_FILES) && isset($HTTP_POST_FILES))
$_FILES = $HTTP_POST_FILES;
if(!isset($_FILES['image_file']))
$error["image_file"] = "An image was not found.";
$newphrase = $SAVEPID.".jpg";
$imagename = str_replace(" ", "-", $newphrase);
if(empty($imagename))
$error["imagename"] = "The name of the image was not found.";
if(empty($error))
{
$newimage = $imagename;
if(basename($_FILES['image_file']['name']) == "")
{
}
else
{
$result = #move_uploaded_file($_FILES['image_file']['tmp_name'], $newimage);
if(empty($result))
$error["result"] = "There was an error moving the uploaded file.";
$source = $imagename;
$target = "products/$source";
$width = 200;
$height = 133;
$quality = 100;
$size = getimagesize($source);
//scale evenly
$ratio = $size[0] / $size[1];
if ($ratio >= 1){
$scale = $width / $size[0];
} else {
$scale = $height / $size[1];
}
// make sure its not smaller to begin with!
if ($width >= $size[0] && $height >= $size[1]){
$scale = 1;
}
$im_in = imagecreatefromjpeg ($source);
$im_out = imagecreatetruecolor($size[0] * $scale, $size[1] * $scale);
imagecopyresampled($im_out, $im_in, 0, 0, 0, 0, $size[0] * $scale, $size[1] * $scale, $size[0], $size[1]);
imagejpeg($im_out, $target, $quality);
imagedestroy($im_out);
imagedestroy($im_in);
$result = #move_uploaded_file($_FILES['image_file']['tmp_name'], $newimage);
if(empty($result))
$error["result"] = "There was an error moving the uploaded file.";
$source = $imagename;
$target = "products/large/$source";
$width = 600;
$height = 400;
$quality = 100;
$size = getimagesize($source);
//scale evenly
$ratio = $size[0] / $size[1];
if ($ratio >= 1){
$scale = $width / $size[0];
} else {
$scale = $height / $size[1];
}
// make sure its not smaller to begin with!
if ($width >= $size[0] && $height >= $size[1]){
$scale = 1;
}
$im_in = imagecreatefromjpeg ($source);
$im_out = imagecreatetruecolor($size[0] * $scale, $size[1] * $scale);
imagecopyresampled($im_out, $im_in, 0, 0, 0, 0, $size[0] * $scale, $size[1] * $scale, $size[0], $size[1]);
imagejpeg($im_out, $target, $quality);
imagedestroy($im_out);
imagedestroy($im_in);
}
}
$DelFile = $imagename;
if(basename($_FILES['image_file']['name']) == "")
echo "";
else
unlink($DelFile);
$SAVEPNAME = str_replace("'","''",$_REQUEST['PNAME']);
$SAVEPTEXT = str_replace("'","''",$_REQUEST['PTEXT']);
$SAVEPPRICE = str_replace("'","''",$_REQUEST['PPRICE']);
$SAVEPID = str_replace("'","''",$_REQUEST['PID']);
$dbh=mysql_connect ("localhost", "florida_fields", "fields321") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("florida_fields");
if(basename($_FILES['image_file']['name']) == "")
{
$query = "UPDATE SHOPPRODUCTS SET PNAME = '$SAVEPNAME', PTEXT = '$SAVEPTEXT', PPRICE = '$SAVEPPRICE' WHERE PID = '$SAVEPID'";
}
else
{
$query = "UPDATE SHOPPRODUCTS SET PNAME = '$SAVEPNAME', PTEXT = '$SAVEPTEXT', PPRICE = '$SAVEPPRICE', PIMAGE ='1' WHERE PID = '$SAVEPID'";
}
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
}
if($_GET["action"] == "addproduct")
{
$GETPNAME = str_replace("'","''",$_REQUEST['PNAME']);
$GETPTEXT = str_replace("'","''",$_REQUEST['PTEXT']);
$GETPPRICE = str_replace("'","''",$_REQUEST['PPRICE']);
$GETPCAT = str_replace("'","''",$_REQUEST['PCAT']);
$dbh=mysql_connect ("localhost", "florida_fields", "fields321") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("florida_fields");
$query = "INSERT INTO SHOPPRODUCTS VALUES ('','$GETPNAME','$GETPTEXT','$GETPPRICE','$GETPCAT','0')";
mysql_query($query);
}
if($_GET["action"] == "editcat")
{
$GETCATNAME2 = str_replace("'","''",$_REQUEST['CATNAME2']);
$GETSHOPCAT2 = str_replace("'","''",$_REQUEST['SHOPID2']);
$GETSOLDOUT2 = str_replace("'","''",$_REQUEST['SOLDOUT2']);
$dbh=mysql_connect ("localhost", "florida_fields", "fields321") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("florida_fields");
$query = "UPDATE SHOPCAT SET CATNAME = '$GETCATNAME2', SOLDOUT = '$GETSOLDOUT2' WHERE SHOPID = '$GETSHOPCAT2'";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
}
?>
<?
if($_GET["action"] == "deleteshopcat")
{
$dbh=mysql_connect ("localhost", "florida_fields", "fields321") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("florida_fields");
$TID = $_REQUEST['DID'] ;
$sql = "DELETE FROM SHOPCAT WHERE SHOPID = '$TID'";
mysql_query($sql);
//mysql_close();
}
?>
<?
if($_GET["action"] == "deleteproduct")
{
$dbh=mysql_connect ("localhost", "florida_fields", "fields321") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("florida_fields");
$TID = $_REQUEST['DID'] ;
$sql = "DELETE FROM SHOPPRODUCTS WHERE PID = '$TID'";
mysql_query($sql);
//mysql_close();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?echo$SHOWTITLE?></title>
<meta name="description" content="<?echo$SHOWDESC?>" />
<meta name="keywords" content="<?echo$SHOWKEYS?>">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="css/menu.css" rel="stylesheet" type="text/css" />
<SCRIPT SRC="language-en.js"></SCRIPT>
<SCRIPT SRC="nopcart.js"></SCRIPT>
<script>
function Edit(id)
{
window.open("editor/examples/editor1.php?ID="+id,"test","toolbar=no,location=no,status=no,resizable=yes,scrollbars=auto,width=700,height=600,top=50,left=50");
}
</script>
<script language="JavaScript">
<!--
function Form1()
{
if(document.form2.NAME.value=="")
{
alert("Please Enter Page Name");
return false;
}
}
function Form2()
{
if(document.form3.SUBONENAME.value=="")
{
alert("Please Enter Sub Page Name");
return false;
}
}
function Form3()
{
if(document.form4.SUBTWONAME.value=="")
{
alert("Please Enter Sub Page Name");
return false;
}
}
//-->
</script>
<script>
function DeletePage(id)
{
if(confirm("Are you really really sure you want to delete this page?"))
{
if(confirm("Ok, don't tell me I didn't warn you! You can not undo this one you know?"))
{
parent.location="index.php?action=delete&DID="+id
}
}
}
</script>
<script>
function DeleteProd(id)
{
if(confirm("Are you really really sure you want to delete this product?"))
{
if(confirm("Ok, don't tell me I didn't warn you! You can not undo this one you know?"))
{
parent.location="index.php?ID=49&action=deleteproduct&DID="+id
}
}
}
</script>
<script>
function DeleteShopCat(id)
{
if(confirm("Are you really really sure you want to delete this catagoy?"))
{
if(confirm("Ok, don't tell me I didn't warn you! You can not undo this one you know?"))
{
parent.location="index.php?ID=49&action=deleteshopcat&DID="+id
}
}
}
</script>
<script>
function showit(it) {
document.getElementById(it).style.display = "block";
}
function hideit(it) {
document.getElementById(it).style.display = "none";
}
function hideall() {
for (var i=1; i<=2; i++) {
hideit("x" + i);
}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
</script>
<style type="text/css">
<!--
body {
background-image: url(back.jpg);
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
-->
</style>
<link href="css/florida.css" rel="stylesheet" type="text/css" />
</head>
<body onload="MM_preloadImages('images/button1_2.jpg','images/button2_2.jpg')">
<table width="1024" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="top" background="mainback.jpg"><table width="944" height="717" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="109"><div align="right"><img src="images/facebook.jpg" width="310" height="50" border="0" /><br />
<img src="images/button1_1.jpg" name="Image4" border="0" id="Image4" /><img src="images/button2.jpg" width="32" height="59" /><img src="images/button2_1.jpg" name="Image6" width="129" height="59" border="0" id="Image6" /></div></td>
</tr>
<tr>
<td height="159">
</td>
</tr>
<tr>
<td valign="top"><table width="941" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top"> </td>
<td valign="top" class="TextD"><br /> </td>
</tr>
<tr>
<td width="156" valign="top"><table width="155" border="0" cellspacing="0" cellpadding="0">
<tr>
<td background="images/menuback.jpg"><br />
<table width="156" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="28"> </td>
<td width="128" valign="top"><? include("menu.php");?>
<br />
<br /></td>
</tr>
</table>
<div align="left"><img src="images/menubottom.jpg" width="149" height="69" /><br />
</tr>
</table>
<?php
if ($_SESSION['florida']=='fields321')
{
?>
<div align="left">
<span class="link2"> • Edit Menu</span><br />
<span class="link2"> • Logout</span><br />
<span class="link2"> • Page Settings</span><br />
<span class="link2"> • Sort Menu</span><br />
<span class="link2"> • Members</span><br />
<span class="link2"> • Orders</span><br />
<span class="link2"> • Edit Gallery</span><br />
</div>
<?
}
?>
<span class="link2"> • Shop The Farm</span><br />
</td>
<td width="779" valign="top"><span class="TextB"><strong>SHOPPING CART</strong></span><br />
<br />
<span class="TextB">Members are responsible for all paypal fees. The fee will be listed on your invoice as shipping.</span> <br />
<br />
<FORM ACTION="checkout.php" NAME="form" METHOD="GET" onSubmit="return ValidateCart(this)">
<div align="left">
<script>
ManageCart();
</script>
<input type=IMAGE src="images/placeorder.jpg" alt="Place Order" border=0 /> <img src="images/returntocart.jpg" border="0"/>
</div>
</FORM><br /></td>
</tr>
</table></td>
</tr>
</table>
<br /></td>
</tr>
<tr>
<td align="center"> </td>
</tr>
</table>
</body>
</html>
below = checkout.php code
<?
session_start();
?>
<?
$strMessageBody .= "$QUANTITY_1 - \$$PRICE_1 - $NAME_1 <br>";
if( $NAME_2 ) {$strMessageBody .= "$QUANTITY_2 - \$$PRICE_2 - $NAME_2 <br>";}
if( $NAME_3 ) {$strMessageBody .= "$QUANTITY_3 - \$$PRICE_3 - $NAME_3 <br>";}
if( $NAME_4 ) {$strMessageBody .= "$QUANTITY_4 - \$$PRICE_4 - $NAME_4 <br>";}
if( $NAME_5 ) {$strMessageBody .= "$QUANTITY_5 - \$$PRICE_5 - $NAME_5 <br>";}
if( $NAME_6 ) {$strMessageBody .= "$QUANTITY_6 - \$$PRICE_6 - $NAME_6 <br>";}
if( $NAME_7 ) {$strMessageBody .= "$QUANTITY_7 - \$$PRICE_7 - $NAME_7 <br>";}
if( $NAME_8 ) {$strMessageBody .= "$QUANTITY_8 - \$$PRICE_8 - $NAME_8 <br>";}
if( $NAME_9 ) {$strMessageBody .= "$QUANTITY_9 - \$$PRICE_9 - $NAME_9 <br>";}
if( $NAME_10 ){$strMessageBody .= "$QUANTITY_10 - \$$PRICE_10 - $NAME_10 <br>";}
if( $NAME_11 ){$strMessageBody .= "$QUANTITY_11 - \$$PRICE_11 - $NAME_11 <br>";}
if( $NAME_12 ){$strMessageBody .= "$QUANTITY_12 - \$$PRICE_12 - $NAME_12 <br>";}
if( $NAME_13 ){$strMessageBody .= "$QUANTITY_13 - \$$PRICE_13 - $NAME_13 <br>";}
if( $NAME_14 ){$strMessageBody .= "$QUANTITY_14 - \$$PRICE_14 - $NAME_14 <br>";}
if( $NAME_15 ){$strMessageBody .= "$QUANTITY_15 - \$$PRICE_15 - $NAME_15 <br>";}
if( $NAME_16 ){$strMessageBody .= "$QUANTITY_16 - \$$PRICE_16 - $NAME_16 <br>";}
if( $NAME_17 ){$strMessageBody .= "$QUANTITY_17 - \$$PRICE_17 - $NAME_17 <br>";}
if( $NAME_18 ){$strMessageBody .= "$QUANTITY_18 - \$$PRICE_18 - $NAME_18 <br>";}
if( $NAME_19 ){$strMessageBody .= "$QUANTITY_19 - \$$PRICE_19 - $NAME_19 <br>";}
if( $NAME_20 ){$strMessageBody .= "$QUANTITY_20 - \$$PRICE_20 - $NAME_20 <br>";}
if( $NAME_21 ){$strMessageBody .= "$QUANTITY_21 - \$$PRICE_21 - $NAME_21 <br>";}
if( $NAME_22 ){$strMessageBody .= "$QUANTITY_22 - \$$PRICE_22 - $NAME_22 <br>";}
if( $NAME_23 ){$strMessageBody .= "$QUANTITY_23 - \$$PRICE_23 - $NAME_23 <br>";}
if( $NAME_24 ){$strMessageBody .= "$QUANTITY_24 - \$$PRICE_24 - $NAME_24 <br>";}
if( $NAME_25 ){$strMessageBody .= "$QUANTITY_25 - \$$PRICE_25 - $NAME_25 <br>";}
if( $NAME_26 ){$strMessageBody .= "$QUANTITY_26 - \$$PRICE_26 - $NAME_26 <br>";}
if( $NAME_27 ){$strMessageBody .= "$QUANTITY_27 - \$$PRICE_27 - $NAME_27 <br>";}
if( $NAME_28 ){$strMessageBody .= "$QUANTITY_28 - \$$PRICE_28 - $NAME_28 <br>";}
$wcart = $strMessageBody;
$strMessageBody2 .= "$TOTAL";
$wcart = $strMessageBody;
$wtotal = $strMessageBody2;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Florida Fields To Forks</title>
<meta name="description" content="<?echo$SHOWDESC?>" />
<meta name="keywords" content="<?echo$SHOWKEYS?>">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="css/menu.css" rel="stylesheet" type="text/css" />
<SCRIPT SRC="language-en.js"></SCRIPT>
<SCRIPT SRC="nopcart.js"></SCRIPT>
<script>
function Edit(id)
{
window.open("editor/examples/editor1.php?ID="+id,"test","toolbar=no,location=no,status=no,resizable=yes,scrollbars=auto,width=700,height=600,top=50,left=50");
}
</script>
<script language="JavaScript">
<!--
function Form1()
{
if(document.form2.NAME.value=="")
{
alert("Please Enter Page Name");
return false;
}
}
function Form2()
{
if(document.form3.SUBONENAME.value=="")
{
alert("Please Enter Sub Page Name");
return false;
}
}
function Form3()
{
if(document.form4.SUBTWONAME.value=="")
{
alert("Please Enter Sub Page Name");
return false;
}
}
function checkoutone()
{
if(document.forma.PICKUP1.value=="")
{
alert("Please Enter Pick-up Date");
return false;
}
}
function checkouttwo()
{
if(document.formb.PICKUP1.value=="")
{
alert("Please Enter Pick-up Date");
return false;
}
}
//-->
</script>
<script>
function DeletePage(id)
{
if(confirm("Are you really really sure you want to delete this page?"))
{
if(confirm("Ok, don't tell me I didn't warn you! You can not undo this one you know?"))
{
parent.location="index.php?action=delete&DID="+id
}
}
}
</script>
<script>
function DeleteProd(id)
{
if(confirm("Are you really really sure you want to delete this product?"))
{
if(confirm("Ok, don't tell me I didn't warn you! You can not undo this one you know?"))
{
parent.location="index.php?ID=49&action=deleteproduct&DID="+id
}
}
}
</script>
<script>
function DeleteShopCat(id)
{
if(confirm("Are you really really sure you want to delete this catagoy?"))
{
if(confirm("Ok, don't tell me I didn't warn you! You can not undo this one you know?"))
{
parent.location="index.php?ID=49&action=deleteshopcat&DID="+id
}
}
}
</script>
<script>
function showit(it) {
document.getElementById(it).style.display = "block";
}
function hideit(it) {
document.getElementById(it).style.display = "none";
}
function hideall() {
for (var i=1; i<=2; i++) {
hideit("x" + i);
}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
</script>
<style type="text/css">
<!--
body {
background-image: url(back.jpg);
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
-->
</style>
<link href="css/florida.css" rel="stylesheet" type="text/css" />
</head>
<?
$GETMYTOTAL = $SHOWMEQ;
?>
<body onload="MM_preloadImages('images/button1_2.jpg','images/button2_2.jpg')">
<table width="1024" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="top" background="mainback.jpg"><table width="944" height="717" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="109"><div align="right"><img src="images/facebook.jpg" width="310" height="50" border="0" /><br />
<img src="images/button1_1.jpg" name="Image4" border="0" id="Image4" /><img src="images/button2.jpg" width="32" height="59" /><img src="images/button2_1.jpg" name="Image6" width="129" height="59" border="0" id="Image6" /></div></td>
</tr>
<tr>
<td height="159">
</td>
</tr>
<tr>
<td valign="top"><table width="941" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top"> </td>
<td valign="top" class="TextD"><br /> </td>
</tr>
<tr>
<td width="156" valign="top"><table width="155" border="0" cellspacing="0" cellpadding="0">
<tr>
<td background="images/menuback.jpg"><br />
<table width="156" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="28"> </td>
<td width="128" valign="top"><? include("menu.php");?>
<br />
<br /></td>
</tr>
</table>
<div align="left"><img src="images/menubottom.jpg" width="149" height="69" /><br />
</tr>
</table>
<?php
if ($_SESSION['florida']=='fields321')
{
?>
<span class="link2"> • Edit Menu</span><br />
<span class="link2"> • Logout</span><br />
<span class="link2"> • Page Settings</span><br />
<span class="link2"> • Sort Menu</span><br />
<span class="link2"> • Members</span><br />
<?
}
?>
<span class="link2"> • View Cart</span><br />
<span class="link2"> • Shop The Farm</span><br />
</td>
<td width="779" valign="top"><span class="TextC">Please review your order and select payment method below.<br>
Please be sure to submit a Pick Up Date thank you. <br />
</span><br />
<br />
View available dates<br />
<br />
<span class="TextB"><?echo$wcart?></span><br />
<table width="486" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><form id="forma" name="forma" method="post" action="checkout_check.php" onSubmit="return checkoutone();">
<span class="TextA">Pick-up date:</span>
<input name="PICKUP1" type="text" class="TextA" id="PICKUP1" size="20" />
<span class="TextA">Comments:</span>
<input name="COMMENTS1" type="text" class="TextA" id="COMMENTS1" size="20" />
<input type="hidden" name="memberid" value="<?echo$_SESSION['memberid']?>">
<input type="hidden" name="cart" value="<?echo$wcart?>">
<input type="hidden" name="amount" value="<?echo$SHOWMEQ?>">
<label>
<input name="button" type="submit" class="TextB" id="button" value="Pay by Check" />
</label>
</form></td>
<td><form id="formb" name="formb" method="post" action="checkout_paypal.php" onSubmit="return checkouttwo();">
<span class="TextA">Pick-up date:</span>
<input name="PICKUP1" type="text" class="TextA" id="PICKUP1" size="20" />
<span class="TextA">Comments:</span>
<input name="COMMENTS1" type="text" class="TextA" id="COMMENTS1" size="20" />
<input type="hidden" name="memberid" value="<?echo$_SESSION['memberid']?>">
<input type="hidden" name="cart" value="<?echo$wcart?>">
<input type="hidden" name="amount" value="<?echo$SHOWMEQ?>">
If you use globals, then now as they don't exist, you need to carry those variables around in different way, as function's parameters or $_SESSION variables
Related
I want to pass a variable to next page but i doesn't seem to work as expected. I have done samething on a different page but now it dosen't work.
This is the metod im using to pass the variables (email.php):
<div class='alternativ'> <td width="50%" style=" padding:5px;"> <form method='GET' action='excelimport.php'> <input type='hidden' name='pidnew3' value='$pidnew2'> <input type="submit" name="submit"> </form></td> </div>
and in excelimport.php i have this:$pidnew4 = $_POST['pidnew3'];
Im getting 2 error in excelimport.php:
Notice: Undefined index: pidnew3 in D:\home\site\wwwroot\devlopment\excelimport.php on line 77
its reffering to this: $pidnew4 = $_POST['pidnew3'];
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in D:\home\site\wwwroot\devlopment\excelimport.php on line 102
and this is reffering to this: $recResult = mysql_fetch_array($sql);
I have this php (email.php) page that i want to pass to another.:
<?php
include_once 'includes/db_connect.php';
include_once 'includes/functions2.php';
include_once 'includes/config.php';
error_reporting(-1); ini_set( 'display_errors', 1 );
//Start av sessions
sec_session_start();
if (login_check($mysqli) == true) {
$logged = 'Inloggad';
} else {
$logged = 'utloggad';
}
$uploadedStatus = 0;
if ( isset($_POST["submit"]) ) {
if ( isset($_FILES["file"])) {
//if there was an error uploading the file
if ($_FILES["file"]["error"] > 0) {
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else {
if (file_exists($_FILES["file"]["name"])) {
unlink($_FILES["file"]["name"]);
}
$storagename = "discussdesk.xlsx";
move_uploaded_file($_FILES["file"]["tmp_name"], $storagename);
$uploadedStatus = 1;
}
} else {
echo "Ingen fil vald <br />";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Kandidater</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=0.709">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<!-- jQuery library -->
<script src="js/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="main.css">
<link rel="shortcut icon" href="logo/wfmini.png">
<script type="text/javascript" language="javascript">
function checkedbox(element) {
var checkboxes = document.getElementsByTagName('input');
if (element.checked) {
for (var i = 0; i < checkboxes.length; i++) {
if (checkboxes[i].type == 'checkbox') {
checkboxes[i].checked = true;
}
}
} else {
for (var i = 0; i < checkboxes.length; i++) {
console.log(i)
if (checkboxes[i].type == 'checkbox') {
checkboxes[i].checked = false;
}
}
}
}
</script>
<script src="js/tinymce/js/tinymce/tinymce.min.js"></script>
<script>tinymce.init({selector:'textarea'});</script>
</head>
<body class="dashboardadmin">
<ss="container-fluid" style="width:50%;">
<br>
<center><h3>Skicka email till kandidater</h3></center>
<br>
<p>Välj kandidater</p>
<form method="post" action="">
<?php
$pidnew2 = $_GET['pidnew'];
// Retrieve Email from Database
$getemail = mysql_query("SELECT * FROM Email_Users WHERE pid='".$pidnew2."'");
if (!$getemail) die('MySQL Error: ' . mysql_error());
echo '<table class="table table-bordered">';
echo "<thead>
<tr>
<th><input type='checkbox' onchange='checkedbox(this)' name='chk'/></th>
<th>Förnamn</th>
<th>Efternamn</th>
<th>Email</th>
</tr>
</thead>";
if (mysql_num_rows($getemail) == 0) {
echo "<tbody><tr><td colspan='3'>No Data Avaialble</td></tr></tbody>";
}
while ($row = mysql_fetch_assoc($getemail)) {
echo "<tbody><tr><td><input value='".$row['Email']."' type='checkbox' name='check[]'/></td>";
echo "<td >".$row['fornamn']."</td>";
echo "<td >".$row['efternamn']."</td>";
echo "<td >".$row['Email']."</td></tr></tbody>";
}
echo "</table>";
?>
</form>
</center>
<br>
</div>
<table width="600" style="margin:115px auto; background:#f8f8f8; border:1px solid #eee; padding:10px;">
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post" enctype="multipart/form-data">
<tr><td colspan="2" style="font:bold 15px arial; text-align:center; padding:0 0 5px 0;">Ladda upp kandidater</td></tr>
<tr>
<td width="50%" style="font:bold 12px tahoma, arial, sans-serif; text-align:right; border-bottom:1px solid #eee; padding:5px 10px 5px 0px; border-right:1px solid #eee;">Välj fil</td>
<td width="50%" style="border-bottom:1px solid #eee; padding:5px;"><input type="file" name="file" id="file" /></td>
</tr>
<tr>
<td style="font:bold 12px tahoma, arial, sans-serif; text-align:right; padding:5px 10px 5px 0px; border-right:1px solid #eee;">Send</td>
<div class='alternativ'>
<td width="50%" style=" padding:5px;">
<form method='GET' action='excelimport.php'>
<input type='hidden' name='pidnew3' value='$pidnew2'>
<input type="submit" name="submit">
</form></td>
</div>
</tr>
</table>
<?php if($uploadedStatus==1){
header('Location: excelimport.php');
}?>
</form>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-38304687-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>
And here's the other one (excelimport.php):
<?php
include_once 'includes/db_connect.php';
include_once 'includes/functions2.php';
include_once 'includes/config.php';
error_reporting(-1); ini_set( 'display_errors', 1 );
//Start av sessions
sec_session_start();
if (login_check($mysqli) == true) {
$logged = 'Inloggad';
} else {
$logged = 'utloggad';
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="main.css">
<link rel="shortcut icon" href="logo/wfmini.png">
</head>
<body class="dashboardadmin">
<div class="innehall">
</div>
<p>
<?php
set_include_path(get_include_path() . PATH_SEPARATOR . 'Classes/');
include 'PHPExcel/IOFactory.php';
$pidnew4 = $_POST['pidnew3'];
$inputFileName = 'discussdesk.xlsx';
try {
$objPHPExcel = PHPExcel_IOFactory::load($inputFileName);
} catch(Exception $e) {
die('Error loading file "'.pathinfo($inputFileName,PATHINFO_BASENAME).'": '.$e->getMessage());
}
$allDataInSheet = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);
$arrayCount = count($allDataInSheet); // Here get total count of row in that Excel sheet
for($i=2;$i<=$arrayCount;$i++){
$userfName = trim($allDataInSheet[$i]["A"]);
$usereName = trim($allDataInSheet[$i]["B"]);
$userMobile = trim($allDataInSheet[$i]["C"]);
$query = "SELECT name FROM Email_Users WHERE fornamn = '".$userfName."' and efternamn '".$usereName."' and email = '".$userMobile."' and pid = '".$pidnew4."'";
$sql = mysql_query($query);
$recResult = mysql_fetch_array($sql);
$existName = $recResult["fornamn"];
if($existName=="") {
$insertTable= mysql_query("insert into Email_Users (fornamn, efternamn, email, pid) values('".$userfName."', '".$usereName."', '".$userMobile."', '".$pidnew4."');");
$msg = 'Record has been added. <div style="Padding:20px 0 0 0;">Go Back to tutorial</div>';
} else {
$msg = 'Record already exist. <div style="Padding:20px 0 0 0;">Go Back to tutorial</div>';
}
}
echo "<div style='font: bold 18px arial,verdana;padding: 45px 0 0 500px;'>".$msg."</div>";
?>
</body>
</html>
<form method='GET' action='excelimport.php'>
<input type='hidden' name='pidnew3' value='$pidnew2'>
<input type="submit" name="submit">
</form>
In this form, you mentioned GET method and you are passing variable using GET method in your another page.
You can not get pidnew3 variable to another page because you are using POST method to get pidnew3 variable.
You just need to change the below line from
$pidnew4 = $_POST['pidnew3'];
to
$pidnew4 = $_GET['pidnew3'];
I just realised what can be wrong, you didn't display the $pidnew2 value here
<form method='GET' action='excelimport.php'>
<input type='hidden' name='pidnew3' value='$pidnew2'>
<input type="submit" name="submit">
</form>
You should replace that block with
<form method='GET' action='excelimport.php'>
<input type='hidden' name='pidnew3' value='<?php echo $pidnew2; ?>'>
<input type="submit" name="submit">
</form>
Then you get the value of the variable $pidnew2 and not the string '$pidnew2'
You should change the method in the form by POST, as you are trying to get a variable passed through 'GET'. Or as below you can get the variable using the 'GET' method.
$pidnew4 = $_GET['pidnew3'];
values are ok in managecart.php
but soon as i checkout which goes to checkout.php file the values dont pickup from what i have entered into managecart.php
below is the coding i had created for the page (checkout.php) but now it dont seem to work.
<?
session_start();
?>
<?
$strMessageBody .= "$QUANTITY_1 - \$$PRICE_1 - $NAME_1 <br>";
if( $NAME_2 ) {$strMessageBody .= "$QUANTITY_2 - \$$PRICE_2 - $NAME_2 <br>";}
if( $NAME_3 ) {$strMessageBody .= "$QUANTITY_3 - \$$PRICE_3 - $NAME_3 <br>";}
if( $NAME_4 ) {$strMessageBody .= "$QUANTITY_4 - \$$PRICE_4 - $NAME_4 <br>";}
if( $NAME_5 ) {$strMessageBody .= "$QUANTITY_5 - \$$PRICE_5 - $NAME_5 <br>";}
if( $NAME_6 ) {$strMessageBody .= "$QUANTITY_6 - \$$PRICE_6 - $NAME_6 <br>";}
if( $NAME_7 ) {$strMessageBody .= "$QUANTITY_7 - \$$PRICE_7 - $NAME_7 <br>";}
if( $NAME_8 ) {$strMessageBody .= "$QUANTITY_8 - \$$PRICE_8 - $NAME_8 <br>";}
if( $NAME_9 ) {$strMessageBody .= "$QUANTITY_9 - \$$PRICE_9 - $NAME_9 <br>";}
if( $NAME_10 ){$strMessageBody .= "$QUANTITY_10 - \$$PRICE_10 - $NAME_10 <br>";}
if( $NAME_11 ){$strMessageBody .= "$QUANTITY_11 - \$$PRICE_11 - $NAME_11 <br>";}
if( $NAME_12 ){$strMessageBody .= "$QUANTITY_12 - \$$PRICE_12 - $NAME_12 <br>";}
if( $NAME_13 ){$strMessageBody .= "$QUANTITY_13 - \$$PRICE_13 - $NAME_13 <br>";}
if( $NAME_14 ){$strMessageBody .= "$QUANTITY_14 - \$$PRICE_14 - $NAME_14 <br>";}
if( $NAME_15 ){$strMessageBody .= "$QUANTITY_15 - \$$PRICE_15 - $NAME_15 <br>";}
if( $NAME_16 ){$strMessageBody .= "$QUANTITY_16 - \$$PRICE_16 - $NAME_16 <br>";}
if( $NAME_17 ){$strMessageBody .= "$QUANTITY_17 - \$$PRICE_17 - $NAME_17 <br>";}
if( $NAME_18 ){$strMessageBody .= "$QUANTITY_18 - \$$PRICE_18 - $NAME_18 <br>";}
if( $NAME_19 ){$strMessageBody .= "$QUANTITY_19 - \$$PRICE_19 - $NAME_19 <br>";}
if( $NAME_20 ){$strMessageBody .= "$QUANTITY_20 - \$$PRICE_20 - $NAME_20 <br>";}
if( $NAME_21 ){$strMessageBody .= "$QUANTITY_21 - \$$PRICE_21 - $NAME_21 <br>";}
if( $NAME_22 ){$strMessageBody .= "$QUANTITY_22 - \$$PRICE_22 - $NAME_22 <br>";}
if( $NAME_23 ){$strMessageBody .= "$QUANTITY_23 - \$$PRICE_23 - $NAME_23 <br>";}
if( $NAME_24 ){$strMessageBody .= "$QUANTITY_24 - \$$PRICE_24 - $NAME_24 <br>";}
if( $NAME_25 ){$strMessageBody .= "$QUANTITY_25 - \$$PRICE_25 - $NAME_25 <br>";}
if( $NAME_26 ){$strMessageBody .= "$QUANTITY_26 - \$$PRICE_26 - $NAME_26 <br>";}
if( $NAME_27 ){$strMessageBody .= "$QUANTITY_27 - \$$PRICE_27 - $NAME_27 <br>";}
if( $NAME_28 ){$strMessageBody .= "$QUANTITY_28 - \$$PRICE_28 - $NAME_28 <br>";}
$wcart = $strMessageBody;
$strMessageBody2 .= "$TOTAL";
$wcart = $strMessageBody;
$wtotal = $strMessageBody2;
?>
this i feel is where the data is being lost any ideas?
managecart.php page below
<?
session_start();
include("includes/db.php");
include("includes/phpscripts.php");
include('includes/settings.php');
if($_GET["action"] == "addcat")
{
$GETCATNAME = str_replace("'","''",$_REQUEST['CATNAME']);
$dbh=mysql_connect ("localhost", "florida_fields", "fields321") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("florida_fields");
$query = "INSERT INTO SHOPCAT VALUES ('','$GETCATNAME','0')";
mysql_query($query);
}
if($_GET["action"] == "editcat")
{
$GETCATNAME2 = str_replace("'","''",$_REQUEST['CATNAME2']);
$GETSHOPCAT2 = str_replace("'","''",$_REQUEST['SHOPID2']);
$GETSOLDOUT2 = str_replace("'","''",$_REQUEST['SOLDOUT2']);
$dbh=mysql_connect ("localhost", "florida_fields", "fields321") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("florida_fields");
$query = "UPDATE SHOPCAT SET CATNAME = '$GETCATNAME2', SOLDOUT = '$GETSOLDOUT2' WHERE SHOPID = '$GETSHOPCAT2'";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
}
if($_GET["action"] == "saveproduct")
{
$SAVEPID = str_replace("'","''",$_REQUEST['PID']);
unset($imagename);
if(!isset($_FILES) && isset($HTTP_POST_FILES))
$_FILES = $HTTP_POST_FILES;
if(!isset($_FILES['image_file']))
$error["image_file"] = "An image was not found.";
$newphrase = $SAVEPID.".jpg";
$imagename = str_replace(" ", "-", $newphrase);
if(empty($imagename))
$error["imagename"] = "The name of the image was not found.";
if(empty($error))
{
$newimage = $imagename;
if(basename($_FILES['image_file']['name']) == "")
{
}
else
{
$result = #move_uploaded_file($_FILES['image_file']['tmp_name'], $newimage);
if(empty($result))
$error["result"] = "There was an error moving the uploaded file.";
$source = $imagename;
$target = "products/$source";
$width = 200;
$height = 133;
$quality = 100;
$size = getimagesize($source);
//scale evenly
$ratio = $size[0] / $size[1];
if ($ratio >= 1){
$scale = $width / $size[0];
} else {
$scale = $height / $size[1];
}
// make sure its not smaller to begin with!
if ($width >= $size[0] && $height >= $size[1]){
$scale = 1;
}
$im_in = imagecreatefromjpeg ($source);
$im_out = imagecreatetruecolor($size[0] * $scale, $size[1] * $scale);
imagecopyresampled($im_out, $im_in, 0, 0, 0, 0, $size[0] * $scale, $size[1] * $scale, $size[0], $size[1]);
imagejpeg($im_out, $target, $quality);
imagedestroy($im_out);
imagedestroy($im_in);
$result = #move_uploaded_file($_FILES['image_file']['tmp_name'], $newimage);
if(empty($result))
$error["result"] = "There was an error moving the uploaded file.";
$source = $imagename;
$target = "products/large/$source";
$width = 600;
$height = 400;
$quality = 100;
$size = getimagesize($source);
//scale evenly
$ratio = $size[0] / $size[1];
if ($ratio >= 1){
$scale = $width / $size[0];
} else {
$scale = $height / $size[1];
}
// make sure its not smaller to begin with!
if ($width >= $size[0] && $height >= $size[1]){
$scale = 1;
}
$im_in = imagecreatefromjpeg ($source);
$im_out = imagecreatetruecolor($size[0] * $scale, $size[1] * $scale);
imagecopyresampled($im_out, $im_in, 0, 0, 0, 0, $size[0] * $scale, $size[1] * $scale, $size[0], $size[1]);
imagejpeg($im_out, $target, $quality);
imagedestroy($im_out);
imagedestroy($im_in);
}
}
$DelFile = $imagename;
if(basename($_FILES['image_file']['name']) == "")
echo "";
else
unlink($DelFile);
$SAVEPNAME = str_replace("'","''",$_REQUEST['PNAME']);
$SAVEPTEXT = str_replace("'","''",$_REQUEST['PTEXT']);
$SAVEPPRICE = str_replace("'","''",$_REQUEST['PPRICE']);
$SAVEPID = str_replace("'","''",$_REQUEST['PID']);
$dbh=mysql_connect ("localhost", "florida_fields", "fields321") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("florida_fields");
if(basename($_FILES['image_file']['name']) == "")
{
$query = "UPDATE SHOPPRODUCTS SET PNAME = '$SAVEPNAME', PTEXT = '$SAVEPTEXT', PPRICE = '$SAVEPPRICE' WHERE PID = '$SAVEPID'";
}
else
{
$query = "UPDATE SHOPPRODUCTS SET PNAME = '$SAVEPNAME', PTEXT = '$SAVEPTEXT', PPRICE = '$SAVEPPRICE', PIMAGE ='1' WHERE PID = '$SAVEPID'";
}
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
}
if($_GET["action"] == "addproduct")
{
$GETPNAME = str_replace("'","''",$_REQUEST['PNAME']);
$GETPTEXT = str_replace("'","''",$_REQUEST['PTEXT']);
$GETPPRICE = str_replace("'","''",$_REQUEST['PPRICE']);
$GETPCAT = str_replace("'","''",$_REQUEST['PCAT']);
$dbh=mysql_connect ("localhost", "florida_fields", "fields321") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("florida_fields");
$query = "INSERT INTO SHOPPRODUCTS VALUES ('','$GETPNAME','$GETPTEXT','$GETPPRICE','$GETPCAT','0')";
mysql_query($query);
}
if($_GET["action"] == "editcat")
{
$GETCATNAME2 = str_replace("'","''",$_REQUEST['CATNAME2']);
$GETSHOPCAT2 = str_replace("'","''",$_REQUEST['SHOPID2']);
$GETSOLDOUT2 = str_replace("'","''",$_REQUEST['SOLDOUT2']);
$dbh=mysql_connect ("localhost", "florida_fields", "fields321") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("florida_fields");
$query = "UPDATE SHOPCAT SET CATNAME = '$GETCATNAME2', SOLDOUT = '$GETSOLDOUT2' WHERE SHOPID = '$GETSHOPCAT2'";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
}
?>
<?
if($_GET["action"] == "deleteshopcat")
{
$dbh=mysql_connect ("localhost", "florida_fields", "fields321") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("florida_fields");
$TID = $_REQUEST['DID'] ;
$sql = "DELETE FROM SHOPCAT WHERE SHOPID = '$TID'";
mysql_query($sql);
//mysql_close();
}
?>
<?
if($_GET["action"] == "deleteproduct")
{
$dbh=mysql_connect ("localhost", "florida_fields", "fields321") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("florida_fields");
$TID = $_REQUEST['DID'] ;
$sql = "DELETE FROM SHOPPRODUCTS WHERE PID = '$TID'";
mysql_query($sql);
//mysql_close();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?echo$SHOWTITLE?></title>
<meta name="description" content="<?echo$SHOWDESC?>" />
<meta name="keywords" content="<?echo$SHOWKEYS?>">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="css/menu.css" rel="stylesheet" type="text/css" />
<SCRIPT SRC="language-en.js"></SCRIPT>
<SCRIPT SRC="nopcart.js"></SCRIPT>
<script>
function Edit(id)
{
window.open("editor/examples/editor1.php?ID="+id,"test","toolbar=no,location=no,status=no,resizable=yes,scrollbars=auto,width=700,height=600,top=50,left=50");
}
</script>
<script language="JavaScript">
<!--
function Form1()
{
if(document.form2.NAME.value=="")
{
alert("Please Enter Page Name");
return false;
}
}
function Form2()
{
if(document.form3.SUBONENAME.value=="")
{
alert("Please Enter Sub Page Name");
return false;
}
}
function Form3()
{
if(document.form4.SUBTWONAME.value=="")
{
alert("Please Enter Sub Page Name");
return false;
}
}
//-->
</script>
<script>
function DeletePage(id)
{
if(confirm("Are you really really sure you want to delete this page?"))
{
if(confirm("Ok, don't tell me I didn't warn you! You can not undo this one you know?"))
{
parent.location="index.php?action=delete&DID="+id
}
}
}
</script>
<script>
function DeleteProd(id)
{
if(confirm("Are you really really sure you want to delete this product?"))
{
if(confirm("Ok, don't tell me I didn't warn you! You can not undo this one you know?"))
{
parent.location="index.php?ID=49&action=deleteproduct&DID="+id
}
}
}
</script>
<script>
function DeleteShopCat(id)
{
if(confirm("Are you really really sure you want to delete this catagoy?"))
{
if(confirm("Ok, don't tell me I didn't warn you! You can not undo this one you know?"))
{
parent.location="index.php?ID=49&action=deleteshopcat&DID="+id
}
}
}
</script>
<script>
function showit(it) {
document.getElementById(it).style.display = "block";
}
function hideit(it) {
document.getElementById(it).style.display = "none";
}
function hideall() {
for (var i=1; i<=2; i++) {
hideit("x" + i);
}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
</script>
<style type="text/css">
<!--
body {
background-image: url(back.jpg);
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
-->
</style>
<link href="css/florida.css" rel="stylesheet" type="text/css" />
</head>
<body onload="MM_preloadImages('images/button1_2.jpg','images/button2_2.jpg')">
<table width="1024" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="top" background="mainback.jpg"><table width="944" height="717" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="109"><div align="right"><img src="images/facebook.jpg" width="310" height="50" border="0" /><br />
<img src="images/button1_1.jpg" name="Image4" border="0" id="Image4" /><img src="images/button2.jpg" width="32" height="59" /><img src="images/button2_1.jpg" name="Image6" width="129" height="59" border="0" id="Image6" /></div></td>
</tr>
<tr>
<td height="159">
</td>
</tr>
<tr>
<td valign="top"><table width="941" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top"> </td>
<td valign="top" class="TextD"><br /> </td>
</tr>
<tr>
<td width="156" valign="top"><table width="155" border="0" cellspacing="0" cellpadding="0">
<tr>
<td background="images/menuback.jpg"><br />
<table width="156" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="28"> </td>
<td width="128" valign="top"><? include("menu.php");?>
<br />
<br /></td>
</tr>
</table>
<div align="left"><img src="images/menubottom.jpg" width="149" height="69" /><br />
</tr>
</table>
<?php
if ($_SESSION['florida']=='fields321')
{
?>
<div align="left">
<span class="link2"> • Edit Menu</span><br />
<span class="link2"> • Logout</span><br />
<span class="link2"> • Page Settings</span><br />
<span class="link2"> • Sort Menu</span><br />
<span class="link2"> • Members</span><br />
<span class="link2"> • Orders</span><br />
<span class="link2"> • Edit Gallery</span><br />
</div>
<?
}
?>
<span class="link2"> • Shop The Farm</span><br />
</td>
<td width="779" valign="top"><span class="TextB"><strong>SHOPPING CART</strong></span><br />
<br />
<span class="TextB">Members are responsible for all paypal fees. The fee will be listed on your invoice as shipping.</span> <br />
<br />
<FORM ACTION="checkout.php" NAME="form" METHOD="POST" onSubmit="return ValidateCart(this)">
<div align="left">
<script>
ManageCart();
</script>
<input type=IMAGE src="images/placeorder.jpg" alt="Place Order" border=0 /> <img src="images/returntocart.jpg" border="0"/>
</div>
</FORM><br /></td>
</tr>
</table></td>
</tr>
</table>
<br /></td>
</tr>
<tr>
<td align="center"> </td>
</tr>
</table>
</body>
</html>
Hi i am retrieving data from database using pagination which i am able to retrieve but i am facing problem that in my pagination next and last button is not working
here is my code
** index.php**
<script type="text/javascript">
function searchboxfun(numRecords, pageNum ) {
$.ajax({
type: "GET",
url: "usersearchboxresult.php?search=" + document.getElementById("UserSearchBox").value,
data: "show="+numRecords+"&pagenum="+pageNum,
cache: false,
beforeSend: function () {
$('#content').html('<img src="loader.gif" alt="" width="24" height="24" style=" padding-left:469px;">');
},
success: function(html) {
$("#RightPaneContainerDiv").html( html );
}
});
return false;
}
function changeDisplayRowCount(numRecords) {
searchboxfun(numRecords, 1);
}
$( document ).ready(function() {
searchboxfun(10, 1);
});
</script>
<form name="myForm" id="Myform" action="#" onsubmit="return searchboxfun(); ">
<input type="text" id="UserSearchBox" name="UserSearchBox" style="width: 95%; margin-top: 15px; margin-left: 2%;" placeholder="Search Box"/>
<div style="float: right; margin-right: 2%; margin-top: 0px;">
<input type="submit" name="Search" value="Search" id="search" onclick='searchboxfun();'>
</div>
</form>
usersearchboxresult.php
<?php
session_start();
?>
<head>
<style>
.hidden { display: none; }
</style>
<link rel="stylesheet" type="text/css" href="styles.css" />
<script language="javascript" src="users.js" type="text/javascript"></script>
<script src="jquery.js"></script>
</head>
<?php
require_once("configure.php");
// Very important to set the page number first.
if (!(isset($_GET['pagenum']))) {
$pagenum = 1;
} else {
$pagenum = $_GET['pagenum'];
}
//Number of results displayed per page by default its 10.
$page_limit = ($_GET["show"] <> "" && is_numeric($_GET["show"]) ) ? $_GET["show"] : 10;
// Get the total number of rows in the table
//$sql = "SELECT * FROM tbl_pagination WHERE 1" ;
$search=$_GET['search'];
$eid=$_SESSION['eid'];
$sql="select * from clientreg where eid=$eid and (mobile like '%$search%' or fname like '%$search%' or service like '%$search%')";
//$select_table = "";
$cnt = mysql_num_rows( mysql_query($sql))or die("There is no record in Database!");
//Calculate the last page based on total number of rows and rows per page.
$last = ceil($cnt/$page_limit);
//this makes sure the page number isn't below one, or more than our maximum pages
if ($pagenum < 1) {
$pagenum = 1;
} elseif ($pagenum > $last) {
$pagenum = $last;
}
$lower_limit = ($pagenum - 1) * $page_limit;
$sql2 = $sql . " limit ". ($lower_limit)." , ". ($page_limit). " ";
$rs = mysql_query($sql2);
?>
<form name="frmUser" method="post" action="">
<div style="width:98%; margin-left:20px;">
<table border="0" cellpadding="10" cellspacing="1" width="100%" class="tblListForm">
<?php
$j=0;
$countleadmodified=array();
$countResult = 0;
while ( $row = mysql_fetch_array($rs) ) {
<tr>
<td><input type="checkbox" name="users[]" class="users" value="<?php echo $row["id"]; ?>" ></td>
<td>✰</td>
<td><?php echo $_SESSION['user'];?></td>
<td><?php echo $row["fname"];?></td>
<td><?php echo $row["lname"];?></td>
<td><?php echo $row["mobile"];?></td>
</tr>
<?php
$j++;
}
?>
</table>
</div>
</form>
<div id="paging">
<div class="height30"></div>
<table width="50%" border="0" cellspacing="0" cellpadding="2" align="center">
<tr>
<td valign="top" align="left">
<label> Rows Limit:
<select name="show" onChange="changeDisplayRowCount(this.value);">
<option value="10" <?php if ($_GET["show"] == 10 || $_GET["show"] == "" ) { echo ' selected="selected"'; } ?> >10</option>
<option value="20" <?php if ($_GET["show"] == 20) { echo ' selected="selected"'; } ?> >20</option>
<option value="30" <?php if ($_GET["show"] == 30) { echo ' selected="selected"'; } ?> >30</option>
</select>
</label>
</td>
<td valign="top" align="center" >
<?php
if ( ($pagenum-1) > 0) {
?>
First
Previous
<?php
}
//Show page links
for($i=1; $i<=$last; $i++) {
$j=1;
if ($i == $j) {
?>
<!--<a href="javascript:void(0);" class="selected" ><?php echo $i ?></a>-->
<?php
} else {
?>
<a href="javascript:void(0);" class="hidden" onclick="displayRecords('<?php echo $page_limit; ?>', '<?php echo $i; ?>');" ><?php echo $i ?></a>
<?php
}
$j++;}
if ( ($pagenum+1) <= $last) {
?>
Next
<?php } if ( ($pagenum) != $last) { ?>
<a href="javascript:void(0);" onclick="displayRecords('<?php echo $page_limit; ?>', '<?php echo $last; ?>');" class="links" >Last</a>
<?php
}
?>
</td>
<td align="right" valign="top">
Page <?php echo $pagenum; ?> of <?php echo $last; ?>
</td>
</tr>
</table>
</div>
here i this code i am able to retrive data from data base but any pagination is not working
where i am wrong how can i achieve my goal
Any help will be appreciated
I am struggling with my custom Javascript / Jquery code.
My code currently takes foldername, imagename, url dynamically from a PHP variable and passed to a function slideShow().
The following code works but shows a blank screen at the start and after the first cycle of images is completed. I understand that if all the images need to be loaded before they can be displayed, there will be a slight delay. Watch the cycle of the images, after cycling 7-8 times, the pages goes blank for 5 seconds before displaying again.
Working copy of the page is here http://tinyurl.com/8yqwvqs
<script type="text/javascript">
function RefreshPage(Period)
{
setTimeout("location.reload(true);", Period);
}
function slideShow(images,path,imageName,lnkUrl,sysFile,tim)
{
imName=imageName.split(",");
urlLink=lnkUrl.split(",");
image=images.split("|");
sysFile1=sysFile.split(",")
var i=0;
l=0;
arrLen=image.length-1
var val=0;
for(i=0;i<image.length-1;i++)
{
(function(i) {
setTimeout(function() {
//alert(time);
var num_of_cat = 4;
var myArr = new Array();
var temp=0;
if(i>=arrLen)
{
imName[3] = imName[3].replace('_',' ');
myArr[1] = '<!--<marquee behavior="slide" scrollamount="10">--><img src="'+path+sysFile1[3]+'" border="0" width="200" height="200"><br><b>'+imName[3]+'</b><!--</marquee>-->';
}
else
{
imName[i] = imName[i].replace('_',' ');
myArr[0] = '<!--<marquee behavior="slide" scrollamount="10">--><img src="'+path+sysFile1[i]+'" border="0" width="200" height="200"><br><b>'+imName[i]+'</b><!--</marquee>-->';
//}
}
if(i+1>=arrLen)
{
imName[2] = imName[2].replace('_',' ');
myArr[1] = '<!--<marquee behavior="slide" scrollamount="10">--><img src="'+path+sysFile1[2]+'" border="0" width="200" height="200"><br><b>'+imName[2]+'</b><!--</marquee>-->';
}
else
{
imName[i+1] = imName[i+1].replace('_',' ');
myArr[1] = '<!--<marquee behavior="slide" scrollamount="10">--><img src="'+path+sysFile1[i+1]+'" border="0" width="200" height="200"><br><b>'+imName[i+1]+'</b><!--</marquee>-->';
//}
}
if(i+2>=arrLen)
{
imName[1] = imName[1].replace('_',' ');
myArr[2] = '<!--<marquee behavior="slide" scrollamount="10">--><img src="'+path+sysFile1[1]+'" border="0" width="200" height="200"><br><b>'+imName[1]+'</b><!--</marquee>-->';
}
else
{
imName[i+2] = imName[i+2].replace('_',' ');
myArr[2] = '<!--<marquee behavior="slide" scrollamount="10">--><img src="'+path+sysFile1[i+2]+'" border="0" width="200" height="200"><br><b>'+imName[i+2]+'</b><!--</marquee>-->';
//}
}
if(i+3>=arrLen)
{
imName[0] = imName[0].replace('_',' ');
myArr[3] = '<!--<marquee behavior="slide" scrollamount="10">--><img src="'+path+sysFile1[0]+'" border="0" width="200" height="200"><br><b>'+imName[0]+'</b><!--</marquee>-->';
}
else
{
imName[i+3] = imName[i+3].replace('_',' ');
myArr[3] = '<!--<marquee behavior="slide" scrollamount="10">--><img src="'+path+sysFile1[i+3]+'" border="0" width="200" height="200"><br><b>'+imName[i+3]+'</b><!--</marquee>-->';
//}
}
for(p=0;p<myArr.length;p++)
{
$('#place'+p).html(myArr[p]);
}
},i*6000);
})(i);
l=l+1;
}
var li;
li=arrLen+"0";
li=li-15;
RefreshPage(li*750);
}
function clock(testArr){
var myArr1=new Array();
myArr1 = shuffle(testArr);
document.getElementById('place0').innerHTML = myArr1[0];
document.getElementById('place1').innerHTML = myArr1[1];
document.getElementById('place2').innerHTML = myArr1[2];
document.getElementById('place3').innerHTML = myArr1[3];
}
slideShow('a.jpg|b.jpg|giftbasketcategory.jpg|homecategory.jpg|img_4903.jpg|kd-vwb-1.jpg|links.jpg|picnicpal-stackeddisplay2.jpg|pictures.jpg|siblingcategorycookie.jpg|weddingsketch.jpg|wooden-bowls.jpg|','./retailers/','Notecards ,Kids__,Baby Gifts ,Wedding Gifts,Wooden Bowls ,Home,Gift_Baskets,','http://abc.com/test.asp?Cat=1818,http://abc.com/test.asp?Cat=1822,http://abc.com/test.asp?Cat=1821,http://abc.com/test.asp?Cat=1819,http://abc.com/test.asp?Cat=1820,http://abc.com/test.asp?Cat=1823,http://abc.com/test.asp?Cat=1824,','IMG_4903.JPG,SiblingCategoryCookie.jpg,PicnicPal-StackedDisplay2.jpg,WeddingSketch.JPG,wooden-bowls.jpg,HomeCategory.JPG,GiftBasketCategory.JPG,',100);
</script>
<table border="0" width="435px" bgcolor="#ECECEC">
<tr>
<td>
</td>
<td style="border:none; text-align:center">
<table >
<tr>
<td>
<div style="width:200px; float:left; text-align:center; padding-left:7px;" id='place0'></div>
<div style="width:200px; float:left; text-align:center; padding-left:7px;" id="place1"></div>
</td>
</tr>
<tr><td><div style="width:200px; float:left; text-align:center; padding-left:7px;" id="place2"></div>
<div style="width:200px; float:left; text-align:center; padding-left:7px;" id="place3"></div></td></tr></table>
</td>
<td>
</td>
</tr>
</table>
Have you tried calling slidehow onLoad on the client side?
http://api.jquery.com/ready/
In the case above:
$(document).ready(function() {
document.slideShow(params);
});
This will avoid all the timeouts messing up with other Javascript files from being fetched/loaded/executed.
The issue is that at form submission through ajax the page still reloads, even though the code has been written for it to not refresh the page, but only a certain div tag. It refreshes the div tag successfully.
As far as I can see (I have quintuple checked) the javascript form submission is written correctly as is the div refresh code.
There might be a problem in the php code where the form and the div that refreshes through ajax are present. The php file and the ajax javascript file are below...
Php file: The div gets refreshed by calling GET ajax=1. The form is called "addmonitor" and the div id is "monitor_form" - located around 2/3 down the bottom of the php code:
<?php
if (DIRECTORY_SEPARATOR=='/'){
define('EZMON_C', dirname(__FILE__));
}else{
define('EZMON_C', str_replace("\\", '/', dirname(__FILE__)));
}
require_once(EZMON_C.'/admin/local_config.php');
function mak_pwords($string, $saltkey, $pos=15) {
$stringA = sha1($string);
$salt = md5($saltkey);
$afterstr = substr($stringA, $pos);
$startbeginning = -(strlen($afterstr));
$beforestr = substr($stringA, 0, $startbeginning);
$hex = '/$E'; // fake ending
$salted = $beforestr . $salt . $afterstr . $hex;
return $salted;
}
//Path to location of local_config.php
error_reporting(0);
// resume the existing session, or establish a new one
session_start();
// Check Login
if(!isset($_SESSION['s_username']) && !isset($_SESSION['s_password']))
{
header("Location:index.php");
exit;
}
//$uid = isset($_GET['uid'])?intval($_GET['uid']):0;
// TODO: this is so wrong, but must remain for now. IMPORTANT!!! move this to index.php, where i assume login password checking is performed.
$uid = isset($_GET['uid'])?intval($_GET['uid']):0;
$_SESSION['uid']=$uid;
if(!isset($_GET['page'])){
$page = 1;
}else{
$page = $_GET['page'];
}
// Added by KTHSoft
if (isset($_GET['ajax'])){
$get_items = 'SELECT * FROM servers WHERE user_id=\''.mysql_real_escape_string($uid).'\'';
$get_items_res = mysql_query($get_items) or die(mysql_error( ));
$total_items = mysql_num_rows($get_items_res);
# Define the number of results per page
$max_results = 10;
/* Figure out the limit for the query based
on the current page number. */
$from = (($page * $max_results) - $max_results);
# get only the limited results
$get_limited_items = "SELECT * FROM servers WHERE user_id='".mysql_real_escape_string($uid)."' ORDER BY com_domain ASC LIMIT $from, $max_results";
$get_limited_items_res = mysql_query($get_limited_items) or die(mysql_error( ));
echo '<table><b>Monitors:</b></table>';
echo '<table>';
$turn = "275";
$cookies_defined = False; // Added by Predrag Bradaric (31. March 2011)
while ($items = mysql_fetch_array ($get_limited_items_res))
{
$domain = $items['domain'];
$com_domain = $items['com_domain'];
$port = $items['port'];
$last_time = $items['last_time'];
$last_date = $items['last_date'];
$last_status = $items['last_status'];
$active = $items['active'];
$sid = $items['id'];
if($last_status==1) {
$status = '<td width="10" align="left"><img src="images/rarrow.png" alt="Website Down" title="Website Down" style="margin-top: 2px;"></td>';
}elseif($last_status == 0){
if($active == 1){
if($last_time !=""){
$status = '<td width="10" align="left"><img src="images/garrow.png" alt="Website Up" title="Website Up" style="margin-top: 2px;"></td>';
}else{
$status = '<td width="10" align="left"><img src="images/pause.png" alt="Monitoring not started yet" title="Monitoring not started yet" style="margin-top: 2px;"></td>';
}
$last_updtt = $last_time;
$last_updtd = $last_date;
}
if($active==0){
$status = '<td width="10" align="left"><img src="images/pause.png" alt="Website Not Monitored" title="Website Not Monitored" style="margin-top: 2px;"></td>';
}
}else{
$status = '<td>Unknown</td>';
}
if($port==80){$port_type="HTTP";
}elseif($port==21){$port_type="FTP";
}elseif($port==143){$port_type="IMAP";
}elseif($port==25){$port_type="SMTP";
}elseif($port==5060){$port_type="SIP";
}elseif($port==110){$port_type="POP";
}elseif($port==443){$port_type="HTTPS";
}elseif($port==2082){$port_type="cPanel";
}elseif($port==2086){$port_type="WHM";
}elseif($port==3306){$port_type="MySQL";
}else{$port_type=$port;}
if($last_time==""){
$last_time="Monitoring not started yet";
}
echo '<tr>'.$status
?>
<!-- MODIFIED BY Predrag Bradaric (29. March 2011) -->
<?php
if (!(isset($_GET['donotrefresh']))) {
if (isset($_COOKIE["$com_domain$port"])) {
$cookies_defined = True;
}
?>
<script type="text/javascript">
if (dhtmlwindow.getCookie("<?php echo "$com_domain$port"; ?>")) {
var window_name = "<?php echo "$com_domain$port"; ?>";
<?php echo "$com_domain$port"; ?> = dhtmlwindow.open(window_name, dhtmlwindow.getCookie(window_name).split("~")[4], decodeURIComponent(dhtmlwindow.getCookie(window_name).split("~")[5]), dhtmlwindow.getCookie(window_name).split("~")[6], 'width='+dhtmlwindow.getCookie(window_name).split("~")[2]+',height='+dhtmlwindow.getCookie(window_name).split("~")[3]+',left='+dhtmlwindow.getCookie(window_name).split("~")[0]+',top='+dhtmlwindow.getCookie(window_name).split("~")[1]+',resize=0,scrolling=0', 'recal');
}
// alert(dhtmlwindow.getCookie("<?php echo "$com_domain$port"; ?>"))
</script>
<!-- END OF MODIFICATION (29. March 2011) -->
<?php } ?>
<td> <!--
<?php echo $domain; ?><?php echo ' ' . $port_type; ?> -->
<?php echo $domain; ?><?php echo ' ' . $port_type; ?>
</td>
<?php
# monitor buttons to pause, resume and delete
if ($active == 1)
{
?>
<td align="right" width="25" style="font-size: 11px; color: #666;">
<img src="images/control_pause.png" title="Pause monitor: <?php echo $domain; ?>" alt="Pause monitor: <?php echo $domain; ?>" height="16" width="16" border="0"></td>
<!--
<td align="right" width="25" style="font-size: 11px; color: #666;">
<img src="images/control_pause.png" title="Pause monitor: <?php echo $domain; ?>" alt="Pause monitor: <?php echo $domain; ?>" height="16" width="16" border="0"></td> -->
<?php
}
else if ($active == 0)
{
?>
<td align="right" width="25" style="font-size: 11px; color: #666;">
<img src="images/control_play_blue.png" title="Resume monitor: <?php echo $domain; ?>" alt="Resume monitor: <?php echo $domain; ?>" height="16" width="16" border="0"></td>
<!--
<td align="right" width="25" style="font-size: 11px; color: #666;">
<img src="images/control_play_blue.png" title="Resume monitor: <?php echo $domain; ?>" alt="Resume monitor: <?php echo $domain; ?>" height="16" width="16" border="0"></td> -->
<?php
}
?>
<td align="right" width="18" style="font-size: 11px; color: #666;">
<img src="images/delete.png" title="Delete monitor: <?php echo $domain; ?>" alt="Delete monitor: <?php echo $domain; ?>" height="16" width="16" border="0"></td>
<!--
<td align="right" width="18" style="font-size: 11px; color: #666;">
<img src="images/delete.png" title="Delete monitor: <?php echo $domain; ?>" alt="Delete monitor: <?php echo $domain; ?>" height="16" width="16" border="0"></td> -->
<?php
# set position of windows displaying the graphs
if ($turn == "275")
{
$turn = "730";
}
else if ($turn == "730")
{
$turn = "275";
}
}
echo "</table>";
// MODIFIED BY Predrag Bradaric (31. March 2011)
if (!($cookies_defined) && !(isset($_GET['donotrefresh']))) {
// init dhtml windows from database
// at this point $uid should be valid user id
include("dhtmlretrieve.php");
}
// END OF MODIFICATION (31. March 2011)
# begin page numbers output
# Figure out the total number of pages. Always round up using ceil()
$total_pages = ceil($total_items / $max_results);
# Build Page Number Hyperlinks
echo "<center><font size=\"2\" color=\"#666666\"face=\"Arial, Helvetica, sans-serif\">Pages of your monitors:<br /></font>";
if($page <= 7)
{
$from_linkedpage = 1;
$to_linkedpage = 15;
}
else
{
if($page > $total_pages - 7)
{
$from_linkedpage = $total_pages - 15;
$to_linkedpage = $total_pages;
}
else
{
$from_linkedpage = $page - 7; //15*floor($page / 15)+1;
$to_linkedpage = $page + 7; //$from_linkedpage + 14;
}
}
if ($to_linkedpage > $total_pages)
{
$to_linkedpage = $total_pages;
}
if ($from_linkedpage < 1)
{
$from_linkedpage = 1;
}
// Build Previous Link
if(($from_linkedpage > 1) || ($page > 1))
{
$prev = ($page - 1);
echo '<a onclick="goToPage(' . $prev . ')" href="#"><b>< Previous</b></a> ';
}
for($j = $from_linkedpage; $j <= $to_linkedpage; $j++)
{
if(($page) == $j)
{
echo "$j ";
}
else
{
echo '<a onclick="goToPage(' . $j . ')" href="#">'.$j.'</a> ';
}
}
// Build Next Link
if($page < $total_pages)
{
$next = ($page + 1);
echo ' <a onclick="goToPage(' . $next . ')" href="#"><b>Next ></b></a>';
}
echo "</font></center><br>";
?>
<script type='text/javascript'>
function goToPage(page){
var dataString = 'ajax=1&donotrefresh=1&page=' + page + '&uid=<?php echo $uid;?>';
$.ajax({
type: "GET",
url: "monpanel.php",
data: dataString,
success: function(html_data){
$('#list_monitors').html(html_data);
}
});
}
</script>
<?php
die();
}
// End added by KTHSoft
/* Temporary config.php replacement */
$uname_admin = $setting['uname_admin'];
$pword_admin = $setting['pword_admin'];
$allow_add = $setting['allow_add'];
$mon_int = $setting['mon_int'];
$max_fail = $setting['max_fail'];
$time_out = $setting['time_out'];
$mon_email = $setting['mon_email'];
$do_logging = $setting['do_logging'];
$fully_log = $setting['fully_log'];
$err_check = $setting['err_check'];
$email_override = $setting['email_override'];
$cfg_offset = $setting['cfg_offset'];
$pingIP_host = $setting['pingIP_host'];
$ping_delay = $setting['ping_delay'];
$num_pings = $setting['num_pings'];
$reliable_test_server = $setting['reliable_test_server'];
$reliable_test_server2 = $setting['reliable_test_server2'];
$date_format = $setting['date_format'];
$version = $setting['version'];
/* End Temporary config.php replacement */
error_reporting(0);
$style='';
$uid = isset($_GET['uid'])?intval($_GET['uid']):0;
$title=' - Viewing UserID:'.$uid.' Servers Status';
header("Cache-Control: must-revalidate");
$offset = 60 * 60 * 24 * -1;
$ExpStr = "Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT";
header($ExpStr);
include("header.php");
$monthnow = date("m");
$yearnow = date("Y");
/*
# Delete Monitors
if (isset($_GET["act"]) && $_GET["act"] == "delete") {
$del_items="DELETE FROM servers WHERE id='$_GET[sid]' AND user_id='$_GET[uid]'";
mysql_query($del_items) or die(mysql_error( ));
#echo '<script>alert("Monitor Deleted Successfully!")</script>';
}
# Pause Monitors
if (isset($_GET["act"]) && $_GET["act"] == "pause") {
$pause_items="UPDATE servers SET active=0 WHERE id='$_GET[sid]' AND user_id='$_GET[uid]'";
mysql_query($pause_items) or die(mysql_error( ));
#echo '<script>alert("Monitor Paused Successfully!")</script>';
}
# Resume Monitors
if (isset($_GET["act"]) && $_GET["act"] == "resume") {
$resume_items="UPDATE servers SET active=1 WHERE id='$_GET[sid]' AND user_id='$_GET[uid]'";
mysql_query($resume_items) or die(mysql_error( ));
#echo '<script>alert("Monitor Paused Successfully!")</script>';
}
*/
?>
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="jquery.validate.min.js"></script>
<script type="text/javascript" src="jquery.cookie.min.js"></script>
<link rel="stylesheet" href="windowfiles/dhtmlwindow.css" type="text/css" />
<script type="text/javascript" src="windowfiles/dhtmlwindow.js"></script>
<link rel="stylesheet" href="modalfiles/modal.css" type="text/css" />
<script type="text/javascript" src="modalfiles/modal.js"></script>
<script type="text/javascript" src="validate.js"></script>
<input type="hidden" id="hidUid" value="<?php echo (intval($uid)); ?>"/>
<?php
// Sanitise security addition
if (is_int(intval($uid))){$uid = intval($uid);}else{$uid = 0;}
if ($uid != '')
{
$date_array = getdate();
foreach ($date_array as $key => $val) {$key = $val;}
$mon=$date_array['mon'];
if($mon<10){$mon="0$mon";}
$day=$date_array['mday'];
if($day<10){$day="0$day";}
$year=$date_array['year'];
$hrs=$date_array['hours'];
if($hrs<10){$hrs="0$hrs";}
$min=$date_array['minutes'];
if($min<10){$min="0$min";}
$sec=$date_array['seconds'];
if($sec<10){$sec="0$sec";}
$time="$hrs:$min:$sec";
// date = month/day/year 10/05/2006
if ($setting['date_format'] == 'day/month/year'){
$day_mon_yr = "$day/$mon/$year";
$date = "$day-$mon-$year";
}
if ($setting['date_format'] == 'month/day/year'){
$day_mon_yr = "$mon/$day/$year";
$date = "$mon-$day-$year";
}
if ($setting['date_format'] == 'year/month/day'){
$day_mon_yr = "$year/$mon/$day";
$date = "$year-$mon-$day";
}
echo '<table align="left" valign="top" width="255" style="margin-top: 0px;">';
if(isset($_SESSION['s_username']))
{
echo '<tr><td width="10"> </td><td style="border: 1px solid #666666; background: #fff; padding: 12px;">';
// loop through the monitors the user has and display them in the menu
$get_items = "SELECT * FROM servers WHERE user_id='$uid'";
$get_items_res = mysql_query($get_items) or die(mysql_error( ));
if(isset($_SESSION['s_username']))
{
?>
<script type='text/javascript'>
var dataString = 'ajax=1&page=' + <?php echo $page?> + '&uid=<?php echo $uid;?>';
$.ajax({
type: "GET",
url: "monpanel.php",
data: dataString,
success: function(html_data){
$('#list_monitors').html(html_data);
}
});
</script>
<?php
echo '<div id="list_monitors">';
echo "</div>";
// chaeck if the user logged in is a paid customer
#$get_paid = "SELECT paid FROM servers WHERE user_id='$uid' LIMIT 1";
#$get_paid_res = mysql_query($get_paid) or die(mysql_error( ));
while ($item_paid = mysql_fetch_array ($get_items_res))
{
$paid_array = $item_paid['paid'];
$paid = $paid_array[0];
}
if ($paid == "1")
{
?>
<div id="monitor_form">
<fieldset border="0">
<table align="left">
<form name="addmonitor" action=""> <!-- action="user_add.php" method="POST" -->
<tr>
<td colspan="2"><font color="#666666"><strong>Add new monitor:</strong></font></td>
</tr>
<input type="hidden" name="cemail" id="cemail" value="<?=$_SESSION['s_username']?>" />
<tr>
<td><label for="domain" id="domain_label" style="text-align: left;">Website URL/IP<br>
<font size="1" color="red">without http://www.</font></label></td>
<td valign="top"><input type="text" size="13" name="domain" id="domain" class="text-input" /></td>
</tr>
<tr>
<td><label class="error" for="domain" id="domain_error">Field is required.</label></td>
</tr>
<tr>
<td><label for="com_domain" id="com_domain_label" style="text-align: left;">Monitor Name</label></td>
<td valign="top"><input type="text" size="13" name="com_domain" id="com_domain" class="text-input" /></td>
</tr>
<tr>
<td><label class="error" for="com_domain" id="com_domain_error">Field is required.</label></td>
</tr>
<tr>
<td><label for="port" id="port_label" style="text-align: left;">Port</label></td>
<td valign="top"><select name="port" id="port" class="select-input">
<option value="80" SELECTED>HTTP: 80</option>
<option value="443">HTTPS: 443</option>
<option value="21">FTP: 21</option>
<option value="5060">SIP: 5060</option>
<option value="80">TCP: 80</option>
<option value="5060">UDP: 5060</option>
<option value="143">IMAP: 143</option>
<option value="25">SMTP: 25</option>
<option value="110">POP3: 110</option>
</select></td>
</tr>
<tr>
<input type="hidden" name="active" id="active" value="1" />
<input type="hidden" name="uid" id="uid" value="<?php echo $uid;?>" />
</tr>
<tr>
<td><label for="main" id="main_label" style="text-align: left;">Main<br>
<font size="1" color="red">only one per URL/IP</font></label></td>
<td valign="top"><select name="main" id="main" class="select-input">
<option value="0">No</option>
<option value="1">Yes</option>
</select></td>
</tr>
<tr>
<td><input type="submit" value="Add monitor" name="addserver" class="button" id="addserver_btn" /></td> <!-- name="addserver" -->
</tr>
</form>
</table>
</fieldset>
</div>
<?php
}
else if ($paid == "0")
{
?>
<div id="free">
<fieldset border="0">
<table align="left">
<form name="free" action=""> <!-- action="user_add.php" method="POST" -->
<tr>
<td colspan="2"><font color="#666666"><strong>Add new monitor:</strong></font></td>
</tr>
<tr>
<td><label for="free" id="free" style="text-align: left;">Website URL/IP<br>
<font size="1" color="red">without http://www.</font></label></td>
<td valign="top"><input type="text" size="13" name="free" id="free" class="text-input" /></td>
</tr>
<tr>
<td><label for="free1" id="free1" style="text-align: left;">Monitor Name</label></td>
<td valign="top"><input type="text" size="13" name="free1" id="free1" class="text-input" /></td>
</tr>
<tr>
<td><label for="free2" id="free2" style="text-align: left;">Port</label></td>
<td valign="top"><select name="free2" id="free2" class="select-input">
<option value="80" SELECTED>HTTP: 80</option>
<option value="443">HTTPS: 443</option>
<option value="21">FTP: 21</option>
<option value="5060">SIP: 5060</option>
<option value="80">TCP: 80</option>
<option value="5060">UDP: 5060</option>
<option value="143">IMAP: 143</option>
<option value="25">SMTP: 25</option>
<option value="110">POP3: 110</option>
</select></td>
</tr>
<tr>
<td><label for="free3" id="free3" style="text-align: left;">Main<br>
<font size="1" color="red">only one per URL/IP</font></label></td>
<td valign="top"><select name="free3" id="free3" class="select-input">
<option value="0">No</option>
<option value="1">Yes</option>
</select></td>
</tr>
<tr>
<td><input type="submit" value="Add monitor" name="free4" class="button" id="free4"
onClick="pay=dhtmlmodal.open('pay', 'div', 'paydiv', 'Paid Account', 'width=425px,height=267px,center=1,resize=0,scrolling=0'); return false" /></td> <!-- name="addserver" -->
</tr>
</form>
</table>
</fieldset>
</div>
<div id="paydiv" style="display:none">
<center>
<h4>To monitor more websites subscribe to our advanced service:</h4>
1) You get to set up monitors for an <b>unlimited number of websites</b><br>2) Unlimited alert emails<br>3) Unlimited alert SMS messages<br>4) and much more for only $5 per month...<br><br>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="GDTCMF9N56TKG">
<input type="image" src="https://www.paypal.com/en_AU/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online.">
<img alt="" border="0" src="https://www.paypal.com/en_AU/i/scr/pixel.gif" width="1" height="1">
</form>
<br><br>
</center>
</div>
<?php
}
echo '<br><table><b>Account:</b></table>';
echo '<table>';
?>
<tr><td><img src="images/user.png" title="Edit Profile" alt="Edit Profile">
Edit Profile<br>
<img src="images/lock.png" title="Change Password" alt="Change Password">
Change Password<br>
<img src="images/monitor_go.png" title="Logout" alt="Logout"> Logout</tr></td></table>
</table>
<?php
}
}
}
else
{
echo '<br /><br /><br /><br /><br /><br /><br /><br /><br /><br />';
echo '<center><strong>Sorry, You have accessed this page improperly and your access has been logged.</strong></center>';
}
include_once('footer.php');
end;
?>
and the javascript file (only the relevant function):
// Exibit no.1
$(function() {
$(".button").click(function() {
// validate and process form here
$('.error').hide();
var domain = $("input#domain").val();
if (domain == "") {
$("label#domain_error").show();
$("input#domain").focus();
return false;
}
var com_domain = $("input#com_domain").val();
if (com_domain == "") {
$("label#com_domain_error").show();
$("input#com_domain").focus();
return false;
}
var cemail = $("input#cemail").val();
var port = $("select#port").val();
var active = $("input#active").val();
var uid = $("input#uid").val();
var main = $("select#main").val();
var dataString = 'cemail='+ cemail + '&domain=' + domain + '&com_domain=' + com_domain + '&active=' + active + '&main=' + main + '&port=' + port;
//alert (dataString);return false;
$.ajax({
type: "POST",
url: "user_add.php",
data: dataString,
success: function() {
$('#monitor_form').append("<div id='message'></div>");
$('#monitor_form form')[0].reset();
$('#message').html("<img id='checkmark' src='images/tick.png' /><b> Monitor sucessfully added!</b>")
.hide()
.fadeIn(500, function() {
$('#message').append("");
});
setTimeout("$('#message').hide().remove();", 6000);
var dataString2 = 'ajax=1&uid=' + uid;
$.ajax({
async: false,
type: "GET",
dataType: "html",
url: "monpanel.php",
data: dataString2,
success: function(html_data){
$('#list_monitors',top.document).html(html_data);
}
});
//document.onkeydown = showDown;
}
});
return false;
});
});
function showDown(evt) {
event = (evt)? evt : ((event)? event : null);
if (evt) {
if (event.keyCode == 8 && (event.srcElement.type!= "text" && event.srcElement.type!= "textarea" && event.srcElement.type!= "password")) {
// When backspace is pressed but not in form element
cancelKey(evt);
}
else if (event.keyCode == 116) {
// When F5 is pressed
cancelKey(evt);
}
else if (event.keyCode == 122) {
// When F11 is pressed
cancelKey(evt);
}
else if (event.ctrlKey && (event.keyCode == 78 || event.keyCode == 82)) {
// When ctrl is pressed with R or N
cancelKey(evt);
}
else if (event.altKey && event.keyCode==37 ) {
// stop Alt left cursor
return false;
}
}
}
function cancelKey(evt) {
if (evt.preventDefault) {
evt.preventDefault();
return false;
}
else {
evt.keyCode = 0;
evt.returnValue = false;
}
}
Thank you for any insight!
Do not forget to prevent the default handler:
<input type="submit" value="Send" onclick="myAjaxFunction(); return false" />
Does $(".button") have it's href set to #? If so, that'll refresh the page. I suggest using something like:
$(".button").click(function(e){
e.preventDefault();