Dynamic PHP Pagination Mysqli - javascript

I have tried dynamic pagination in php, I have implemented the code and that works fine too, but the real problem here is I get all page numbers in the URL I have already visited, maybe because I am using &pn in query string instead of ?pn, and I need to use &pn in my condition instead of ?pn so that I can fetch values of particular vendor type via $_GET
<!DOCTYPE html>
<html lang="en">
<?php
require "conn.php";
?>
<?php
$qryfav = "SELECT favicon FROM website_details WHERE website_id = 0";
$qfav = mysqli_query($conn, $qryfav);
$rowfav = mysqli_fetch_array($qfav);
?>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>BookYourEvents - Vendor List</title>
<link rel="shortcut icon" type="image/png" href="favicon_thumbnail/<?php echo $rowfav['favicon']; ?>" height = "16px" width = "16px">
<!-- fraimwork - css include -->
<link rel="stylesheet" type="text/css" href="assets/css/bootstrap.min.css">
<!-- icon css include -->
<link rel="stylesheet" type="text/css" href="assets/css/fontawesome-all.css">
<link rel="stylesheet" type="text/css" href="assets/css/flaticon.css">
<!-- carousel css include -->
<link rel="stylesheet" type="text/css" href="assets/css/slick.css">
<link rel="stylesheet" type="text/css" href="assets/css/slick-theme.css">
<link rel="stylesheet" type="text/css" href="assets/css/animate.css">
<link rel="stylesheet" type="text/css" href="assets/css/owl.carousel.min.css">
<link rel="stylesheet" type="text/css" href="assets/css/owl.theme.default.min.css">
<!-- others css include -->
<link rel="stylesheet" type="text/css" href="assets/css/magnific-popup.css">
<link rel="stylesheet" type="text/css" href="assets/css/jquery.mCustomScrollbar.min.css">
<link rel="stylesheet" type="text/css" href="assets/css/calendar.css">
<!-- color switcher css include -->
<link rel="stylesheet" type="text/css" href="assets/css/colors/style-switcher.css">
<link id="color_theme" rel="stylesheet" type="text/css" href="assets/css/colors/default.css">
<!-- custom css include -->
<link rel="stylesheet" type="text/css" href="assets/css/style.css">
</head>
<body class="default-header-p">
<!-- backtotop - start -->
<div id="thetop" class="thetop"></div>
<div class='backtotop'>
<a href="#thetop" class='scroll'>
<i class="fas fa-angle-double-up"></i>
</a>
</div>
<!-- backtotop - end -->
<!-- preloader - start -->
<div id="preloader"></div>
<!-- preloader - end -->
<!-- header-section - start
================================================== -->
<?php
include "header-1.php";
?>
<!-- header-section - end
================================================== -->
<!-- altranative-header - start
================================================== -->
<!-- altranative-header - end
================================================== -->
<!-- breadcrumb-section - start
================================================== -->
<!-- breadcrumb-section - end
================================================== -->
<!-- event-search-section - start
================================================== -->
<?php
$vendor_query_string = $_GET['vendor_type'];
echo $vendor_query_string."<br>";
$protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
$url = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
echo $url."<br>"; // Outputs: Full URL
?>
<section id="event-search-section" class="event-search-section clearfix" style="background-image: url(assets/images/special-offer-bg.png);">
<div class="container">
<div class="row">
<!-- section-title - start -->
<div class="col-lg-4 col-md-12 col-sm-12">
<div class="section-title">
<small class="sub-title">Find best event on BYE!</small>
<h2 class="big-title">Search<strong>Vendors</strong></h2>
</div>
</div>
<!-- section-title - end -->
<!-- search-form - start -->
<div class="col-lg-8 col-md-12 col-sm-12">
<div class="search-form form-wrapper">
<form action="user-side-list-view-search-vendors.php?vendor_type=<?php echo $vendor_query_string ; ?>" method="POST">
<ul>
<li>
<span class="title">Vendor Name</span>
<div class="form-item">
<input type="text" name="search" placeholder="Enter Vendor Name">
</div>
</li>
<li>
<button type="submit" name="submit_search" class="submit-btn">Search Vendor now</button>
</li>
</ul>
</form>
</div>
</div>
<!-- search-form - end -->
</div>
</div>
</section>
<!-- event-search-section - end
================================================== -->
<?php
//The First Query to get total count of rows
$qry = "SELECT COUNT(*) FROM vendor_detail INNER JOIN vendor_master ON vendor_detail.vendor_id = vendor_master.vendor_id WHERE vendor_type = '$vendor_query_string' AND vendor_is_active = 1";
$q = mysqli_query($conn, $qry);
$row = mysqli_fetch_row($q);
//Here we have the total row count
$rows = $row[0];
//This is the number of results we want to get display per page
$page_rows = 5;
//This tells us page number of our last page
$last = ceil($rows/$page_rows);
//This make sure last cannot be last then one
if ($last < 1)
{
$last = 1;
}
//Establish the $pagenum variable
$pagenum = 1;
//Get Pagenum from URL vars if it is present, else it is equal to 1.
if (isset($_GET['pn']))
{
$pagenum = preg_replace('#[^0-9]#','',$_GET['pn']);
}
//This makes sure that page number isnt below 1, or more than our last page
if($pagenum < 1)
{
$pagenum = 1;
}
elseif ($pagenum > $last)
{
$pagenum = $last;
}
//This sets the range of rows to query for the chosen $pagenum
$limit = 'LIMIT ' .($pagenum - 1) * $page_rows.',' .$page_rows;
//qry again but just for one page with limit
$qry = "SELECT * FROM vendor_detail INNER JOIN vendor_master ON vendor_detail.vendor_id = vendor_master.vendor_id WHERE vendor_type = '$vendor_query_string' AND vendor_is_active = '1' ORDER BY vendor_detail_id DESC $limit ";
$q = mysqli_query($conn, $qry);
//This shows the user what page they are on, and the total number of pages
$textline = "Page <b>$pagenum</b> of <b>$last</b>";
//Establish the pagination control Variables
$paginationctrls = '';
//If There is more than 1 page worth of results
if ($last!=1)
{
/* First we check if we are on page one. If we are then we don't need a link to the previous page or the first page so we do nothing. If we aren't then we generate links to the first page, and to the previous page.*/
if ($pagenum > 1)
{
$previous = $pagenum - 1;
$paginationctrls.='<li class="page-item prev-item"><a class="page-link" href="'.$url.'&pn='.$previous.'">Prev</a></li>';
//Render Clickable number links that should appear on the left of the target page number
for ($i=$pagenum - 4; $i < $pagenum; $i++)
{
if ($i > 0)
{
$paginationctrls.='<li class="page-item"><a class="page-link" href="'.$url.'&pn='.$i.'">'.$i.'</a></li> ';
}
}
}
//Render the target pagenumber, but without it being a link
$paginationctrls.='<li class="page-item active"><a class="page-link">'.$pagenum.'</a> </li>';
//Render the clickable number links that should appear on the right
for ($i=$pagenum+1; $i <= $last ; $i++)
{
$paginationctrls.='<li class="page-item "><a class="page-link" href="'.$url.'&pn='.$i.'">'.$i.'</a> </li> ';
if ($i>=$pagenum+4)
{
break;
}
}
//This does the same as above, only checking if we are on the last page, and then generating the "Next"
if ($pagenum != $last)
{
$next = $pagenum + 1;
$paginationctrls.=' <li class="page-item next-item"><a class="page-link" href="'.$url.'&pn='.$next.'">Next</a> </li>';
}
}
$list = '';
?>
<!-- event-section - start
================================================== -->
<section id="event-section" class="event-section bg-gray-light sec-ptb-100 clearfix">
<div class="container">
<div class="row">
<!-- sidebar-section - start -->
<div class="col-lg-3 col-md-12 col-sm-12">
<div class="sidebar-section">
<!-- Add to Calendar - start -->
<div title="Add to Calendar" class="addeventatc">
Add to Calendar
<span class="start">06/18/2015 09:00 AM</span>
<span class="end">06/18/2015 11:00 AM</span>
<span class="timezone">Europe/Paris</span>
<span class="title">Summary of the event</span>
<span class="description">Description of the event</span>
<span class="location">Location of the event</span>
<span class="organizer">Organizer</span>
<span class="organizer_email">Organizer e-mail</span>
<span class="all_day_event">false</span>
<span class="date_format">MM/DD/YYYY</span>
</div>
<!-- Add to Calendar - end -->
<!-- map-wrapper - start -->
<!-- map-wrapper - end -->
<!-- spacial-event-wrapper - start -->
<!-- spacial-event-wrapper - end -->
</div>
</div>
<!-- sidebar-section - end -->
<!-- - start -->
<div class="col-lg-9 col-md-12 col-sm-12">
<div class="search-result-form">
<ul class="nav event-layout-btngroup">
<li><a class="active" href=""><i class="fas fa-th-list"></i></a></li>
<li><i class="fas fa-th"></i></li>
</ul>
</div>
<div class="tab-content">
<div id="list-style" class="tab-pane fade in active show">
<?php
while ($row = mysqli_fetch_array($q))
{ ?>
<!-- event-item - start -->
<div class="event-list-item clearfix">
<!-- event-image - start -->
<div class="event-image">
<img src="../vendor/vendor_thumbnail/<?php echo $row['vendor_pic']; ?>" alt="Image_not_found">
</div>
<!-- event-image - end -->
<!-- event-content - start -->
<div class="event-content">
<div class="event-title mb-15">
<h3 class="title">
<strong> <?php echo $row['vendor_name']; ?></strong>
</h3>
</div>
<p class="discription-text mb-30">
<?php echo $row['vendor_description']; ?>
</p>
<div class="event-info-list ul-li clearfix">
<ul>
<li>
<span class="icon">
<i class="fas fa-user"></i>
</span>
<div class="info-content">
<small>Owner Name</small>
<h3> <?php echo $row['vendor_fname']." ".$row['vendor_lname'];?></h3>
</div>
</li>
<li>
<span class="icon">
<i class="fas fa-rupee-sign"></i>
</span>
<div class="info-content">
<small>Package Price</small>
<h3><?php echo $row['vendor_per_package_price']; ?></h3>
</div>
</li>
<li>
<a href="vendor-overview-details.php?vendor_detail_id=<?php echo $row['vendor_detail_id']?>" class="tickets-details-btn">
See More Details
</a>
</li>
</ul>
</div>
</div>
<!-- event-content - end -->
</div>
<!-- event-item - end -->
<?php
}
?>
</div>
<!-- event-item - end -->
<div>
<p><?php echo $textline ;?></p>
<p><?php echo $list ;?></p>
<div id="pagination controls"></div>
</div>
<div class="pagination ul-li clearfix">
<ul>
<?php echo $paginationctrls ;?>
</ul>
</div>
</div>
</div>
</div>
<!-- - end -->
</div>
</section>
<!-- event-section - end
================================================== -->
<!-- default-footer-section - start
================================================== -->
<?php
include "footer.php";
?>
<!-- default-footer-section - end
================================================== -->
<!-- fraimwork - jquery include -->
<script src="assets/js/jquery-3.3.1.min.js"></script>
<script src="assets/js/popper.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<!-- carousel jquery include -->
<script src="assets/js/slick.min.js"></script>
<script src="assets/js/owl.carousel.min.js"></script>
<!-- map jquery include -->
<script src="assets/js/gmap3.min.js"></script>
<script src="http://maps.google.com/maps/api/js?key=AIzaSyC61_QVqt9LAhwFdlQmsNwi5aUJy9B2SyA"></script>
<!-- calendar jquery include -->
<script src="assets/js/atc.min.js"></script>
<!-- others jquery include -->
<script src="assets/js/jquery.magnific-popup.min.js"></script>
<script src="assets/js/isotope.pkgd.min.js"></script>
<script src="assets/js/jarallax.min.js"></script>
<script src="assets/js/jquery.mCustomScrollbar.concat.min.js"></script>
<!-- gallery img loaded - jquery include -->
<script src="assets/js/imagesloaded.pkgd.min.js"></script>
<!-- multi countdown - jquery include -->
<script src="assets/js/jquery.countdown.js"></script>
<!-- color panel - jquery include -->
<!-- <script src="assets/js/style-switcher.js"></script> -->
<!-- custom jquery include -->
<script src="assets/js/custom.js"></script>
</body>
</html>
method, so can someone help with this query?

