example-index.php
<?php session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<meta http-equiv='Content-Style-Type' content='text/css' />
<link rel='shortcut icon' href='images/siteexpeditor.ico' />
<link href='css/layout.css' rel='stylesheet' type='text/css' />
<link href='css/style.css' rel='stylesheet' type='text/css' />
<link href='css/style-colours1.css' rel='stylesheet' type='text/css' />
<!-- include jQuery library -->
<script type='text/javascript' src='js/jquery.js'></script>
<script type='text/javascript' src='js/example.js'></script>
<title>Example Index</title>
</head>
<body class="twoColFixLtHdr">
<div id="container">
<!-- header -->
<div id="dataArea"></div>
<!-- end #header -->
<!-- #mainContent -->
<div id="mainContent">
</div>
<!-- end #mainContent -->
<!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats -->
<br class="clearfloat" />
<!-- footer -->
<?php include ("php/footer.php"); ?>
<!-- end #footer -->
<!-- end #container -->
<?php
$trans_ID = "0";
echo "<script type='text/javascript' src='
http://www.siteexpeditor.com/js/example.js#obj1/" . $trans_ID . "/obj2/" . "0" . "/obj3/" . "0" . "/obj4/" . "0" . "/obj5/" . "0" . "'></script>";
?>
</div>
</body>
</html>
Example of Javascript Code
<!--
var myParams = getScriptUrlParams();
str1 = (myParams["obj1"]);
str2 = (myParams["obj2"]);
str3 = (myParams["obj3"]);
str4 = (myParams["obj4"]);
str5 = (myParams["obj5"])
function getScriptUrlParams()
{
var scriptTags = document.getElementsByTagName("script");
// This code is assumed to be in a file so the "src" attribute
// is guaranteed to be present...no error-checking is needed
var urlFrags = scriptTags[scriptTags.length-1].src.split("#");
var urlParams=[];
var urlParamRaw = [];
if (urlFrags.length > 1)
{
urlParamRaw = urlFrags[1].split("/");
if (urlParamRaw.length >= 2)
{
for(var param=0;param<urlParamRaw.length;param+=2)
urlParams[urlParamRaw[param]] = (urlParamRaw.length >= param + 1 ? unescape(urlParamRaw[param+1]) : null);
}
}
return(urlParams);
}
//
// This function controls the main processing
// ** M A I N P R O C E S S I N G C O N T R O L
getData(str1,str2,str3,str4,str5);
function getData(str1,str2,str3,str4,str5) {
var xmlHttp;
str1 = String(str1);
str2 = String(str2);
str3 = String(str3);
str4 = String(str4);
str5 = String(str5);
showData(str1,str2,str3,str4,str5);
}
//Called functions below this line
function showData(str1,str2,str3,str4,str5)
{
xmlHttp=GetDataXmlHttpObject()
if (xmlHttp==null) {
alert ("Browser does not support HTTP Request")
return
}
str1 = String(str1);
str2 = String(str2);
str3 = String(str3);
str4 = String(str4);
str5 = String(str5);
switch(str1)
{
case "0":
var url="
http://www.siteexpeditor.com/php/example-login-data.php"
//var x=document.getElementById("input#email");
//str2 = (x.value);
str2 = $("input#email").val();
str3 = $("input#password").val();
url=url+"?xxx="+str1+"&email="+str2+"&password="+str3+"&errorno="+str4+"&transpass="+str5;
break;
default:
document.write("Unknown Transaction ID (" + str1 + ") - getData.js");
}
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=getDataStateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function getDataStateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("dataArea").innerHTML=xmlHttp.responseText
}
}
function GetDataXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
//Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
// -->
Example of PHP Code called by above Javascript and injected into the division (id=dataArea) with example-index.php
<?php
session_start();
$trans_ID = $_GET['xxx'];
$transpass = $_GET['transpass'];
if ($transpass == 1) {
$message = "";
$emailerr = false;
$passworderr = false;
$email = trim($_GET['email']);
$length = strlen($email);
if ($length == 0) {
$emailerr = true;
$message = "MISSING EMAIL ADDRESS";
}
else {
//
//Password missing - return control to sign-on screen
//
$password = trim($_GET['password']);
$length = strlen($password);
if ($length == 0) {
$passworderr = true;
$message = "MISSING PASSWORD";
}
}
if (($emailerr == false) && ($passworderr == false)) {
//VALID SIGN ON - Pass control to client accounts
$_SESSION['client_ID'] = $client_data['ID'];
$_SESSION['account_ID'] = $client_data['default_account_ID'];
header("Location:
http://www.siteexpeditor.com/example-client-page.php");
exit;
} //End if
} //End if
if ((((($emailerr == true) || ($passworderr == true)) && ($transpass == 1)) || ($transpass == 0 ))) {
echo "<div id='header'>";
echo " <table class='maxWidth'>";
echo " <tr>";
echo " <td>";
echo " <a href='index.php'><img src='images/logo.png' id='logo' alt='' /></a>";
echo " </td>";
echo " <td class='alignRight'>";
echo " <form id='login-form' method='post' action='javascript:getData(" . $trans_ID . "," . "0" . "," . "0" . "," . "0" . "," . "1" . ")'>";
echo " <table>";
echo " <tr>";
echo " <td><label>Email</label></td>";
echo " <td><label>Password</label></td>";
echo " <td></td>";
echo " </tr>";
echo " <tr>";
echo " <td><input type='text' id='email' name='email' value='$email' /></td>";
echo " <td><input type='password' id='password' value='$password' /></td>";
echo " <td><input type='submit' value='Log in' id='login-submit' /></td>";
echo " </tr>";
echo " <tr>";
echo " <td><input type='checkbox' name='keep' value='' /> <label>Keep me logged in</label></td>";
echo " <td><label><a href='#'>Forgotten your password</a></label></td>";
echo " <td></td>";
echo " </tr>";
echo " <tr>";
echo " <td colspan='3' class='highlight'>" . $message . "</td>";
echo " </tr>";
echo " </table>";
echo " </form>";
echo " </td>";
echo " </tr>";
echo " </table>";
echo "</div>";
}
?>
