Forum Moderators: coopster

Message Too Old, No Replies

Php page rotator code problem

page rotator script

         

banik2010

5:09 am on Jun 1, 2010 (gmt 0)

10+ Year Member



someone made this code but its not working acctually i have three offer pages i want my website users to signup for those three offers one by one then he will be able to get the product


This is the php code :-



<?php
//----------------START RUN AT TOP OF PAGE, BEFORE ANY HTML -------//
//how many offers do you want to chain together.
$numberOfOffers = 2;
//leave blank if the offers are in the same directory as this script.
//Do NOT include trailing slash.
$offersDirectory = '';
//Do NOT change this variable.
//Add offer names to this array, as they become available.
$offerNames = array('incomeweb','cocc','czcc');
$nextbutton = NULL;
$_COOKIE['completed'][] = 'cocc';
if(isset($_POST['offer'])) {
$count = count($_POST['offer']);
if($count > 1) {
$nextbutton = '<form action="" method="post">'."\n";
for($i = 1; $i < $count; $i++) {
if(isset($_POST['offer'][$i])) {
$nextbutton .= '<input type="hidden" name="offer[]" value="'.$_POST['offer'][$i].'" />'."\n";
}
}
$nextbutton .= '<input type="submit" name="next" value="Next"/>
</form>."\n"';
}
if(in_array($_POST['offer'][0],$offerNames)) {
$page = $offerDirectory . '/' . $_POST['offer'][0] . '.php';
}
}
else {
if(isset($_COOKIE["completed"])) {
$openNames = array_diff($offerNames,$_COOKIE['completed']);
if(!empty($openNames)) {
$openOffers = @array_rand($openNames,$numberOfOffers);
$count = count($openOffers);
if($count > 1) {
$nextbutton = '<form action="" method="post">'."\n";
for($i = 1; $i < $count; $i++) {
if(isset($openOffers[$i])) {
$nextbutton .= '<input type="hidden" name="offer[]" value="'.$openOffers[$i].'" />'."\n";
}
}
$nextbutton .= '<input type="submit" name="next" value="Next"/>
</form>'."\n";
}
$page = $offersDirectory . '/' . $offerNames[$openOffers[0]] . '.php';
}
else {
header('Status: 200');
header("Location: http://www.mydomain.com/signup.html");
}
}
else {
$page = $offersDirectory . '/' . $offerNames[0] . '.php';
}
}
//--------------END RUN AT TOP OF PAGE ---------------------------//



//NEXT LINES GO WHERE YOU WANT THE PAGE INCLUDED IN YOUR SCRIPT.
if(isset($page)) include_once($page);
echo $nextbutton;
//LINES ABOVE GO WHERE YOU WANT THE PAGE INCLUDED IN YOUR SCRIPT.



//This will go on every offer page to create a cookie
// incomeweb.php
setcookie("completed[]","incomeweb", time()+60*60*24*365*10);
// cocc.php
setcookie("completed[]","cocc", time()+60*60*24*365*10);
// czcc.php
setcookie("completed[]","czcc", time()+60*60*24*365*10);

?>


It is giving this error :-

Warning: include_once(.php) [function.include-once]: failed to open stream: No such file or directory in /home/user/public_html/offers/index.php on line 64

Warning: include_once() [function.include]: Failed opening '.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/user/public_html/offers/index.php on line 64


can somebody fix this for me please



banik2010

5:13 am on Jun 1, 2010 (gmt 0)

10+ Year Member



The file name is not showing in include command and i already placed the offer pages in the same directory

Matthew1980

7:36 am on Jun 1, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi there banik2010,

Welcome to webmaster world!

Are you getting any output at all, reason I ask I because you (or whoever wrote the code) is mixing the quoting style:-

$myvar = "<h1>Hi there people<a href=\"mypage.php\">Click me</a></h1>\n\r";//Double quotes need 'toothpicks'
$myvar .= "<h1>another line of html<a href=\"anotherPage.php\">Click me</a></h1>\n\r";

$myvar = '<h1>Hi there people<a href="mypage.php">Click me</a></h1>\n\r';//Single quotes don't need escaping
$myvar .= '<h1>hello click this<a href="mypage.php">Click me</a></h1>\n\r';

I think that once you get the ambiguity of the quotes sorted, it will set you on the right way, not a guarantee but a start ;)

Cheers,
MRb

optik

2:28 pm on Jun 1, 2010 (gmt 0)

10+ Year Member



The variable $page is not been set, it should be set here

if(in_array($_POST['offer'][0],$offerNames)) {
$page = $offerDirectory . '/' . $_POST['offer'][0] . '.php';
}

This suggests there is no value for $_POST['offer'][0] which should be sent by your form, e.g a field with the name 'offer'.

I'm not sure why it is a two dimensional array, maybe that is the problem, if the form just is a single option or value field $_POST['offer']
would work instead of $_POST['offer'][0] throughout your code.

banik2010

2:50 pm on Jun 1, 2010 (gmt 0)

10+ Year Member



I cannot tell as i am not any programmer one of my friend wrote this code for me he is unavailable at this time so i need to work this out anybody can arite a code to show three offer pages one by one every page will set a cookie so that the user can not signup two times and then on the last offer page he wil be given the product signup link. Any body who can write the code for me i will really appreciate it