AngularJs is not working after calling a php file - php

I am using AngularJS in header.php and create_test.php files. It is working fine when I execute the files separately.
Then I am calling this header.php create_test.php file.
After calling create_test.php file AngularJS codes are not working.
Why is it so? Can anyone assist me to solve this?
In header.php file,
<?php
//calling methods of methods.php file
include'C:/wamp64/www/performance/header/src/demo/methods.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="shortcut icon" type="image/png" href="http://localhost/performance/login/images/merahkee.png" />
<title> Merahkee Technology Soluctions</title>
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<!-- SmartMenus jQuery Bootstrap 4 Addon CSS -->
<link href="../addons/bootstrap-4/jquery.smartmenus.bootstrap-4.css" rel="stylesheet">
<!--Angularjs-->
<script data-require="angular.js#*" data-semver="1.6.9" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.7/angular.js"></script>
<!--This version is for title attribute-->
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.9/angular.js"></script>
<!--Angularjs starts-->
<script src="http://localhost/performance/header/src/addons/bootstrap-4/header.js"></script>
</head>
<body style="padding-top:80px;">
<!-- Navbar -->
<nav class="navbar navbar-expand-lg fixed-top navbar-dark bg-dark">
<div ng-app="rootApp" class="container">
<a ng-app = "firstApp" ng-controller = "firstController" class="navbar-brand" href="#">{{ pageTitle }}</a>
<div class="collapse navbar-collapse" id="navbarNavDropdown">
<!-- Left nav -->
<ul class="nav navbar-nav mr-auto">
<!--Display project dropdown-->
<li ng-app = "thirdApp" ng-controller = "thirdController" class="nav-item dropdown" style="padding-right:15px;" ><a class="nav-link dropdown-toggle" href="#">{{Project}}</a>
<ul class="dropdown-menu">
<?php
echo '<li><a class="dropdown-item">Recent Projects </a></li>';
for($i=0;$i<$projectcount;$i++){
//calling test_name() method and storing those values in a string
$test=project_name($count_uid,$user_id,$pro_sql);
$project_name=$test[$i];
if(strlen($project_name)>=25){
$projectName=substr($project_name,0,25);
$projectName=$projectName.'..';
}
else{
$projectName=$project_name;
}
echo'<li><a class="dropdown-item" href="http://localhost/performance/project/ShowTest_of_project.php?project_name='.$project_name.'&user_id='.$user_id.'" title="'.$project_name.'">'.$projectName.'</a></li>';
}//for loops ends
//show all projects
echo'<li ng-app = "seventhApp" ng-controller = "seventhController"><a ng-repeat="x in sdc_pro" class="dropdown-item" href="{{x.href}}'.$user_id.'">{{x.name}}</a></li>';
?>
</ul><!--dropdown-menu closes-->
</li><!--project dropdown ends-->
<li ng-app = "fourApp" ng-controller = "fourController" class="nav-item dropdown"><a style="padding-right:15px;" class="nav-link dropdown-toggle" href="#">{{Test}}</a>
<ul class="dropdown-menu">
<?php
echo '<li><a class="dropdown-item">Recent Tests </a></li>';
for($i=0;$i<$testcount;$i++){
//calling test_name() method and storing those values in a string
$test1=recent_test1($test_sql);
$test_name1=$test1[$i];
//project name
$project=recentTest_project($test_sql);
$project_name=$project[$i];
//platform file name
$platform=platform_file();
$platform_file=$platform[$i];
//project id
$project_id=pro_id($test_sql);
$pro_id=$project_id[$i];
//calling file_name() method and storing those values in a string
//$file=load_file_name();
//$file_name=$file[$i];
//echo' <a type="submit" name="testname" href='.$file_name.'>'.$test_name.'</a><br>';
if(strlen($test_name1)>=25){
$testName=substr($test_name1,0,25);
$testName=$testName.'..';
}
else{
$testName=$test_name1;
}
echo'<li><a class="dropdown-item" href="http://localhost/performance/RunTest_09.php?test_name='.$test_name1.'&project_name='.$project_name.'" title="'.$test_name1.'">'.$testName.'</a></li>';
}//for loops ends
//show all projects ,delete project and create project
echo'<li ng-app = "eighthApp" ng-controller = "eigthController"><a ng-repeat="x in sdc_test" class="dropdown-item" href="{{x.href}}'.$user_id.'">{{x.name}}</a></li>';
?>
</ul>
</li><!--test dropdown ends-->
<li ng-app = "fifthApp" ng-controller = "fifthController" class="nav-item dropdown"><a class="nav-link dropdown-toggle" href="#">{{Report}}</a>
<ul class="dropdown-menu">
<li></li>
</ul>
</li><!--report list ends-->
</ul>
<ul class="nav navbar-nav">
<li ng-app = "sixthApp" ng-controller = "sixthController" class="nav-item dropdown"><a class="nav-link dropdown-toggle" href="#">{{default}}</a>
<ul class="dropdown-menu">
<li><a ng-repeat="x in details" class="dropdown-item" href="{{x.href}}">{{x.name}}</a></li>
</ul>
</li>
</ul>
</div><!--collapse navbar-collapse-->
</div>
</nav>
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>
<!-- SmartMenus jQuery plugin -->
<script type="text/javascript" src="http://localhost/performance/header/src/jquery.smartmenus.js"></script>
<!-- SmartMenus jQuery Bootstrap 4 Addon -->
<script type="text/javascript" src="http://localhost/performance/header/src/addons/bootstrap-4/jquery.smartmenus.bootstrap-4.js"></script>
</body>
</html>
In cteate_test file,
<?php
include_once 'C:\xampp\htdocs\Performance\header\src\demo\header.php';
include_once 'C:\xampp\htdocs\Performance\project\methods\methods.php';
?>
<!DOCTYPE html>
<html>
<head>
<script>
function ConfirmDelete() {
return confirm("Are you sure you want to delete?");
}
</script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<link rel="stylesheet" href="http://localhost/performance/project/css/showAllProject.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<!--Angularjs-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.9/angular.js"></script>
<script >
var app = angular.module("myApp", []);
app.controller("namesCtrl", function($scope) {
$scope.names = [
{name:'PROJECT'},
{name:' |DESCRIPTION'},
{name:' |CREATEDON'},
{name:' |LASTUPDATED'},
{name:' |'},
]
$scope.hrefs = [
{href:'http://localhost/performance/deleteProject_showAll_pro.php?project_name=',src:'http://localhost/performance/css/delete.png',title:'delete',alt:'delete',onclick:'return ConfirmDelete()'},
{href:'http://localhost/performance/editProject_form.php?project_name=',src:'http://localhost/performance/css/edit.ico',title:'edit',alt:'edit',onclick:''},
{href:'http://localhost/performance/copyProject_form.php?project_name=',src:'http://localhost/performance/css/copy_pro.png',title:'copy',alt:'edit',onclick:''},
]
});
</script>
</head>
<body style="font-size:12px;">
<div class="row">
<div class="container">
<div class="col-lg-10" id="col-lg-14" >
</div>
<div ng-app="myApp" ng-controller ="namesCtrl" class="row vertical-center-row" id="myApp">
<div class="col-lg-20" id="myApp-main">
<div class="row">
<div ng-repeat="x in names" class="col" id="col">
{{x.name}}
</div>
</div>
</div>
<div class="col-lg-12" id="project" >
<?php
for($i=0;$i<$procount;$i++){
//calling test_name() method and storing those values in a string
$project=project_name1($user_id);
$project_name=$project[$i];
//description
$desctipt=project_description1($user_id);
$description=$desctipt[$i];
// project creation date
$date=ProjectCreated_date($user_id);
$created_on=$date[$i];
//project edited on
$editDate=ProjectEdited_date($user_id);
$edited_on=$editDate[$i];
//for displaying the project
if(strlen($project_name)>=25){
$projectName=substr($project_name,0,25);
$projectName=$projectName.'..';
}
else{
$projectName=$project_name;
}
//for displaying the description of the project
if(strlen($description)>=25){
$description=substr($description,0,25);
$description=$description.'..';
}
else{
$description=$description;
}
//display project name, discription,created date and deleted date date
echo '<div class="row" id="row" ng-mouseover="changeImage=true" ng-mouseleave="changeImage=false" ng-init="changeImage=false">';
//projectName
echo'<div class="col">';
echo $projectName;
echo '</div>';
//description
echo'<div class="col" >';
echo $description;
echo '</div>';
//created date
echo'<div class="col" >';
echo $created_on;
echo '</div>';
//last updated date
echo'<div class="col" >';
echo $edited_on;
echo '</div>';
//
echo'<div class="col col-sm-1" ng-repeat="x in hrefs">';
echo '
<img src="{{x.src}}" title="{{x.title}}" alt="{{x.alt}}" style="width:15px;height:15px;border:0;" Onclick=""/>';
//<img ng-show="changeImage" src="http://localhost/performance/css/edit.ico" title="edit" alt="running test" style="width:15px;height:15px;border:0;margin-left:0.5cm">
//<img ng-show="changeImage" src="http://localhost/performance/css/copy_pro.png" title="copy" alt="running test" style="width:15px;height:15px;border:0;margin-left:0.5cm"/>';
echo '</div>';
echo'</div>';//display project name, discription,created date and deleted date date div ends
echo '<hr id="hr">';}//for loop ends
?>
</div> <!--project div ends-->
<div class="col-lg-12" id="createProject" >
<center><img src="http://localhost/performance/css/create.png" title="Create Test" alt="Create New Project" id="createProjectIMG"></center>
</div>
</div><!--myApp div ends-->
</div><!--container-fluid div ends-->
</div><!--row div ends-->
</body>
</html>

