PHP pageName pulling from other page - php

I'm working on my script site I have the url setup like this with PHP.
movies.php?pages=action
But every time a member goes to the url it pulls the page name from movies.php how can I fix this issue I have pasted my code down below.
<?php
// StreamPlex Page System - Play Page
DEFINE("IN_STREAMPLEX", 1);
$pageName = "All Movies";
require_once('inc/config.php');
require_once('inc/header.php');
$action = $_GET['action'];
$pages = $_GET['pages'];
if(isset($pages)) {
require_once("{$pages}.php");
} else {
?>
Then at the bottom of the page I have finished off with this code here
<?php include 'inc/footer.php'; ?>
<?php } ?>
Can somebody please help me in telling me what I'm doing wrong.

I have fix the issue i had change around the code at the top of the page from
<?php
DEFINE("IN_STREAMPLEX", 1);
$pageName = "All Movies";
require_once('inc/config.php');
require_once('inc/header.php');
$action = $_GET['action'];
$pages = $_GET['pages'];
if(isset($pages)) {
require_once("{$pages}.php");
} else {
?>
To this
<?php
// StreamPlex Page System - Play Page
DEFINE("IN_STREAMPLEX", 1);
$action = $_GET['action'];
$pages = $_GET['pages'];
if(isset($pages)) {
require_once("{$pages}.php");
} else {
$pageName = "All Movies";
require_once('inc/config.php');
require_once('inc/header.php');
?>
Now it works in loads with no problems.

Related

modifying from admin panel and logging out does not save the images

I have a main pain where I want to modify things from the admin account
and whenever I log out of the admin account the images are not saved and it give me an undefined index error.
this is my main page php code:
<?php $src = $_SESSION['firstimgsrc'];echo "<img id='first' src='$src'>";?><!-- Direct link 1st champion -->
<?php $src1 = $_SESSION['secondimgsrc'];echo "<img id='second' src='$src1'>"; ?><!-- Direct link 2nd champion -->
<?php $src2 = $_SESSION['thirdimgsrc'];echo "<img id='third' src='$src2'>";?> <!-- Direct link 3rd champion -->
<?php $src3 = $_SESSION['forthimgsrc'];echo "<img id='forth' style='border-right: 0px;' src='$src3'>"; ?> <!-- Direct link 4th champion -->
this is the admin panel php code:
<?php
if(isset($_POST['submit'])) {
session_start();
$firstimgsrc = $_POST['firstimgsrc'];
if ($firstimgsrc == "") {
$_SESSION['firstimgsrc'] = $jk;
} else {
$_SESSION['firstimgsrc'] = $firstimgsrc;
$jk = $_SESSION['firstimgsrc'];
}
$secondimgsrc = $_POST['secondimgsrc'];
if ($secondimgsrc == "") {
$_SESSION['secondimgsrc'] = $jk1; } else {
$_SESSION['secondimgsrc'] = $secondimgsrc;
$jk1 = $_SESSION['secondimgsrc'];
}
$thirdimgsrc = $_POST['thirdimgsrc'];
if ($thirdimgsrc == "") {
$_SESSION['thirdimgsrc'] = $jk2;
} else {
$_SESSION['thirdimgsrc'] = $thirdimgsrc;
$jk2 = $_SESSION['thirdimgsrc'];
}
$forthimgsrc = $_POST['forthimgsrc'];
if ($forthimgsrc == "") {
$_SESSION['forthimgsrc'] = $jk3;
} else {
$_SESSION['forthimgsrc'] = $forthimgsrc;
$jk3 = $_SESSION['forthimgsrc'];
}
header("Location: ../egamingtv.php");
}
?>
worked, I just used unset instead of the session_destroy in my logout page

How to properly redirect to the same page in php

I am working on something that i want to use in a project.
i am to redirect the current page to itself using php and session. The idea is that:
if my `$_session['insert']= true; then refresh the page to itself;`
Here is the code:
sess_page1.php
session_start();
$_SESSION["insert"] = 1;
$_SESSION["test"] = "Page refreshed";
?>
Click here to go to the next page
sess_page2.php
<?php
session_start();
if (isset($_SESSION["insert"]) && ($_SESSION["insert"]==1)) {
header('location:'.$_SERVER['PHP_SELF']);
print $_SESSION["test"];
}
else
{
echo "Impossible to execute.";
exit();
}
?>
But the page does not redirect to itself...The whole idea is the page should refresh one time.
What i did wrong here? Can somebody help?
Try this:
sess_page1.php
session_start();
$_SESSION["stopper"] = 0;
$_SESSION["insert"] = 1;
$_SESSION["test"] = "Page refreshed";
?>
Click here to go to the next page
sess_page2.php
<?php
session_start();
if (isset($_SESSION["insert"]) && ($_SESSION["insert"]==1) && ($_SESSION["stopper"]==0)) {
$_SESSION['stopper']=1;
header('location:'.$_SERVER['PHP_SELF']);
print $_SESSION["test"];
}
else
{
echo "Impossible to execute.";
exit();
}
?>

To define CURRENT page for current menu item

I've created a navigation menu by PHP.
1) I need help how can i change link class for current page. I mean for example when HOME PAGE is open link should be like class="bla bla CURRENT"
2) Is there any suggest to better way for the LINK to that buttons.
HERE IS THE CODES
<?php
require_once('../config.php');
$sql= "SELECT * FROM veri_kategori";
foreach ($dbh->query($sql) as $row)
{
echo "<li class=\"dropdown\">".$row["tr"]."</li>";
}
?>
Try this solution:
<?
require_once('../config.php');
// Get the current page.
$pag = $_GET['pag'];
if (isset($pag)) {
if ($page == 'about') {
// Redirect or include your page.
} else if ($page == 'contact') {
// Redirect or include your page.
}
} else {
// Redirect or include your home page.
}
$sql = "SELECT * FROM veri_kategori";
foreach ($dbh->query($sql) as $row) {
// Set default class.
$class = "dropdown-toggle";
// If home page, set another class.
if (!isset($pag)) {
$class = "bla bla CURRENT";
}
echo "<li class=\"dropdown\">{$row["tr"]}</li>";
}
?>

