Hey guys, I did have this working at one point but somehow I've broke it and unsure how to fix it as I've tried many methods but still not working.
I want to have it so on the front page if your not currently in a 'Heist' you see the main featue page which is some words, a start button and an invite section.
Then if you start a heist it should show a different page (heistinvite.php)
If you accept an invite it should send you to (heistaction.php)
if player 2 has accepted player one should go to (heistaction.php) instead of (heistinvite.php)
apologies in advance...btw I currently use dreamweaver while coding, is there any other softtware that would improve on my layout of coding?
CODE
if (isset($_SESSION['userid'])) {
// this is because i dont like MySQL timestamp i like the UNIX style
function revertheisttime($str) {
list($date, $time) = explode(' ', $str);
list($year, $month, $day) = explode('-', $date);
list($hour, $minute, $second) = explode(':', $time);
$timestamp = mktime($hour, $minute, $second, $month, $day, $year);
return $timestamp;
}
$q = "SELECT heisttimer FROM login WHERE id='".$_SESSION["userid"]."'";
$r = mysql_query($q);
$v = mysql_fetch_array($r);
$lastActive = revertheisttime($v['heisttimer']);
if (($lastActive + (60*60*12) - time() > 0)) { // 10*60 = 10 minutes change 10 to 5 if you want 5 min
// session expired send to index
$result = $lastActive + (60*60*12) - time();
$result2 = $result / 60;
echo 'You cannot commit another heist for '; echo ceil ($result2); echo' minutes.';
} else { ?>
<?
$user ="SELECT username, id FROM login WHERE id= '".$_SESSION["userid"]."'";
$result = mysql_query($user);
$row = mysql_fetch_assoc ($result);
$username = $row['username'];
$heist="SELECT player1, invitation, player2, reward FROM heist WHERE player1 = '".$username."'";
$heistresult = mysql_query($heist);
while ($rowi = mysql_fetch_array($heistresult)){
$player1 = $rowi['player1'];
$player2 = $rowi['player2'];
$invitation = $rowi['invitation'];
$reward = $rowi['reward'];
if ($player1 == $username && $player2 == ''){
header ('Location: heistinvite.php');
}else{
if ($player2 == $invitation){
header ('Location: heistaction.php');
$heist="SELECT player1, player2 FROM heist WHERE player2 = '".$username."'";
$heistresult = mysql_query($heist);
while ($rowi = mysql_fetch_array($heistresult)){
$player1 = $rowi['player1'];
$player2 = $rowi['player2'];
if ($player2 == $username){
header ('Location: heistaction.php');
}else{
?>
(You must be at least rank 2 to attempt a Heist)<br><br>
To perform a Getaway, you and your partner must be in the same state. You must use a stabled animal of your choice as well as your partner purchasing extra equipment.
It will cost you $5,000 to start a Getaway. Please be advised that once started you will not be able to cancel unless you wish to lose your deposit.<br><br>
<form action="startheist.php" method="post">
<input type="submit" value="Begin Heist"></form>
<br><br><b>Invites</b><br>
<form action="heistaccept.php" method="post">
<table border="1" bordercolor="#000000">
<?php
$heist="SELECT player1, invitation FROM heist WHERE invitation = '".$username."'";
$heistresult = mysql_query($heist);
$rowi = mysql_fetch_array($heistresult);
$player1 = $rowi['player1'];
echo'<tr><td>Invitation From</td><td><input type="checkbox" name="inviter" value="'.$player1.'"> ';echo $player1; echo'</td></tr>
'; ?><br><br></table>
<input type="submit" value="Accept!"><input type="submit" name="deny" value="Deny!"></form>
<? }} }}} }}?>