Related

Removing one item from cart removes everything instead

I have a implemented a shopping cart function on my project website by following this guide video on YT https://www.youtube.com/watch?v=eAK8uYtNTy4&t=3528s and I am able to add items to the shopping cart and remove items(kind of). However the remove function is very odd indeed,because it allows me to remove the item but when I clicked on it it also removes other items that is currently in the cart as well...
Here are my codes for the cart (cart.php)
<?php
session_start();
require_once ("conn.php");
require_once ("component.php");
if (isset($_POST['remove'])){
if ($_GET['action'] == 'remove'){
foreach ($_SESSION['cart'] as $key => $value){
if($value["ID"] == $_GET['game_ID']){
unset($_SESSION['cart'][$key]);
echo "<script>alert('Product has been Removed...!')</script>";
echo "<script>window.location = 'cart.php'</script>";
}
}
}
}
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Cart</title>
<link rel="icon" href= "images/logoonly.png" type="image/jpg" sizes="16x16">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/cart.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="js/sticky.js"></script>
<script src="https://kit.fontawesome.com/ac84272c35.js" crossorigin="anonymous"></script>
</head>
<body>
<!-- Navigation -->
<navbar>
<section class="navbar-section" style="background-color: #252525; box-shadow: 0px 2px 6px black;">
<div class="navbar-div">
<div class="navbar-div-logo">
<a href="index.html">
<img href="index.html" class="logo-pic" src="images/logoonly.png" alt="">
<img class="logo-name" src="images/logonameonly.png" alt="">
</a>
</div>
<ul class="navbar-ul-links">
<li> <a class="navbar-a-links" href="index.html">home</a> </li>
<li> <a class="navbar-a-links" href="store.php">store</a> </li>
<li> <a class="navbar-a-links" href="news.html">news</a> </li>
<li> <a class="navbar-a-links" href="about.html">about</a> </li>
</ul>
<div class="navbar-div-cart-login">
<i class="fas fa-shopping-bag"></i>
<a class="login navbar-a-links" href="login.html">login</a>
</div>
</div>
</section>
</navbar>
<!-- /Navigation -->
<!-- Main Content -->
<?php
$total = 0;
if (isset($_SESSION['cart'])){
$ID = array_column($_SESSION['cart'], 'game_ID');
include("conn.php");
$result = mysqli_query($con,"Select * from games where games.game_status = 1");
while($row = mysqli_fetch_array($result)){
foreach ($ID as $game_ID){
if ($row['game_ID'] == $game_ID){
cartElement( $row['game_name'],$row['game_price'], $row['game_ID']);
$total = $total + (int)$row['game_price'];
}
}
}
}else{
echo "<h5>Cart is Empty</h5>";
}
?>
</section>
<!-- /Main Content -->
<!-- Footer -->
<footer>
<section class="footer-section" style="background-color: black;">
</section>
</footer>
<!-- /Footer -->
<script src="js/modal.js"></script>
<!-- Animate Show Panel -->
<script type="text/javascript">
function show(elementId) {
document.getElementById("personal-info").style.display = "none";
document.getElementById("acc-info").style.display = "none";
document.getElementById(elementId).style.display = "flex";
}
</script>
<!-- /Animate Show Panel -->
</body>
</html>
here are the components for the cart to display the items. (component.php)
<?php
function component($game_name, $game_price, $game_ID){
$element = "
<form action=\"store.php\" method=\"post\">
<div class=\"newrelease\">
<div class=\"special-offer-description-div\">
<h5 name=\"game_name\">$game_name</input></h5>
<button type=\"submit\" class=\"purchase\" name=\"add\">Add To Cart</button>
<input type='hidden' name='game_ID' value='$game_ID'>
<div class=\"price-div\">
<h6>- 85%</h6>
<p class=\"strikethrough\" name=\"game_price\">RM$game_price</p>
</div>
</div>
</div>
</form>
";
echo $element;
}
function cartElement($game_name, $game_price, $game_ID){
$element = "
<form action=\"cart.php?action=remove&id=$game_ID\" method=\"post\">
<section class=\"cart-section\">
<div class=\"block\"></div>
<div class=\"cart-div\">
<h1>$game_name</h1>
<!-- Cart Games -->
<div class=\"cart-items-div\">
<div class=\"description-div\">
<div class=\"description\">
<!-- Game Name -->
<h2 class=\"game-title\"></h2>
<!-- Game Description -->
<div class=\"d\">
<div class=\"details\">
<h2>overall reviews:</h2>
<h2>release date:</h2>
</div>
<div class=\"game-details\">
<h2 style=\"color: #407AD3;\">very positive</h2>
<h2>8 aug, 2018</h2>
</div>
</div>
<!-- Game Specification -->
<div class=\"compatibility\">
<i class=\"fab fa-windows\"></i>
<i class=\"fab fa-apple\"></i>
<i class=\"fab fa-linux\"></i>
</div>
</div>
<div class=\"button-div\">
<!-- Remove Game From Cart Button -->
<button type=\"submit\" class=\"btn btn-danger mx-2\" name=\"remove\"><i class=\"fas fa-trash-alt\" style=\"color: #FF4444\" ></i> </button>
<!-- Purchase Game -->
<button class=\"purchase\" input type=\"text\" value=\"1\">Purchase</button>
<!-- Price -->
<h3 style=\"border-right: none;\">$game_price</h3>
</div>
</div>
</div>
</form>
";
echo $element;
}

