Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How can I integrate a php code?


Guest

Recommended Posts

Hello!

 

I need help.

 

I put in the index.php this script. It works well, But the basket will be zero (temporarily). When I call the index.php (click), it will be zero.

 

[Previously I tried javascript, but it is simply for me. Ok, cancel is too simply.

 

I would like integrate this code:

 

 

<?php

function verified(){
$redirect_url='test/verify.php';
$expires=-1;
session_start();
$validated=false;
if(!empty($_COOKIE["verified"])) { $validated=true; }
if(!$validated && isset($_SESSION['verified'])) { $validated=true; }
if(is_numeric($expires) && $expires==-1 && !isset($_SESSION['verified'])) { $validated=false; }
if($validated) { return; }
else {
$redirect_url=$redirect_url."?return=".$_SERVER['REQUEST_URI']."&x=".$expires;
Header('Location: '.$redirect_url);
exit(0);
}
}
verified();
?>

 

 

verify.php

 

<?php

session_start();
if($_SERVER['REQUEST_METHOD']=='POST')
{
if(isset($_POST['YES']))
{
$redirect=isset($_GET['return'])?urldecode($_GET['return']):'./';
$expire=isset($_GET['x']) && is_numeric($_GET['x'])?intval($_GET['x']):-1;
if($expire==-1)
{
$_SESSION['verified']="yes";
header("location: ".$redirect);
exit(0);
}
if($expire==0)
{
setcookie("verified", "yes",mktime(0,0,0,01,01,date("Y")+30));
$_SESSION['verified']="yes";
header("location: ".$redirect);
exit(0);
}
setcookie("verified", "yes",(time()+$expire));
$_SESSION['verified']="yes";
header("location: ".$redirect);
exit(0);
}else{
header("location: http://www.google.hu");
exit(0);
}
}

?>

<form id="AgeQuestionForm" name="f" action="" method="post">

<button type="submit" name="YES" id="yes" class="button"><img src="images/img1.jpg" alt=""> Yes, I am over 18</button>

<button type="submit" name="NO" id="no" class="button"><img src="images/img2.jpg" alt=""> No, I'm not 18</a>

</form>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...