Related

PHP dynamic list retrieval returning Undefined index

I've been testing and playing around as part of personal practice, however, I got stuck in the below point where I want to add a list of items via javascript and upon submission, I want to verify and then store the added list. However, once I submit I get an error Unidentified index as if the value is not submitted as checked by isset function and it's always returning empty. After further looking in StackOverflow, I noticed some are referring to the HTML structure; hence, I minimized the HTML to look like the below :
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="assets/vendor/bootstrap/css/bootstrap.min.css">
<link href="assets/vendor/fonts/circular-std/style.css" rel="stylesheet">
<link rel="stylesheet" href="assets/libs/css/customeStyle.css">
<link rel="stylesheet" href="assets/libs/css/style.css">
<link rel="stylesheet" href="assets/vendor/fonts/fontawesome/css/fontawesome-all.css">
<title>Concept - Bootstrap 4 Admin Dashboard Template</title>
</head>
<body>
<!-- ============================================================== -->
<!-- main wrapper -->
<!-- ============================================================== -->
<?php //include("navBar.php"); ?>
<!-- ============================================================== -->
<!-- left sidebar -->
<!-- ============================================================== -->
<?php //include("SlideBar.php"); ?>
<!-- ============================================================== -->
<!-- end left sidebar -->
<!-- ============================================================== -->
<!-- ============================================================== -->
<?php
if(isset($_POST["submit"])){
//$test = $_POST["patName"];
if(isset($_POST["medAdded0"])){
//echo $value;
$listName= $_POST["medAdded0"];
echo '<script language="javascript">';
echo 'alert("'.$listName.'")';
echo '</script>';
echo $listName;
}else {
//echo $value;
echo '<script language="javascript">';
echo 'alert("still empty")';
echo '</script>';
echo $_POST["medAdded0"];
}
}
?>
<form action="#" method="POST">
<div class="row">
<div class="col-xl-8 col-lg-8 col-md-8 col-sm-12 col-12">
<div id="medListContainer" class="form-group">
</div>
</div>
</div>
<div class="col-lg-4">
<div class="card">
<h5 class="card-header">List of Medication</h5>
<div class="card-body">
<div class="list-group" id="pillsList">
<button class="list-group-item list-group-item-action" value="noor">Dapibus ac facilisis in</button>
<button class="list-group-item list-group-item-action" value="btn2">Morbi leo risus</button>
<button class="list-group-item list-group-item-action" value="btn3">Porta ac consectetur ac</button>
</div>
</div>
</div>
</div>
<input class="btn btn-success" type="submit" name="submit" value="Save">
</form>
<!-- Optional JavaScript -->
<!-- jquery 3.3.1 -->
<script src="assets/vendor/jquery/jquery-3.3.1.min.js"></script>
<!-- bootstap bundle js -->
<script src="assets/vendor/bootstrap/js/bootstrap.bundle.js"></script>
<!-- slimscroll js -->
<script src="assets/vendor/slimscroll/jquery.slimscroll.js"></script>
<!-- main js -->
<script src="assets/libs/js/main-js.js"></script>
<script>
var indexCounter=0;
$('#pillsList').on('click', function (e) {
e.preventDefault();
var targetList = document.getElementById("medListContainer");
var medValue= e.target.value;
if (indexCounter==10) {
//code
alert("you've exceeded your limit, please generate new ");
}else{
addMedList(medValue,targetList);
}
});
function addMedList(BtnValue,targetList) {
//function to place the list of selected medicaition
var btn = document.createElement("INPUT");
btn.innerHTML= BtnValue;
btn.className = "list-group-item list-group-item-action";
btn.setAttribute("value", BtnValue);
btn.setAttribute("id", 'medAdded' + indexCounter);
btn.setAttribute("name", 'medAdded' + indexCounter);
indexCounter++;
btn.setAttribute("type", "button");
targetList.appendChild(btn);
}
</script>
</body>
</html>
You've written:
if(isset($_POST["medAdded0"])){
//echo $value;
$listName= $_POST["medAdded0"];
echo '<script language="javascript">';
echo 'alert("'.$listName.'")';
echo '</script>';
echo $listName;
}else {
//echo $value;
echo '<script language="javascript">';
echo 'alert("still empty")';
echo '</script>';
echo $_POST["medAdded0"];
}
The else block is executed when $_POST["medAdded0"] is not set. So it makes no sense to try to echo it there. Get rid of the line
echo $_POST["medAdded0"];

