PHP Include Help

Hello,

I am working on a project for a friend. It’s a simple button counter, that also loads a random page on button click as well. I am try to put the pages loaded above the button, and the counter below the button. The form is html while the page loader and counter are php. I have tried separating the functions, I have tried moving the form above the php code, but all this does is place the button above both the pages being loaded, and the counter as well. This will not work, here is the following php and html:

[php]<?php

function clickInc()
{
$mypages = array(“test1.html”, “test2.html”, “test3.html”);
$myrandompage = $mypages[mt_rand(0, count($mypages) -1)];
include ($myrandompage);
///////////////////////////
$count = (“clickcount.txt”);
$maxcount = 939;
$clicks = file($count);
$clicks[0]++;
$fp = fopen($count, “w”) or die(“Can’t open file”);
fputs($fp, “$clicks[0]”);
fclose($fp);
echo “
$myrandompage”;
echo ‘
’.$clicks[0].’’;

if ($clicks[0] == $maxcount) 
{
  echo "<br>Your Code Is: 156845246";
}

}
if( isset($_POST[‘ralphie_x’]) )
{

clickInc();

}
?>[/php]

[code]

    <form action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
      <input type="image" src="b1.png" onMouseOver="this.src='b2.png'" onMouseOut="this.src='b1.png'" onClick="this.src='b1.png'" name="ralphie">
    </form>

[/code]

I know the code is noobish, I’m not pro at this. But I hope that there is someone out there that can help me. I know there are formatting issues and things like that, my concern is simple, putting the pages above the button as it is now, and putting the counter echo below the form. I have tried to just “put” it there with simple echo code but that don’t work. Any help is appreciated, thanks.

Fixed my own issue. This is “solved” now.

Sponsor our Newsletter | Privacy Policy | Terms of Service