I am beginner to php.. please help,,
I am passing data from one page to another using GET
I am reloading the page automatically using following code.
<?php require_once ("includes/sessions.php"); ?>
<?php
$page = $_SERVER['PHP_SELF'];
$sec = "100000";
?>
<?php include ("includes/connection.php"); ?>
<?php
conferm_login();
?>
<html>
<head>
<meta http-equiv="refresh" content="<?php echo $sec?>;URL='<?php echo $page?>'">
</head>
<body>
<?php
$usr = $_GET['usr'];
$usr2='';
if($usr=='User1')
$usr2='User2';
it works fine but after the automatic refresh the error i am getting is Unidentified index.pointing to variables i.e $user=$_GET['usr'] even in previous pages from where i send data. I also wrapped $user=$_GET['usr'] with if(isset($_GET['usr'])) but there will no output.
<?php
require_once ("includes/sessions.php");
include ("includes/connection.php");
$page = basename($_SERVER['REQUEST_URI']);
$sec = "100000";
conferm_login();
<html>
<head>
<meta http-equiv="refresh" content="<?php echo $sec?>;URL='<?php echo $page?>'">
</head>
<body>
<?php
$usr = $_GET['usr'];
$usr2='';
if($usr=='User1')
$usr2='User2';
?>
Related
The default link I get is to link index.php.
How can I change the default link to all my project to index.php?folder=0?
You can check GET starting in index.php file.
If $_GET['folder'] is not set then redirect otherwise load same page.
if(!isset($_GET['folder'])){
header("Location:./index.php?folder=0");
}
Hope this work to you.
You could do something like this...
<?php
$sec = 0;
$page = '?folder=0';
?>
<html>
<head>
<meta http-equiv="refresh" content="<?php echo $sec?>;URL='<?php echo $page?>'">
</head>
<body>
</body>
</html>
Hello everyone.
I've got a small problem. Instead of making a $content variable and putting in the whole content there, I would like to set the page up like this (below), though the problem is that the php variables that is placed at the end (title, keywords, description, page), aren't working even though its in the index.php.
Question: How can I make the variables work without making a few head_template.php with the variables filled out already?
index.php:
<!DOCTYPE html>
<html class="html" lang="en">
<?php require_once "head_template.php"; ?>
<body class="<?php echo $page; ?>">
<?php require_once "navigation_menu_template.php"; ?>
<?php require_once "load_template.php"; ?>
<h1>Content</h1>
<?php require_once "cookies_script_template.php"; ?>
<?php require_once "footer_template.php"; ?>
</body>
</html>
<?php
$title = "QCG | Homepage";
$keywords = "QCG, Homepage";
$description = "QCG | Homepage - Description";
$page = "homepage";
?>
head_template.php:
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="UTF-8">
<meta name="description" content="<?php echo $description; ?>">
<meta name="keywords" content="<?php echo $keywords; ?>">
<title><?php echo $title; ?></title>
<link rel="stylesheet" type="text/css" href="css/css.css">
</head>
You are setting them after they are used. If you put that block at the top of your page it will work.
<!DOCTYPE html>
<html class="html" lang="en">
<?php
$title = "QCG | Homepage";
$keywords = "QCG, Homepage";
$description = "QCG | Homepage - Description";
$page = "homepage";
?>
<?php require_once "head_template.php"; ?>
<body class="<?php echo $page; ?>">
<?php require_once "navigation_menu_template.php"; ?>
<?php require_once "load_template.php"; ?>
<h1>Content</h1>
<?php require_once "cookies_script_template.php"; ?>
<?php require_once "footer_template.php"; ?>
</body>
</html>
I am trying to make my website mobile friendly and it works when using inside head
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<?php $this->head(); ?>
</head>
<body>
<?php $this->beginBody() ?>
<?php echo $this->render('//layouts/_top_js'); ?>
<?= Alert::flashes() ?>
<?php echo $this->render('//layouts/_header'); ?>
<?= $content ?>
<?php echo $this->render('//layouts/_footer'); ?>
<?php echo $this->render('//layouts/_bottom_js'); ?>
<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>
But when I start using the following code:
php $this->beginBody()
php $this->endBody()
it is completely ignored. Is the viewport code disabled when using the php code to load my pages?
The viewport needs to be explicitly set in the <head> section of your HTML. You should start the page with beginPage() instead of beginBody(), as the second one only renders the <body></body> part of the HTML.
PHP only outputs HTML on the page, in the case of Yii using layouts.
You need to check your layout files to make sure they contain the following line:
<meta name="viewport" content="width=device-width,initial-scale=1">
I am new to php.
I have a header.php with variables which I want to be uniquely set depending on which php page includes the header.php. I want each page that loads the header to display unique data in the header - current page info.
Currently I have something like the following:
header.php
<?php $pageInfo = "";?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="stylesheet" type="text/css" href="css/header.css">
<title></title>
</head>
<body>
<div id="header-box">
<div id="header-wrapper">
<div id="logo-box">
</div>
<div id="info-box">
<div>
<p><?php echo $pageInfo ?></p>
</div>
</div>
</div>
</body>
</html>
page1.php
<body>
<div><?php $pageInfo = ":D"; require 'shared/header.php'; ?></div>
<div><?php include 'shared/menu.php';?></div>
</body>
Yes that is possible. Include works like as you have have merged multiple pages (Scripts) into one. So if you want to change the value of variables in header.php before including header.php define them.
ex:
<?php
$pageInfo = 'Test page';
require_once 'header.php';
?>
Note: Do not declare $pageInfo = '' in header.php else it will over write it. You can do as follow in header.php:
if(!isset($pageInfo)) {
$pageInfo = '';
}
I am using following code for a refreshing page, it is not reloading on completion. The following code is not working sometime.
$page = $_SERVER['PHP_SELF'];
$sec = "10";
header("Refresh: $sec; url=$page");
echo "Watch the page reload itself in 10 second!";
Use a <meta> redirect instead of a header redirect, like so:
<?php
$page = $_SERVER['PHP_SELF'];
$sec = "10";
?>
<html>
<head>
<meta http-equiv="refresh" content="<?php echo $sec?>;URL='<?php echo $page?>'">
</head>
<body>
<?php
echo "Watch the page reload itself in 10 second!";
?>
</body>
</html>
you can use
<meta http-equiv="refresh" content="10" >
just add it between the head tags
where 10 is the time your page will refresh itself
use this code ,it will automatically refresh in 5 seconds, you can change time in refresh
<?php
$url1=$_SERVER['REQUEST_URI'];
header("Refresh: 5; URL=$url1");
?>
Try out this as well. Your page will refresh every 10sec
<html>
<head>
<meta http-equiv="refresh" content="10; url="<?php echo $_SERVER['PHP_SELF']; ?>">
</head>
<body>
</body>
</html>
Maybe use this code,
<meta http-equiv="refresh" content = "30" />
take it be easy
This works with Firefox Quantum 60+ and Chrome v72 (2019)
//set a header to instruct the browser to call the page every 30 sec
header("Refresh: 30;");
It does not seem to be NECESSARY to pass the page url as well as the refresh period in order to (re)call the same page. I haven't tried this with Safari/Opera or IE/Edge.
Simple step like this,
<!DOCTYPE html>
<html>
<head>
<title>Autorefresh Browser using jquery</title>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript">
$(function() {
startRefresh();
});
function startRefresh() {
setTimeout(startRefresh,100);
$.get('text.html', function(data) {
$('#viewHere').html(data);
});
}
</script>
</head>
<body>
<div id="viewHere"></div>
</body>
</html>
This video for complete tutorial
https://youtu.be/Q907KyXcFHc
<meta http-equiv="refresh" content="10" >
This can work. Try it..!! :-)