$_SESSION['login_user'] not workig

I'm trying to figuring out what the problem but I can't.
Basically I have the index.php with a login to an admin area and admin.php that Is the main page of the admin area.
If I remove the SESSION from the admin.php page the login itself works but I can reach the page admin.php without logging into index, but if I add the SESSION to admin.php after the login it goes straight to the else at the end of the admin.php page.
For sure I'm failing something with the SESSION but I don't know what.
Index.php
<!DOCTYPE html>
<html lang="en">
<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">
<link rel="icon" type="image/png" href="images/favico.png">
<title>eWaste</title>
<!-- Font Awesome -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Material Design Bootstrap -->
<link href="css/mdb.min.css" rel="stylesheet">
<!-- Your custom styles (optional) -->
<link href="css/style.css" rel="stylesheet">
<style>
html{
margin-top: 100px;
}
</style>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light grey lighten-5 fixed-top">
<div class="container">
<a class="navbar-brand" href="../index.php">
<img src="../images/logo.png" height="30" class="d-inline-block align-top" alt="">
</a>
<button class="navbar-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 justify-content-end" id="navbarResponsive">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" id="navi-current" href="index.php">Admin</a>
</li>
</ul>
</div>
</div>
</nav>
<!-- Navbar -->
<!--Main-->
<main class="mb-4 pb-5">
<div class="container">
<div class="row">
<div class="col-xl-4 col-lg-4 col-md-3"></div>
<div class="col-xl-4 col-lg-4 col-md-6">
<form class="text-center border border-light p-5" method="post" name="">
<p class="h4 mb-4">Sign in</p>
<!-- Email -->
<input type="text" id="materialContactFormUsername" class="form-control" placeholder="User" name="formuser">
<!-- Password -->
<input type="password" id="defaultLoginFormPassword" class="form-control mb-4" placeholder="Password" name="formpass">
<!-- Login button -->
<button class="btn btn-info btn-block my-4" type="submit" name="submit">Sign in</button>
</form>
</div>
<div class="col-xl-4 col-lg-4 col-md-3"></div>
</div>
</div>
</main>
<!--/.Main-->
<?php
if (isset($_POST['submit']))
{
include 'conn.php';
session_start();
$user = $_POST['formuser'];
$pass = $_POST['formpass'];
$query = mysqli_query($conn, "SELECT user FROM login WHERE user='$user' and pass='$pass'");
if (!$query) {
die('Invalid query: ' . mysqli_error());
}
if (mysqli_num_rows($query) != 0){
$_SESSION['login_user']=$username;
header("Location: admin.php");
}
else{
echo "<script type='text/javascript'>alert('User Name Or Password Invalid!')</script>";
}
mysqli_close($conn);
}
?>
<!--Footer-->
<?php include 'footer.php';?>
<!--/.Footer-->
<!-- SCRIPTS -->
<!-- JQuery -->
<script type="text/javascript" src="js/jquery-3.3.1.min.js"></script>
<!-- Bootstrap tooltips -->
<script type="text/javascript" src="js/popper.min.js"></script>
<!-- Bootstrap core JavaScript -->
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<!-- MDB core JavaScript -->
<script type="text/javascript" src="js/mdb.min.js"></script>
<!-- Initializations -->
<script type="text/javascript">
// Animations initialization
new WOW().init();
</script>
</body>
Admin.php
<?php
if (isset($_SESSION['login_user'])){
session_start();
echo "ok";
?>
<!DOCTYPE html>
<html lang="en">
<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">
<link rel="icon" type="image/png" href="images/favico.png">
<title>eWaste</title>
<!-- Font Awesome -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Material Design Bootstrap -->
<link href="css/mdb.min.css" rel="stylesheet">
<!-- Your custom styles (optional) -->
<link href="css/style.css" rel="stylesheet">
<style>
html{
margin-top: 100px;
}
</style>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light grey lighten-5 fixed-top">
<div class="container">
<a class="navbar-brand" href="../index.php">
<img src="../images/logo.png" height="30" class="d-inline-block align-top" alt="">
</a>
<button class="navbar-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 justify-content-end" id="navbarResponsive">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" id="navi-current" href="index.php">Admin</a>
</li>
</ul>
</div>
</div>
</nav>
<!-- Navbar -->
<!--Main-->
<main class="mb-4 pb-5">
<div class="container">
<div class="row">
<div class="col-xl-4 col-lg-4 col-md-3"></div>
<div class="col-xl-4 col-lg-4 col-md-6">
</div>
<div class="col-xl-4 col-lg-4 col-md-3"></div>
</div>
</div>
</main>
<!--/.Main-->
<!--Footer-->
<?php include 'footer.php';?>
<!--/.Footer-->
<!-- SCRIPTS -->
<!-- JQuery -->
<script type="text/javascript" src="js/jquery-3.3.1.min.js"></script>
<!-- Bootstrap tooltips -->
<script type="text/javascript" src="js/popper.min.js"></script>
<!-- Bootstrap core JavaScript -->
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<!-- MDB core JavaScript -->
<script type="text/javascript" src="js/mdb.min.js"></script>
<!-- Initializations -->
<script type="text/javascript">
// Animations initialization
new WOW().init();
</script>
</body>
</html>
<?php
}
else{
echo "no";
exit();
}
?>
Please try to place this code
<?php
if (isset($_POST['submit']))
{
include 'conn.php';
session_start();
$user = $_POST['formuser'];
$pass = $_POST['formpass'];
$query = mysqli_query($conn, "SELECT user FROM login WHERE user='$user' and pass='$pass'");
if (!$query) {
die('Invalid query: ' . mysqli_error());
}
if (mysqli_num_rows($query) != 0){
$_SESSION['login_user']=$username;
header("Location: admin.php");
}
else{
echo "<script type='text/javascript'>alert('User Name Or Password Invalid!')</script>";
}
mysqli_close($conn);
}
?>
At the Start of the page. You can not assign value into the session if you print something on browser. It will give you warnings.