Syntax Error 'SCRIPT1002' using Internet Explorer 11

SCRIPT1002: Syntax error
index.php, line 4 character 37
I got this error in IE11 and my .click() handlers are not working on the page where the error occurs (only in IE11). On lines 1 to 10 I got some standart meta tags so that shouldn't be the problem (I removed them and still received the error).
Because I got a lot of code and I don't know where exactly this error occurs. What's the best way to find the responsible code for this error?
Here is the index.php file referenced in the error:
<!DOCTYPE html>
<html lang="en">
<?php
include("database/connect.php");
include("modul/session/session.php");
$sql = "SELECT * FROM `tb_appinfo`;";
$result = $mysqli->query($sql);
if (isset($result) && $result->num_rows == 1) {
$appinfo = $result->fetch_assoc();
}
$sql = "SELECT * FROM `tb_ind_design` WHERE tb_user_ID = $session_userid;";
$result = $mysqli->query($sql);
if (isset($result) && $result->num_rows == 1) {
$row = $result->fetch_assoc();
}
?>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="<?php echo $appinfo["description"];?>">
<meta name="author" content="A.Person">
<title><?php echo $appinfo["title"];?></title>
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<!-- Custom styles for this template -->
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<?php
if (preg_match("/(Trident\/(\d{2,}|7|8|9)(.*)rv:(\d{2,}))|(MSIE\ (\d{2,}|8|9)(.*)Tablet\ PC)|(Trident\/(\d{2,}|7|8|9))/", $_SERVER["HTTP_USER_AGENT"], $match) != 0) {
echo '<link href="css/evaStyles_ie.css" rel="stylesheet">';
} else {
if(isset($row)){
echo '
<meta name="theme-color" content="'.$row["akzentfarbe"].'"/>
<style>
:root {
--hintergrund: '.$row["hintergrund"].';
--akzentfarbe: '.$row["akzentfarbe"].';
--schrift: '.$row["schrift"].';
--link: '.$row["link"].';
}
html {
--hintergrund: '.$row["hintergrund"].';
--akzentfarbe: '.$row["akzentfarbe"].';
--schrift: '.$row["schrift"].';
--link: '.$row["link"].';
}
</style>
<link href="css/evaStyles.css" rel="stylesheet">
';
} else {
echo '
<meta name="theme-color" content="'.$appinfo["akzentfarbe"].'"/>
<style>
:root {
--hintergrund: '.$appinfo["hintergrund"].';
--akzentfarbe: '.$appinfo["akzentfarbe"].';
--schrift: '.$appinfo["schrift"].';
--link: '.$appinfo["link"].';
}
html {
--hintergrund: '.$appinfo["hintergrund"].';
--akzentfarbe: '.$appinfo["akzentfarbe"].';
--schrift: '.$appinfo["schrift"].';
--link: '.$appinfo["link"].';
}
</style>
<link href="css/evaStyles.css" rel="stylesheet">
';
}
}
?>
</head>
<body>
<div class="loadScreen">
<span class="helper"></span><img class="img-responsive" id="loadingImg" src="img/loading.svg"/>
</div>
<div id="pageContents" style="opacity: 0;">
<!-- Navigation -->
<div id="naviLink">
<nav class="navbar navbar-expand-lg navbar-inverse bg-color fixed-top" id="slideMe" style="display: none;">
<div class="container">
<a class="navbar-brand" href="modul/dashboard/dashboard.php">
<img src="<?php echo $appinfo["logo_path"];?>" width="<?php echo $appinfo["logo_width"];?>" alt="Logo">
<span style="margin-left:20px;"><?php echo $appinfo["title"];?></span>
</a>
<button class="navbar-toggler custom-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<?php
$userID = ($mysqli->query("SELECT ID FROM tb_user WHERE bKey = '$session_username'")->fetch_assoc());
$sql1 = "SELECT mg.ID, mm.file_path, mm.title FROM tb_ind_nav AS mg INNER JOIN tb_modul AS mm ON mm.ID = mg.tb_modul_ID WHERE mg.tb_user_ID = " . $userID['ID'] . " ORDER BY mg.position";
$result = $mysqli->query($sql1);
if (isset($result) && $result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$link = '
<li class="nav-item">
<a class="nav-link" navLinkId="'. $row["ID"].'" href="'. $row["file_path"].'">'. $translate[$row["title"]].'</a>
</li>
';
echo $link;
}
} else {
$link = '
<li class="nav-item" id="editNavLink">
<a class="nav-link" href="modul/settings/settings.php">'. $translate[15].'</a>
</li>
';
echo $link;
}
?>
</ul>
</div>
</div>
</nav>
</div>
<!-- Page Content -->
<div class="container">
<div class="row">
<div class="col-lg-10 offset-md-1">
<div page="<?php if(isset($_SESSION["user"]["currentPath"])){ echo $_SESSION["user"]["currentPath"]; } else { echo "modul/dashboard/dashboard.php";} ?>" id="pageContent">
</div>
</div>
</div>
</div>
<!-- /.container -->
<footer class="footer" id="slideMeFoot" style="display: none;">
<div class="container">
<a class="foot-link" href="modul/settings/settings.php"><?php echo $translate[16] ?></a><i class="text-muted"> | <?php echo $_SESSION["user"]['username']; ?></i><span class="text-muted">© HTML Link | 2018 | <?php echo $appinfo["title"];?> v.1.0</span>
</div>
</footer>
</div>
<!-- Bootstrap core JavaScript -->
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ" crossorigin="anonymous"></script>
<!-- Own JS -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.19.1/moment.min.js"></script>
<script type="text/javascript">
var translate = {};
<?php
foreach ($translate as $key => $value) {
echo ("translate['".$key."'] = '".$value."';");
};
?>;
</script>
<script src="js/index.js"></script>
</body>
</html>
If you are using arrow syntax like value.foreach(param => {}); It can also cause this error in IE 11 since it does not understand shorthand functions. Need to change the function to be: value.foreach(function(param){});
The problem probably resides in your dashboard.js file. On line 4 you have a setInterval():
var id = setInterval(frame, speed, );
There is either a parameter missing or you accidentally added an extra comma.
To reproduce this you can include the dashboard.js file on any page and the syntax error will be displayed.

