Jump to content

setting a cookie


tourer

Recommended Posts

Hey friends. i am trying to set up a cookie in my php page which needs to be sent to the next page. So as to link both the pages. The first php where the condition will be matched is given below. Here the user enters a resid. Now i also want to enable the function that only if the user enters some value in the resid column, then only the cookie should be set as true.

 

<?php

date_default_timezone_set('Asia/Kolkata');

$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'labview';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die   ('Error connecting to mysql');

$dbname = 'phpscheduleit';

mysql_select_db($dbname,$conn) or die ("could not open db".mysql_error());

// Make timestamp for today's date
$dv = array();
$today = getdate();
$dv['month']  = $today['mon'];
$dv['day']    = $today['mday'];
$dv['year']   = $today['year'];
$default = true;

$dv['todayTs'] = mktime(0,0,0, $dv['month'], $dv['day'], $dv['year']);
$Tdate = date('H') * 60 + date('i');

$userId = $_POST["resid1"];
[b]if(isset($_POST["resid1"])){
setcookie("validation", "true", time()+(3600), "/");
} else { 
echo "Please Enter the Resid.";
}[/b]

   $sql = "SELECT resid, start_date, starttime, endtime
          FROM reservations
           WHERE resid = '$userId'";
             
   $result = mysql_query($sql)
            or die('Query failed. ' . mysql_error());

   if (mysql_num_rows($result)) {

$row = mysql_fetch_assoc($result); //Fetch Data and use $row to get fields data

   	   if ($dv['todayTs'] == $row["start_date"]){
   
       	   if($Tdate >= $row["starttime"] && $Tdate < $row["endtime"]) {
  
	   			 header("Location: http://118.102.191.40/experiment/e1.html");

     	   } else {
           	 	  echo "This is not your time slot";
    	 }}else {
     	  echo "Your slot is booked for some other day";
}}else{
echo "Wrong Reservation id";
}
?>

 

This cookie needs to be sent to different page. This php page calls a swf file. Now the swf file shpuld be called & played only when the php page gets the cookie and that also with a value of true.

 

<?php
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<!--  BEGIN Browser History required section -->
<link rel="stylesheet" type="text/css" href="history/history.css" />
<!--  END Browser History required section -->

<title></title>
<script src="AC_OETags.js" language="javascript"></script>

<!--  BEGIN Browser History required section -->
<script src="history/history.js" language="javascript"></script>
<!--  END Browser History required section -->

<style>
body { margin: 0px; overflow:hidden }
</style>
<script language="JavaScript" type="text/javascript">
<!--
// -----------------------------------------------------------------------------
// Globals
// Major version of Flash required
var requiredMajorVersion = 9;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor version of Flash required
var requiredRevision = 28;
// -----------------------------------------------------------------------------
// -->
</script>
</head>

<body scroll="no">
<script language="JavaScript" type="text/javascript">
<!--
// Version check for the Flash Player that has the ability to start Player Product Install (6.0r65)
var hasProductInstall = DetectFlashVer(6, 0, 65);

// Version check based upon the values defined in globals
var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);

if ( hasProductInstall && !hasRequestedVersion ) {
// DO NOT MODIFY THE FOLLOWING FOUR LINES
// Location visited after installation is complete if installation is required
var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
var MMredirectURL = window.location;
    document.title = gaurav.slice(0, 47) + " - Flash Player Installation";
    var MMdoctitle = document.title;

AC_FL_RunContent(
	"src", "playerProductInstall",
	"FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"",
	"width", "1021",
	"height", "610",
	"align", "middle",
	"id", "e1",
	"quality", "high",
	"bgcolor", "#ffffff",
	"name", "e1",
	"allowScriptAccess","sameDomain",
	"type", "application/x-shockwave-flash",
	"pluginspage", "http://www.adobe.com/go/getflashplayer"
);
} else if (hasRequestedVersion) {
// if we've detected an acceptable version
// embed the Flash Content SWF when all tests are passed
AC_FL_RunContent(
		"src", "e1",
		"width", "1021",
		"height", "610",
		"align", "middle",
		"id", "e1",
		"quality", "high",
		"bgcolor", "#ffffff",
		"name", "e1",
		"allowScriptAccess","sameDomain",
		"type", "application/x-shockwave-flash",
		"pluginspage", "http://www.adobe.com/go/getflashplayer"
);
  } else {  // flash is too old or we can't detect the plugin
    var alternateContent = 'Alternate HTML content should be placed here. '
  	+ 'This content requires the Adobe Flash Player. '
   	+ '<a href=http://www.adobe.com/go/getflash/>Get Flash</a>';
    document.write(alternateContent);  // insert non-flash content
  }
// -->
</script>
<noscript>
  	<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
		id="e1" width="1021" height="610"
		codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
		<param name="movie" value="C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\blazeds\e1.swf" />
		<param name="quality" value="high" />
		<param name="bgcolor" value="#ffffff" />
		<param name="allowScriptAccess" value="sameDomain" />
		<embed src="C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\blazeds\e1.swf" quality="high" bgcolor="#ffffff"
			width="1021" height="610" name="e1" align="middle"
			play="true"
			loop="false"
			quality="high"
			allowScriptAccess="sameDomain"
			type="application/x-shockwave-flash"
			pluginspage="http://www.adobe.com/go/getflashplayer">
		</embed>
</object>
</noscript>
?>
</body>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.