Jump to content

Trouble with if statement?


Snooble

Recommended Posts

An if/else or if/elseif/else statement must start with if first.

 

Also if you are using sessions you must start the session first. Otherwise the session variables will not work.

 

So you code should be:

<?php
session_start();

if($_SESSION['points1'] == 1){
header("Location: cheater.php");
}

?>

<?php 
include 'sessionstartandsql.php';
include 'expire.php';

if(!isset($_SESSION['username'])){
   header("Location: mustlogin.php");
}
elseif($_SESSION['points1'] == 1){
header("Location: cheater.php");
}

$_SESSION['point'] = "".rand(0, 10).".".rand(0, 9)."".rand(0, 9).""; 

echo "You Scored:".$_SESSION['point']." points";

$result = $list['point'] + $_SESSION['point'];

echo "Your Total Points Are: ". $result;
$_SESSION['points1'] = 1;
$sql = "UPDATE wmusers SET point = '$result' WHERE username = '".$list['username']."' LIMIT 1";
mysql_query($sql) or die ("Couldn't execute $sql: " . mysql_error()); 

?>

 

full script. Apologies, session start's within the included files.

 

Snooble

Archived

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

×
×
  • 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.