How to show message that user is already registered in html through php?

I have an HTML form in which a user enter his/her email id to register everything is working great it checks the valid email id and also registered the email id ! But when I applied new code to check that the user is already registered or not it didn't work !!
Below is my Html page
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Sign Up - MOBTRICKS</title>
<!-- CSS -->
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Lobster">
<link rel='stylesheet' href='http://fonts.googleapis.com/css?family=Lato:400,700'>
<link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="assets/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="assets/css/style.css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<!-- Favicon and touch icons -->
<link rel="shortcut icon" href="assets/ico/fa.png">
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="assets/ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="assets/ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="assets/ico/apple-touch-icon-57-precomposed.png">
<!-- <script type="text/javascript">
function greeting(){
alert("Welcome ! Your Email : " + document.forms["form"]["email"].value + " has been registered under our records successfully !")
}
</script> -->
</head>
<body>
<!-- Header -->
<div class="container">
<div class="row header">
<div class="col-sm-4 logo">
<h1><a href=#>PQR</a> <span>.</span></h1>
</div>
<div class="col-sm-8 call-us">
<p>Mob: <span>+91-9530803237</span> | email: <span>ab.creations27#gmail.com</span>
</p>
</div>
</div>
</div>
<!-- Coming Soon -->
<div class="coming-soon">
<div class="inner-bg">
<div class="container">
<div class="row">
<div class="col-sm-12">
<center>
<i class="fa fa-cog fa-spin fa-3x fa-fw"></i>
<span class="sr-only">Loading...</span>
<h2>We're Coming Soon</h2>
<p>We are working very hard on the new version of our site. It will bring a lot of new features. Stay tuned!</p>
<div class="timer">
<div class="days-wrapper">
<span class="days"></span>
<br>days
</div>
<div class="hours-wrapper">
<span class="hours"></span>
<br>hours
</div>
<div class="minutes-wrapper">
<span class="minutes"></span>
<br>minutes
</div>
<div class="seconds-wrapper">
<span class="seconds"></span>
<br>seconds
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Content -->
<div class="container">
<div class="row">
<div class="col-sm-12 subscribe">
<h3>Subscribe to our newsletter !!</h3>
<p>Sign up now to our newsletter and you'll be one of the first to know when the site is ready:</p>
<form class="form-inline" role="form" action="assets/subscribe.php" method="post">
<div class="form-group">
<label class="sr-only" for="subscribe-email">Email address</label>
<input type="text" name="email" placeholder="Enter your email..." class="subscribe-email form-control" id="subscribe-email">
</div>
<button type="submit" class="btn">Subscribe</button>
</form>
***
<div class="success-message"></div>
<div class="error-message"></div>***
</div>
</div>
<div class="row">
<div class="col-sm-12 social">
<i class="fa fa-facebook"></i>
<i class="fa fa-twitter"></i>
<a href="https://github.com/ashu271994" data-toggle="tooltip" data-placement="top" title="GitHub">
<i class="fa fa-github"></i>
</a>
<i class="fa fa-google-plus"></i>
<i class="fa fa-pinterest"></i>
<i class="fa fa-envelope-o"></i>
</div>
</div>
</div>
<!-- Footer -->
<footer id="footer">
<ul class="copyright">
<li>© ASHISH BHARWAL
</li>
<li>Credits: AB-Creations
</li>
</ul>
</footer>
<!-- Javascript -->
<script src="assets/js/jquery-1.11.1.min.js"></script>
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
ipt src="assets/js/jquery.backstretch.min.js"></script>
<script src="assets/js/jquery.countdown.min.js"></script>
<script src="assets/js/scripts.js"></script>
<!--[if lt IE 10]>
<script src="assets/js/placeholder.js"></script>
<![endif]-->
</body>
</html>
Below is my Subscriber.php page
<?php
// Email address verification
function isEmail($email)
{
return (preg_match("/^[-_.[:alnum:]]+#((([[:alnum:]]| [[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i", $email));
}
if ($_POST) {
// Enter the email where you want to receive the notification when someone subscribes
$emailTo = 'ab.creations27#gmail.com';
$subscriber_email = addslashes(trim($_POST['email']));
if (!isEmail($subscriber_email)) {
$array = array();
$array['valid'] = 0;
$array['message'] = 'Insert a valid email address!';
echo json_encode($array);
// $msg="wrong answer";
// echo "<script type='text/javascript'>alert('$msg');</script>";
} else {
$host = "somehostname";
$user = "username";
$pwd = "password";
$db = "demo1";
$conn = new PDO("mysql:host=$host;dbname=$db", $user, $pwd);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
try {
$sql_insert = "SELECT * FROM demotable WHERE subs='$subscriber_email'";
$stmt1 = $conn->prepare($sql_insert);
$stmt1->execute();
$result = $stmt1->fetchColumn();
if ($result == 0) {
$sql_insert = "INSERT INTO demotable (subs)
VALUES ('$subscriber_email')";
$stmt = $conn->prepare($sql_insert);
$stmt->execute();
$array = array();
$array['valid'] = 1;
$array['message'] = "Your Email : $subscriber_email has been registered with us ! Thanks for your subscription!";
echo json_encode($array);
} else {
$array = array();
$array['valid'] = 2;
$array['message'] = "You are already registered !!";
echo json_encode($array);
}
}
catch (Exception $e) {
die(var_dump($e));
}
}
}
?>
Now what is happening when I tried to add an invalid email id then it shows Invalid Email id in marked in HTML page but when I added a new user then add the data in my table and show message but in case of the user who is already registered it didn't show any message !! I also tried to make new functions having "echo json_encode($array)"; But this also won't work !! Tell me what am I missing or what's my mistake !! I am trying to sort it from the last 3 days !!
my scripts.js code below
$('.subscribe form').submit(function(e) {
e.preventDefault();
var postdata = $('.subscribe form').serialize();
$.ajax({
type: 'POST',
url: 'assets/subscribe.php',
data: postdata,
dataType: 'json',
success: function(json) {
if(json.valid == 0) {
$('.success-message').hide();
$('.error-message').hide();
$('.error-message').html(json.message);
$('.error-message').fadeIn();
}
else if (json.valid == 1){
$('.error-message').hide();
$('.success-message').hide();
$('.subscribe form').hide();
$('.success-message').html(json.message);
$('.success-message').fadeIn();
}
else {
$('.error-message').hide().empty();
$('.success-message').hide().empty();
$('.subscribe form').hide();
$('.success-message').html(json.message);
$('.success-message').fadeIn();
}
}
});
});
Try changing
$result = $stmt1->fetchColumn();
to
$result = $stmt1->num_rows;
see if that works.
Finally got it working. The error was simple but yet difficult to find. lolz
$sql_insert = "SELECT * FROM demotable WHERE subs='$subscriber_email'";
should be like
** $sql_insert = "SELECT COUNT(*) FROM demotable WHERE subs='$subscriber_email'";**
Thank you all for your views. :)

