Jump to content

need newbie help !!


adamriley

Recommended Posts

 

Red.php

<?php
require($_SERVER["DOCUMENT_ROOT"]."/Game/Main_one.php");

$spot = $_GET['Spot'];

if ($spot = "Lee") { $SESSION['dir'] = '3'; }
elseif ($spot = "Adam") { $SESSION['dir'] = '2'; }
else { $SESSION['dir'] = '1'; }

echo $SESSION['dir'];

$ss = $_SESSION['dir'];

require($_SERVER["DOCUMENT_ROOT"]."/Game/$ss/adam.php");

session_destroy();
?>

 

Main_one.php

<?php

session_start(); // start the session 


?>

 

When the url is "http://localhost/Game/red.php?Spot=Adam"

I hope that the $SESSION['dir'] = 2

But from echoing it is 3

This is the page i get

3
Warning: require(C:/xampp/htdocs/Game//adam.php) [function.require]: failed to open stream: No such file or directory in C:\xampp\htdocs\Game\Red.php on line 13

Fatal error: require() [function.require]: Failed opening required 'C:/xampp/htdocs/Game//adam.php' (include_path='.;\xampp\php\PEAR') in C:\xampp\htdocs\Game\Red.php on line 13

 

Any one tell me why

 

 

Link to comment
https://forums.phpfreaks.com/topic/201160-need-newbie-help/
Share on other sites

Correct Way:

<?php
require($_SERVER["DOCUMENT_ROOT"]."/Game/Main_one.php");

$spot = $_GET['Spot'];

if ($spot == "Lee") { $SESSION['dir'] = '3'; }
elseif ($spot == "Adam") { $SESSION['dir'] = '2'; }
else { $SESSION['dir'] = '1'; }

echo $SESSION['dir'];

$ss = $_SESSION['dir'];

require($_SERVER["DOCUMENT_ROOT"]."/Game/$ss/adam.php");

session_destroy();
?>

 

nevermind we all have done these things  :P

Link to comment
https://forums.phpfreaks.com/topic/201160-need-newbie-help/#findComment-1055387
Share on other sites

Thanks both of you for your quick reply and the if statement does work now but it does not require the file look for the gap

2
Warning: require(C:/xampp/htdocs/Game/            /adam.php) [function.require]: failed to open stream: No such file or directory in C:\xampp\htdocs\Game\Red.php on line 14

Fatal error: require() [function.require]: Failed opening required 'C:/xampp/htdocs/Game/                                                                           /adam.php' (include_path='.;\xampp\php\PEAR') in C:\xampp\htdocs\Game\Red.php on line 14

 

Link to comment
https://forums.phpfreaks.com/topic/201160-need-newbie-help/#findComment-1055394
Share on other sites

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.