WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : PHP4 session helper HTML file.
Categories : PHP, Java Script, HTML and PHP, Sessions Update Picture
Yasuo Ohgaki
Date : Feb 16th 2001
Grade : 2 of 5 (graded 5 times)
Viewed : 7808
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Yasuo Ohgaki
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

== Browser Check HTML (This is plain HTML w/ JavaScript ===
<html>
<head>
<title>Checking Browser Setting</title>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-JP">
<!-- <script src="/lib/js/md5.js"></script> -->
<script language="javascript" type="text/javascript">
<!--
function start_session() {
// When browser load this page, it should look like
// http://example.com/lib/js/browser_check.html?
sid=PHPSESSION_ID&sname=PHPSESSION&url=http://example.com/index.php?
other_query_var=ABC
// NOTE:target_url data msut be URL encoded. eg. rawurlencode($URL);
var session_id = '';
var session_name = '';
var target_url = '';

query = location.search.split('&');
if (query.length > 3) {
alert('Invalid parameter. Please reload.(1)');
history.back();
return false;
}
for (i = 0; i < query.length; i++) {
el = query[i].split('=',2);
if (el.length > 2) {
alert('Invalid parameter. Please reload.(2)');
history.back();
return false;
}
if (el[0] == 'url') {
target_url = unescape(el[1]);
}
if (el[0] == 'sname') {
session_name = el[1];
}
if (el[0] == '?sid') {
session_id = el[1];
}
}
// Perform simple check see if user changed session id, etc
// Should check them again on server anyway.
if (session_id.length != 32) {
alert('Invalid session id parameter. Please reload.');
history.back();
return false;
}
if (session_name == '') {
alert('Invalid session name parameter. Please reload.');
history.back();
return false;
}
if (target_url == '') {
alert('Invalid URL parameter. Please reload.');
history.back();
return false;
}
// Get rid of session id and name if they are included in url
//alert('BEFORE '+target_url);
q = target_url.split('?');
if (q.length > 2) {
alert('Invalid parameter. Please reload.(3)');
history.back();
return false;
}
if (q.length == 2) {
// have query
regex = session_name+'=.*&';
re = new RegExp(regex);
q[1] = q[1].replace(re,'');
regex = session_name+'.*'; // Delete anything after SESSION name. Should not happen
unless user temper with query string.
re = new RegExp(regex);
q[1] = q[1].replace(re,'');
if (q[1].length > 2) { // have more query.
target_url = q[0]+'?'+q[1];
}
else {
target_url = q[0];
}
}
//alert('DEL_OLD_SESSION '+target_url);

// See if cookie is enabled. No check for cookie seession id. Checks session id on server
anyway.
if (document.cookie != '') {
//alert('COOKIE '+document.cookie);
//alert('AFTER '+target_url);
location.replace(target_url);
return true;
}
else {
session = session_name+'='+session_id;
if (target_url.search(/\?/) == -1) {
target_url += '?'+session;
}
else {
target_url = target_url.replace(/\?/,'?'+session+'&');
}
//alert('AFTER '+target_url);
location.replace(target_url);
return true;
}
}
//-->
</script>
</head>
<body bgcolor="#FFFFFF" onload="return start_session();">
<p align="center"><b><font size="4">Welcome!</font></b></p>
<p align="center"><font size="2">Checking your browser settings</font></p>
<hr width="70%" size="1" noshade>
<noscript>
<p align="center"><font size="2">This site
uses<b>JavaScript</b>and<b>Cookie</b>.</font></p>
<p align="center"><font size="2">If page didn't reload, your browser does not support
JavaScript or JavaScript is disabled.<br>
<b>This site will not work properly without JavaScript</b><br>
Please enable JavaScript and click <a href="javascript:start_session
()">here</a>.</font><br>
<br>
<font size="1">If you cannot see page, Please<br>
hit browser's reload button, after you enbled JavaScript.</font></p>
<hr width="70%" size="1" noshade>
</noscript>
</body>
</html>
==== Browser Check HTML END ====

==== Example PHP Code===
You need to change /lib/browser_check.html whereever you saved the HTML file to use it.

<?php
session_start(); // Start PHP4 session

if (!isset($HTTP_COOKIE_VARS[session_name()]) && !isset($HTTP_GET_VARS[session_name
()])) {
// The HTML file expects browser_check.html?
sid=SESSION_ID&sname=SESSION_NAME&url=URL_TO_LOAD
$hdr = 'Location: http://'. $HTTP_SERVER_VARS['HTTP_HOST'] .'/lib/browser_check.html?
sid=' . session_id() . '&sname=' . session_name() . '&url=' . rawurlencode($HTTP_SERVER_VARS
['REQUEST_URI']); // Don't forget encode with rawurlendoe().
header($hdr);
exit;
}

// Do what ever you need to do
// Note: Do not forget SESSION_NAME=SESSION_ID (there is predefined constant "SID" for
this) for each page if session id is passed as URL parameter.
?>
==== Example Code END ====



Dynamic Calender in PHP, Javascript and HTML.
Categories : PHP, Java Script, HTML and PHP, Calendar
Pull Down Surfing - Surf on Change
Categories : Java Script, MySQL, HTML and PHP, PHP, Databases
XDT Topsite (Gold v1.0)
Categories : Databases, CSS, PHP, HTML and PHP, Sessions
Remote Scripting: send form POST data to a script and insert the results into a page without refreshing the page.
Categories : PHP, AJAX, HTML and PHP, Java Script
AITSH Statistics
Categories : Complete Programs, Databases, HTML and PHP, Sessions, PHP
Dynamic generation of textboxes, select items etc in a table for use with databases applications, matrimonials and for job sites
Categories : PHP, HTML and PHP, Java Script
Tree Menu Dynamic (+Static) with Loading in Progress..
Categories : PHP, Java Script, HTML and PHP
OverEasy - PHP generated JavaScript to do mouseovers on your pages. Modify one file and one function does it all for you!
Categories : PHP, Java Script, HTML and PHP, MySQL
Form Security - Match A Value For Success
Categories : PHP, Authentication, HTML and PHP, Sessions, Security
This PHP function creates dropdown select lists for time and date that you can change, outputs a 14 char MySQL timestamp in a text field
Categories : PHP, MySQL, Java Script, HTML and PHP
Function that allows a Javascript cookie to be set after HTML has been outputted to the page.
Categories : PHP, Java Script, Cookies, HTML and PHP
Local-to-user date and time display regardless of time zone or where the website's server is located
Categories : PHP, Date Time, HTML and PHP, Java Script
PHP3: Formmail. Just a cgi formmail, but than in PHP. It is easy to use!
Categories : HTML and PHP, Email, PHP, Perl, HTML and PHP
CSS style switcher
Categories : PHP, CSS, HTML and PHP, Arrays, Sessions
Newbie Notes #9 - Hyperlinking a post
Categories : PHP, Java Script, HTML and PHP, Beginner Guides