BX slider images not loading properly

<?php $x = $_GET['house_id']; ?>
<?php include 'connection.php';?>
<?php
$queryz = "SELECT * FROM photos WHERE id = $x";
$link = mysqli_query($conn, $queryz);
$lattitude = "SELECT latitude FROM location WHERE id=$x";
$lt = mysqli_query($conn,$lattitude) ;
$longitude = "SELECT longitude FROM location WHERE id=$x";
$lg = mysqli_query($conn,$longitude) ;
?>
<?php
include 'connection.php';
// Create connection
$queryz = "SELECT * FROM photos WHERE id = $x";
$link = mysqli_query($conn, $queryz);
$sql_1 = "SELECT * FROM house_info WHERE id = $x";
$result_1 = mysqli_query($conn,$sql_1);
$info = mysqli_fetch_array($result_1);
$city=$info['city'];
$type=$info['type'];
$location=$info['location'];
$landmark=$info['landmark'];
$gender=$info['gender'];
$address=$info['address'];
?>
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="assets/js/jquery-2.1.0.min.js"></script>
<!--<link href="../../fonts/font-awesome.css" rel="stylesheet" type="text/css">-->
<!--<link href='http://fonts.googleapis.com/css?family=Roboto:700,400,300' rel='stylesheet' type='text/css'>-->
<!--<link href="../../bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css">-->
<!--<link href="../../css/style.css" rel="stylesheet" type="text/css">-->
<!-- bxSlider Javascript file -->
<script src="assets/js/jquery.bxslider.min.js"></script>
<!-- bxSlider CSS file -->
<link href="assets/css/jquery.bxslider.css" rel="stylesheet" type="text/css" />
<style>
#map-simple { min-height: 240px; }
</style>
<title><?php echo $location;?></title>
</head>
<body class="external">
<div id="item-detail" class="content-container">
<div class="row">
<div class="col-md-8">
<div class="inner">
<!--<div class="items-switch">
<img src="ourhousesassets/img/arrow-left.png">
<img src="ourhousesassets/img/arrow-right.png">
</div>-->
<article class="animate move_from_bottom_short">
<div class="gallery">
<div class="image">
<ul class="bxslider">
<li><img height='100%' width='100%' src="addhouse/images_upload/1_1.jpg"/></li>
<li><img height='100%' width='100%' src="addhouse/images_upload/1_2.jpg"/></li>
<li><img height='100%' width='100%' src="addhouse/images_upload/1_3.jpg"/></li>
<li><img height='100%' width='100%' src="addhouse/images_upload/1_4.jpg"/></li>
</ul>
</div>
</div>
</article>
<article class="animate move_from_bottom_short">
<h1><?php echo $type;?>BHK Flat, <?php echo $location;?></h1>
<h2><i class="fa fa-map-marker"></i>Near <?php echo $landmark;?></h2>
<figure class="price average-color"><span><?php echo $gender;?></span></figure>
<figure class="price average-color"><span>Availability: <?php include './ourhousesassets/totalavailability.php';?></span></figure>
</article>
<!--end Description-->
<article class="sidebar">
<div class="person animate move_from_bottom_short">
<div class="inner average-color">
<!--<figure class="person-image">
<img src="ourhousesassets/img/person-01.jpg" alt="">
</figure>-->
<header>Address</header>
<a><?php echo $address;?></a><br>
<a>Near <?php echo $landmark;?></a>
<hr>
<b>Check Rents/Availability</b>
</div>
<?php include './ourhousesassets/getroomwiserent.php';?>
</div>
<!--end .person-->
<div class="block animate move_from_bottom_short">
<dl>
<dt>Bedrooms</dt>
<dd><?php echo $type;?></dd>
<dt>Locality</dt>
<dd><?php echo $location;?></dd>
<dt>Gender</dt>
<dd><?php echo $gender;?></dd>
</dl>
</div>
<div class="block animate move_from_bottom_short">
<dl>
<h2>Bills covered</h2><hr class="one">
<dt>Electricity</dt>
<dd><b><font color="#3fe173">✔</font></b></dd>
<dt>WiFi</dt>
<dd><b><font color="#3fe173">✔</font></b></dd>
<dt>DTH</dt>
<dd><b><font color="#3fe173">✔</font></b></dd>
<dt>Maintenance</dt>
<dd><b><font color="#3fe173">✔</font></b></dd>
<dt>Gas Connection</dt>
<dd><b><font color="#3fe173">✔</font></b></dd>
</dl>
</div>
</article>
<!--end Sidebar-->
<?php include './ourhousesassets/getfurniturelist.php';?>
<?php include './ourhousesassets/getapplianceslist.php';?>
<?php include './ourhousesassets/getamenitieslist.php';?>
<article>
<h3>Map</h3>
<div id="map-simple"></div>
</article>
</div>
</div>
<!--end .col-md-8-->
</div>
<!--end .row-->
</div>
<!--end #item-detail-->
<script type="text/javascript">
$(document).ready(function(){
$('.bxslider').bxSlider({
adaptiveHeight: true,
mode: 'fade'
});
});
</script>
<script>
var _latitude = <?php while($latt = mysqli_fetch_array($lt)){echo $latt['latitude'];}?>;
var _longitude = <?php while($lng = mysqli_fetch_array($lg)){echo $lng['longitude'];}?>;
var draggableMarker = false;
var scrollwheel = false;
var element = document.querySelector('body');
if( hasClass(element, 'external') ){
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = "http://homigo.in/ourhousesassets/js/external.js";
head.appendChild(script);
}
else {
simpleMap(_latitude, _longitude,draggableMarker, scrollwheel);
rating();
averageColor( $('.content-container') );
}
function hasClass(element, cls) {
return (' ' + element.className + ' ').indexOf(' ' + cls + ' ') > -1;
}
</script>
</body>
</html>
The code above uses bx slider to display four images and it's not working properly. The slides are loading, and navigating but the images are not of ful sizes. They're cropped within the div and has not smooth navigation. Please let know if any java script or any other file causing the hindrance for the slider from working properly.