Are PHP script read from Top to bottom?

Are PHP scripts reads from top to bottom? like HTML? because in this code
<?php require_once("./includes/connection.php")?>
<?php require_once("./includes/functions.inc.php"); ?>
<?php
if(isset($_GET['subj']))
{
$sel_subj = get_subject_by_id($_GET['subj']);
$sel_page = NULL;
}else if(isset($_GET['page']))
{
$sel_subj = NULL;
$sel_page = get_page_by_id($_GET['page']);
}else
{
$sel_subj = NULL;
$sel_page = NULL;
}
?>
<?php include("includes/header.inc.php"); ?>
<table id="structure">
<tr>
<td id="navigation">
<ul class = "subjects">
<?php
$subject_set = get_all_subjects();
while($subject = mysql_fetch_array($subject_set))
{
echo "<li";
if($subject['id'] == $sel_subj['id']) {echo " class =\"selected\"";}
echo "><a href=\"content.php?subj=" . urlencode($subject["id"]) .
"\">{$subject["menu_name"]}</a></li>";
echo "<ul class = 'pages'>";
$page_set = get_pages_for_subject($subject['id']);
while($page = mysql_fetch_array($page_set))
{
echo "<li";
if($page['id'] == $sel_page['id']){echo " class = \"selected\"";}
echo"><a href=\"content.php?page=" . urlencode($page["id"]) .
"\">{$page["menu_name"]}</a></li>";
}
echo "</ul>";
}
?>
</ul>
</td>
<td id="page">
<?php if(isset($sel_subj)){?>
<h2><?php echo "{$sel_subj['menu_name']}";?></h2>
<?php } ?>
<?php if(isset($sel_page)){?>
<h2><?php echo "{$sel_page['menu_name']}"?> </h2>
<?php }?>
</td>
</tr>
</table>
<?php require("includes/footer.inc.php"); ?>
specifically this part
if(isset($_GET['subj']))
{
$sel_subj = get_subject_by_id($_GET['subj']);
$sel_page = NULL;
}else if(isset($_GET['page']))
{
$sel_subj = NULL;
$sel_page = get_page_by_id($_GET['page']);
}else
{
$sel_subj = NULL;
$sel_page = NULL;
}
How is this if-else block being called if it's on top of the page?
It is run top-to-bottom one time per page view. On the initial view, assuming the URL has no parameters, then neither $_GET['subj'] or $_GET['page'] will be set.
If the link pointing back to the same page is clicked, then the entire PHP file will be reprocessed. If that link contained subj or page in the URL as a query variable, then the corresponding if block will be executed and the page will be altered accordingly.
Think of the PHP server as dynamically creating some HTML file that is sent to the web browser. Once it is sent, the server is done, and the PHP code is "gone." The only way to run more PHP code is to request a new page, where the process starts over.
(Even AJAX follows the same principles, although generally then you are dealing with partial data requests as opposed to full page views.)
Yes, scripts are run from top to bottom. I don't understand why you think that if-else block is any different? Those if clauses are run to set the $sel_subj and $sel_page variables before the rest of the page is executed and output.
PHP scripts are executed from top-to-bottom. What exactly is your problem?

