Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

php problems

Status
Not open for further replies.

Rizzler

Technical User
Feb 9, 2006
43
SE
hello

would there be any big change in PHP 5.1.1 and 5.1.4?

i run PHP 5.1.4 on my php server and this php script get's like this,
my first thout was that PHP is NOT running but it is and
there, PHP works

as seen above PHP do WORK on my server since i run other php scripts and so on and i run php 5.1.4

i just now uploaded the same php files (with the exact same settings, i changed noyhing, just uploaded the php files) to a friends server with PHP 5.1.1 and it works as seen here,

anyone have any ideas? the script is in the same folder as ss2k and phpinfo on my own webserver.
 
on one box you have short open tags (<?) enabled and on the other box you do not (and thus need to use <?php ... ?> to tell php to parse between the tags).

change your php.ini file to set the directive to On and then restart your web server. better still recode your scripts to be more cross-server compliant.
 
Edit: i added error showing to the php file now and got

Parse error: parse error, unexpected T_DO in Q:\Webroot\station\config.php on line 54

on line 54 we have $dblogin["host"] = "81.227.82.55";

why do this give a parse error on my server and not on my friends ?
 
uncertain. probably the error lies in one of the lines above or below 54. you have not posted the code so i can only guess.
 
i got it to work now jpadie, thanks! :D i got another question for you thou.

if you check you get redirected to playing.php, in the bottom left corner you have a login form. this login form is for the forums @
when someone logs in trou the login form on any page at they get redirected over to the login form resides in a file caled partners.php and i wonder how i can make the login form nor redirect users to the forum but insted just reload the current page they are on so if they login on for example they stay there and wont get redirected on to the forum. the code for my script is bellow.

someone said i can set a variable in each file that stores the local redirection string for a login or something similiar but then how would i do that, or do you know any other way?

Partner.php
*****************************
<?
define('IN_PHPBB', true);
$phpbb_root_path = '../forum/';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//
?>

<?php if(!$userdata['session_logged_in'] || $userdata['user_id'] == -1){ ?>
<form action="../forum/login.php" method="post"><input type="text" name="username"><br /><input type="password" name="password"><br />
<input type="submit" value="login" name="login"></form>
<?php } else { ?>
You are logged in as user "<?php echo $userdata['username']?>"
<?php } ?>
 
not answering your question directly....

the way i handle user authentication is the following:

1. create a file that has all your user handling routines in it. this includes the display of a login box etc. call this login.php.

2. the login.php file essentialy does this:

a. starts a session
b. checks whether the right session keys exist for the user that identifies them as logged in. if so, it updates the last logged in time and ends gracefully.
c. if not, it displays the login form and stops running (with die() or exit() to prevent further code execution). the login form, of course, points towards the value of PHP_SELF to ensure proper handling of the request

3. in each page that i wish protected I include the following as the first line of the page (above all other content)
Code:
require_once "login.php";

in case 2(b) if a user is logged in or logs in correctly then the normal (anticipated) page is presented to the user and no redirection is performed.

i very very very rarely use header("Location ..."). I don't like the way that it can muck around with sessions (if using transid or forgetting to explicitly close the session first) and I tend to code using the dispatch method which obviates the need for redirects. The exception to the rule is for forgotten password pages.
 
i should add:


1. please use more helpful titles to your threads in future. remember that other people will benefit from browsing the forum, seeing your questions and the solutions to them (if any). a helpful and descriptive title will make their browsing experience more fruitful.

2. please post each separate question in a different thread (for the same reason).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top