How do I access a different database and display it on 2 different charts in PHP?

I want to open and have access to my 2 different databases from mysql and display it on 2 different charts respectively. I have put a bootstrap carousel that would ease navigation between 2 charts. Below is my code.
$connect = mysqli_connect("localhost", "root", "", "ws_monitoring");
$query = "SELECT mb_weight, mb_weight_dt, mb_refno, mb_date, mb_weight FROM conveyor_in_entry";
$result = mysqli_query($connect, $query);
$chart_data = '';
while($row = mysqli_fetch_array($result))
{
$chart_data .= "{ mb_weight_dt:'".$row["mb_weight_dt"]."', mb_refno:".$row["mb_refno"].", mb_date:".$row["mb_date"].", mb_weight:".$row["mb_weight"]."}, ";
}
$chart_data = substr($chart_data, 0, -2);
$newconnection = mysqli_connect("localhost", "root", "", "cut" )
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>chart with PHP & Mysql | lisenme.com </title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/morris.js/0.5.1/morris.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/morris.js/0.5.1/morris.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<br /><br />
<div class="container">
<h2>Carousel Test</h2>
<div id="carousel" class="carousel slide" data-ride="carousel" data-interval="2000">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel" data-slide-to="0" class="active"></li>
<li data-target="#carousel" data-slide-to="1"></li>
<li data-target="#carousel" data-slide-to="2"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<div id="chart" class="chart" style="width:100%; height:300px;"></div>
</div>
<div class="item">
<div id="chart1" class="chart" style="width:100%; height:300px;"></div>
</div>
<div class="item">
<div id="chart2" class="chart" style="width:100%; height:300 px;"></div>
</div>
</div>
<!-- Controls -->
<a class="left carousel" href="#carousel" role="button" data-slide="prev">
<span class="sr-only"></span>
</a>
<a class="right carousel" href="#carousel" role="button" data-slide="next">
<span class="sr-only "></span>
</a>
</div>
</body>
</html>
<script>
Morris.Line({
element : 'chart',
data:[<?php echo $chart_data; ?>],
xkey:'mb_weight_dt',
ykeys:['mb_refno', 'mb_date', 'mb_weight'],
labels:['mb_refno', 'mb_date', 'mb_weight'],
hideHover:'auto',
stacked:true
});
</script>
Chart2 will be coming from a new from a different database with different attributes, so far when I create another query for mysql the same database from the first one appears for the 2nd chart.