Weird problem with PHP Breadcrumb Script

I'm using Mick Sears' php breadcrumb script - found here:
http://www.roscripts.com/PHP_breadcrumbs-118.html
I've used this script several times with no problems. But with this one site I'm having the weirdest problem... Home page - fine. Level 1 page - fine. But every time I move to a level2 page, the correct level1 crumb is replaced by "Help". The link on the crumb is the correct one for the help page. This happens even if I clear all browser caches and don't go to the Help section of the site at all.
The site is http://www.fastexas.org. The script is there, but I gave the breadcrumb div display:none; until I can figure this out.
This script seems to have been around awhile and I'm wondering if anyone else has seen this problem.
The Breadcrumb Script:
<?php
class Breadcrumb{
var $output;
var $crumbs = array();
var $location;
function Breadcrumb(){
if ($_SESSION['breadcrumb'] != null){
$this->crumbs = $_SESSION['breadcrumb'];} }
function add($label, $url, $level){
$crumb = array();
$crumb['label'] = $label;
$crumb['url'] = $url;
if ($crumb['label'] != null && $crumb['url'] != null && isset($level)){
while(count($this->crumbs) > $level){
array_pop($this->crumbs); }
if (!isset($this->crumbs[0]) && $level > 0){
$this->crumbs[0]['url'] = "/index.php";
$this->crumbs[0]['label'] = "Home";}
$this->crumbs[$level] = $crumb;}
$_SESSION['breadcrumb'] = $this->crumbs;
$this->crumbs[$level]['url'] = null;}
function output(){
echo "<ul>";
foreach ($this->crumbs as $crumb){
if ($crumb['url'] != null){
echo "<li> <a href='".$crumb['url']."' title='".$crumb['label']."'>".$crumb['label']."</a></li> ";} else {
echo "<li class='last'>".$crumb['label']."</li> ";}}
echo "</ul>";}}
?>
Each page begins with something like:
<?php session_start();
$level= '1';
$label= 'Honors Circle';
$url= '/honors/'; include($_SERVER['DOCUMENT_ROOT']."/includes/Breadcrumb.php");
$trail = new Breadcrumb();
$trail->add($label, $url, $level); ?>
or
<?php
session_start();
$level= '2';
$label= 'Districts';
$url= '/honors/district.php';
include($_SERVER['DOCUMENT_ROOT']."/includes/Breadcrumb.php");
$trail = new Breadcrumb();
$trail->add($label, $url, $level);
?>
And to print the breadcrumb trail:
<div id="breadcrumb"><?php $trail->output(); ?></div>

Categories