Getting "is not defined" loading a function from external javascript

I have two files: index.php and local.js.
This is index.php:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link rel="shortcut icon" href="../../docs-assets/ico/favicon.png">
<!-- FontAwesome: font-set designed for Bootstrap -->
<link href="css/font-awesome.css" rel="stylesheet">
<title>Befair-Timetracker</title>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="css/time.css" rel="stylesheet">
<!-- Template HTML to build up a new row on the table -->
<!-- Just for debugging purposes. Don't actually copy this line! -->
<!--[if lt IE 9]><script src="../../docs-assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
</head>
<body>
<?php
//include("dbconn.php");
?>
<div class="navbar navbar-inverse navbar-fixed-top navbar-time" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle navbarbtn" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Timetracker</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active">Tracking</li>
</ul>
<form class="navbar-form navbar-right">
<div class="form-group">
<input type="text" placeholder="Email" class="form-control input-sm">
</div>
<div class="form-group">
<input type="password" placeholder="Password" class="form-control input-sm">
</div>
<button type="submit" class="btn btn-success">Sign in</button>
</form>
</div><!--/.navbar-collapse -->
</div>
</div>
<!-- Main jumbotron for a primary marketing message or call to action -->
<div class="jumbotron jumbotime">
<div class="container">
<h1 class="time">Timetracker management</h1>
<p class="timepar">Nella tabella sottostante verranno inserite la varie attività, classificabili in base al proprio CH e agli utenti che le svolgono.</p>
<!--<p><a class="btn btn-primary btn-lg" role="button">Learn more »</a></p>-->
</div>
</div>
<div class="container">
<h3 class="time">Risultati attesi</h3>
<hr>
<div class="selection"> <!-- inserire well nella classe per ottenere riquadro blu -->
<span class="titolosel">Centro di costo</span>
<select class="form-control selecttime">
</select>
</div>
<hr>
<!-- Table containing the info about CH, users and RA -->
<table id ="timetable" class="table table-striped">
<thead>
<tr>
<th>Id</th>
<th>Name</th>
<th>Users</th>
<th>Activities</th>
<th>Timer</th>
</tr>
</thead>
<tbody class="ra hide">
</tbody>
</table>
<footer>
© BeFair 2013 - Website developed by Riccardo Pancotti
<div class="pull-right">
<!--<img src="images/beFair.jpg" alt="beFair-logo" class="img-rounded imglogo">-->
</div>
</footer>
</div> <!-- /container -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="js/jquery-1.10.2.min.js"></script>
<script src="js/bootstrap.js"></script>
<script type="text/javascript" src="js/jquery.tmpl.min.js"></script>
<script type="text/javascript" src="js/jquery.tablesorter.min.js"></script>
<script type="text/javascript" src="js/local.js"></script>
<script type="text/javascript" charset="utf-8">
//**ANIMATED DIV/TABLE/TIMER**
function showact(ID){
$(".tr-act"+ID).animate({"height": "toggle"}, { duration: 300 });
//$(".hide").animate({"display":"toggle"}, { duration: 300 });
}
</script>
<script type="text/javascript" charset="utf-8">
//**LOADING JSON**
$(document).ready(function()
{
starttimer(2);
$.getJSON('js/test2.json', function(json) {
$.each(json.ch,function(key,val)
{
var chname=("<option value="+val.name+">"+val.name+"</option>");
$(".selecttime").append(chname);
});
});
});
</script>
<script type="text/javascript" charset="utf-8">
//$(document).ready(startimer(4));
//**CENTRO DI COSTO SELECTION**
$('.selecttime').change(function()
{
var pippo = "";
console.clear();
//setValue();
var pippo = $('.selecttime').val();
var chtable=("<tbody class=\"ra\"><tr>");
$.ajaxSetup( { "async": false } ); //Chiamata asincrona al server per il JSON
$.getJSON('js/test3.json', pippo,function(json) {
for (var i = 0, len = json.ch.length; i < len; i++) {
var namera = json.ch[i].name;
console.log(namera);
if (pippo === namera)
{
console.log("RA " +json.ch[i].ra_list.length);
for (var k = 0, lungh = json.ch[i].ra_list.length; k < lungh; k++)
{
//CICLO PER AGGIUNGERE NUOVE RA
var print = json.ch[i].ra_list[k];
chtable +=("<td>"+print.id+"</td>");
chtable +=("<td>"+print.name+"</td>");
chtable +=("<td>"+print.users+"</td>");
//***VECCHIA RIGA, MOSTRA TIMER***
//chtable +="<td><i class=\"fa fa-plus-square\"></i></td>";
//********************************
chtable +="<td class=\"timertd\"><i class=\"fa fa-plus-square\">+</i></td>";
chtable +="<td></td>";
console.log("Attività " + print.activities.length);
tract = "";
list_act = "";
count = 0;
for (var j = 0, lungh_in = json.ch[i].ra_list[k].activities.length; j < lungh_in; j++)
{
//CICLO PER AGGIUNGERE NUOVE ATTIVITA'
list_act += ("<tr style=\"display:none\" class=\"tr-act"+k+"\">");
list_act += "<td></td><td></td><td></td>";
list_act += "<td>";
list_act += print.activities[j].name;
list_act += "</td>";
list_act += "<td>" + "setValue()" + "</td>";
list_act += ("</tr>");
count++;
}
chtable += list_act;
chtable += "</tr>";
$(".ra").replaceWith(chtable);
}
}
}
});
});
</script>
</body>
</html>
And this is local.js:
var starttimer = function(idt)
{
alert(idt);
};
I'm trying to call this function here (it's part of the index.html):
<script type="text/javascript" charset="utf-8">
//**LOADING JSON**
$(document).ready(function()
{
starttimer(2);
$.getJSON('js/test2.json', function(json) {
$.each(json.ch,function(key,val)
{
var chname=("<option value="+val.name+">"+val.name+"</option>");
$(".selecttime").append(chname);
});
});
});
</script>
but it keeps telling me "function is not defined".
What's the problem?
Probably it's something about the scope but i don't know what.
Solved, i was refering to the wrong file.

Categories

Resources