AngularJs will not work after using php include_once function

I am using angularjs for front end and php for backend.I have written some code in angular it is working fine before including the header.php function.But, after including the header.php it is not working.It is not giving any error also.I am not getting where I went wrong also.
showAllproject.php is,
<?php
include_once 'C:\wamp64\www\Performance\header\src\demo\header.php';
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<!--Angularjs-->
<script data-require="angular.js#*" data-semver="1.6.9" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.9/angular.js"></script>
<script>
angular.module('myApp', []).controller('namesCtrl', function($scope) {
$scope.names = [
{name:'PROJECT'},
{name:'| DESCRIPTION'},
{name:'| CREATED ON'},
{name:'| LAST UPDATED'},
{name:'| '}
];
});
</script>
</head>
<body style="height:100%">
<div class="row" >
<div class="container-fluid">
<div class="col-lg-14" style="background-color:#DCDCDC;height:50px;position:fixed">
</div>
<div ng-app="myApp" ng-controller ="namesCtrl" style="background-color:#DCDCDC;height:500px;margin-top:1cm;margin-left:1cm;margin-right:2cm;" class=" row vertical-center-row">
<div class="col-lg-12" style="background-color:green;height:1cm;">
<div class="row">
<div ng-repeat="x in names" style="margin-right:4cm;margin-left:1cm;" class="col-xs-6">
{{x.name}}
</div>
</div>
</div>
<div class="col-lg-12" style="background-color:blue;height:80%;max-height:80%;overflow: auto;">
<div class="row">
<div ng-repeat="x in names" style="margin-right:4cm;margin-left:1cm;" class="col-xs-6">
</div>
</div>
</div>
<div class="col-lg-12" style="background-color:green;height:1cm;">
</div>
</div>
</div>
</div>
</body>
</html>
header.php is,
<?php
//calling methods of methods.php file
include_once 'C:/wamp64/www/performance/header/src/demo/methods.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="shortcut icon" type="image/png" href="http://localhost/performance/login/images/merahkee.png" />
<title> Merahkee Technology Soluctions</title>
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<!-- SmartMenus jQuery Bootstrap 4 Addon CSS -->
<link href="../addons/bootstrap-4/jquery.smartmenus.bootstrap-4.css" rel="stylesheet">
<!--Angularjs-->
<script data-require="angular.js#*" data-semver="1.6.9" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.7/angular.js"></script>
<!--This version is for title attribute-->
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.9/angular.js"></script>
<!--Angularjs starts-->
<script>
var rootApp = angular.module('rootApp', ['firstApp','secondApp']);
var firstApp = angular.module('firstApp', []);
firstApp.controller('firstController', function($scope) {
$scope.pageTitle = "MerahkeeCloudMeter";
});
var secondApp = angular.module('secondApp', []);
secondApp.controller('SecondController', function($scope) {
$scope.Reports="Reports";
});
var fourApp = angular.module('fourApp', []);
secondApp.controller('fourController', function($scope) {
$scope.Test="Test";
});
var thirdApp = angular.module('thirdApp', []);
secondApp.controller('thirdController', function($scope) {
$scope.Project="Project";
});
var fifthApp = angular.module('fifthApp', []);
secondApp.controller('fifthController', function($scope) {
$scope.Report="Report";
});
var sixthApp = angular.module('sixthApp', []);
secondApp.controller('sixthController', function($scope) {
$scope.default="Default Workspace";
$scope.details = [
{name:'help',href:'#'},
{name:'settings',href:'#'},
{name:'logout',href:'http://localhost/performance/login/logout.php?logout'}
];
});
var seventhApp = angular.module('seventhApp', []);
secondApp.controller('seventhController', function($scope) {
$scope.sdc_pro = [
{name:'Show All Projects',href:'http://localhost/performance/showAll_project.php?user_id='},
{name:'Delete',href:'http://localhost/performance/delete_test.php?user_id='},
{name:'Create Projects',href:'http://localhost/performance/Create_test.php?user_id='}
];
});
var eighthApp = angular.module('eighthApp', []);
secondApp.controller('eigthController', function($scope) {
$scope.sdc_test = [
{name:'Show All Tests',href:'http://localhost/performance/showAll_test.php?user_id='},
{name:'Delete',href:'http://localhost/performance/delete_project.php?user_id='},
{name:'Create Tests',href:'http://localhost/performance/Project_form.php?user_id='}
];
});
</script>
</head>
<body style="padding-top:80px;">
<!-- Navbar -->
<nav class="navbar navbar-expand-lg fixed-top navbar-dark bg-dark">
<div ng-app="rootApp" class="container">
<a ng-app = "firstApp" ng-controller = "firstController" class="navbar-brand" href="#">{{ pageTitle }}</a>
<div class="collapse navbar-collapse" id="navbarNavDropdown">
<!-- Left nav -->
<ul class="nav navbar-nav mr-auto">
<!--Display project dropdown-->
<li ng-app = "thirdApp" ng-controller = "thirdController" class="nav-item dropdown" style="padding-right:15px;" ><a class="nav-link dropdown-toggle" href="#">{{Project}}</a>
<ul class="dropdown-menu">
<?php
echo '<li><a class="dropdown-item">Recent Projects </a></li>';
for($i=0;$i<$projectcount;$i++){
//calling test_name() method and storing those values in a string
$test=project_name($count_uid,$user_id,$pro_sql);
$project_name=$test[$i];
if(strlen($project_name)>=25){
$projectName=substr($project_name,0,25);
$projectName=$projectName.'..';
}
else{
$projectName=$project_name;
}
echo'<li><a class="dropdown-item" href="http://localhost/performance/ShowTest_of_project.php?project_name='.$project_name.'&user_id='.$user_id.'" title="'.$project_name.'">'.$projectName.'</a></li>';
}//for loops ends
//show all projects
echo'<li ng-app = "seventhApp" ng-controller = "seventhController"><a ng-repeat="x in sdc_pro" class="dropdown-item" href="{{x.href}}'.$user_id.'">{{x.name}}</a></li>';
?>
</ul><!--dropdown-menu closes-->
</li><!--project dropdown ends-->
<li ng-app = "fourApp" ng-controller = "fourController" class="nav-item dropdown"><a style="padding-right:15px;" class="nav-link dropdown-toggle" href="#">{{Test}}</a>
<ul class="dropdown-menu">
<?php
echo '<li><a class="dropdown-item">Recent Tests </a></li>';
for($i=0;$i<$testcount;$i++){
//calling test_name() method and storing those values in a string
$test1=recent_test1($test_sql);
$test_name1=$test1[$i];
//project name
$project=recentTest_project($test_sql);
$project_name=$project[$i];
//platform file name
$platform=platform_file();
$platform_file=$platform[$i];
//project id
$project_id=pro_id($test_sql);
$pro_id=$project_id[$i];
//calling file_name() method and storing those values in a string
//$file=load_file_name();
//$file_name=$file[$i];
//echo' <a type="submit" name="testname" href='.$file_name.'>'.$test_name.'</a><br>';
if(strlen($test_name1)>=25){
$testName=substr($test_name1,0,25);
$testName=$testName.'..';
}
else{
$testName=$test_name1;
}
echo'<li><a class="dropdown-item" href="http://localhost/performance/RunTest_09.php?test_name='.$test_name1.'&project_name='.$project_name.'" title="'.$test_name1.'">'.$testName.'</a></li>';
}//for loops ends
//show all projects ,delete project and create project
echo'<li ng-app = "eighthApp" ng-controller = "eigthController"><a ng-repeat="x in sdc_test" class="dropdown-item" href="{{x.href}}'.$user_id.'">{{x.name}}</a></li>';
?>
</ul>
</li><!--test dropdown ends-->
<li ng-app = "fifthApp" ng-controller = "fifthController" class="nav-item dropdown"><a class="nav-link dropdown-toggle" href="#">{{Report}}</a>
<ul class="dropdown-menu">
<li></li>
</ul>
</li><!--report list ends-->
</ul>
<ul class="nav navbar-nav">
<li ng-app = "sixthApp" ng-controller = "sixthController" class="nav-item dropdown"><a class="nav-link dropdown-toggle" href="#">{{default}}</a>
<ul class="dropdown-menu">
<li><a ng-repeat="x in details" class="dropdown-item" href="{{x.href}}">{{x.name}}</a></li>
</ul>
</li>
</ul>
</div><!--collapse navbar-collapse-->
</div>
</nav>
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>
<!-- SmartMenus jQuery plugin -->
<script type="text/javascript" src="../jquery.smartmenus.js"></script>
<!-- SmartMenus jQuery Bootstrap 4 Addon -->
<script type="text/javascript" src="../addons/bootstrap-4/jquery.smartmenus.bootstrap-4.js"></script>
<?php
session_destroy();
?>
</body>
</html>

foundation menu is not working in CodeIgniter

I'am new to foundation framework and i trying to integrate foundation with CodeIgniter. Everything working but menu portion is not working. it seems the style is not effecting the menu. its been 2-3 days i'am working on this, please help me to solve this.
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Foundation | Welcome</title>
<link rel="stylesheet" href="<?php echo base_url().'public/lib/found/'; ? >
css/foundation.css" />
<script src="<?php echo base_url().'public/lib/found/'; ?>js/vendor/
modernizr.js"> </script>
<style>
.columns
{
border:1px solid red;
}
</style>
</head>
<body>
<div class="row">
<nav class="top-bar" data-topbar>
<ul class="title-area">
<li class="name">
<h1>My Site</h1>
</li>
<li class="toggle-topbar menu-icon">Menu</li>
</ul>
<section class="top-bar-section">
<!-- Right Nav Section -->
<ul class="right">
<li class="active">Right Button Active</li>
<li class="has-dropdown">
Right Button Dropdown
<ul class="dropdown">
<li>First link in dropdown</li>
</ul>
</li>
</ul>
<!-- Left Nav Section -->
<ul class="left">
<li>Left Nav Button</li>
</ul>
</section>
</nav>
</div>
<div class="row">
<div class="large-4 columns"><br/><br/></div>
<div class="large-8 columns"><br/><br/></div>
</div>
<script src="<?php echo base_url().'public/lib/found/'; ?>js/vendor/
jquery.js"> </script>
<script src="<?php echo base_url().'public/lib/found/'; ?>js/
foundation.min.js"></script>
<script>
$(document).foundation();
</script>
</body>
</html>
I find the problem. I only added the file which i included in the html page like modernizr.js, foundation.min.js, foundation.css ..etc. But when i added entire foundation folder to my new application its works.

Categories