Jump to content

[SOLVED] Wierd Error?


Crew-Portal

Recommended Posts

I have never seen this before. I just started making a new login script and about 3 minutes into it I started getting an error:

Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0

 

Here is the script

login.php

<?php
session_start();
?>
<form action="go.php" method="post">
  Username: <input type="text" name="username" />
  Password: <input type="password" name="password" />
  <input type="submit" value="Login" class="button">
</form>
<?php
echo $login_s;
?>
<?php if (isset($_POST['destroy'])) { //if login pressed
session_destroy();
} else { //else show form
?>
<form action="" method=post>
<input type=submit name=destroy value=Destroy Session!>
<?php } ?>

 

go.php

<?php
session_start();
$connection = @mysql_connect(localhost, ****, *******) or die("Couldn't connect.");
$db = @mysql_select_db(database, $connection) or die("Couldn't select database.");

$sql="SELECT * FROM user
WHERE username = \"$_POST[username]\" AND password = \"$_POST[password]\"";

$result = @mysql_query($sql,$connection) or print("<b>A fatal MySQL error occured</b>.\n<br />Query: " . $query . "<br />\nError: (" . mysql_errno() . ") " . mysql_error());
$num=mysql_num_rows($result);
while ($row = mysql_fetch_array($result)) {
$active = $row['active'];
$confirm = $row['confirm'];
}
if($num >0) {
if($active == "yes") {
$valid_user = $_POST['username'];
session_register("valid_user");
if (isset($valid_user)){
$login_s = 'You Have Been Sucessfully Logged In!';
}
include("index.php");
}
}
?>

 

Okay I do realize this script is not safe but As I said I started designing it 2 minutes ago so who really cares. The only problem is that I got this error. Could someone help? ::)

Link to comment
https://forums.phpfreaks.com/topic/63843-solved-wierd-error/
Share on other sites

How am I supposed to register variables in PHP5

 

session_registaer() was deprictaed long before php5.

 

A simpe example...

 

p1.php

<?php

  session_start();
  $_SESSION['foo'] = 'bar';
  echo '<a href="p2.php">link</a>';

?>

 

p2.php

<?php

  session_start();
  if (isset($_SESSION['foo'])) {
    echo $_SESSION['foo'];
  }

?>

 

No session_register() required.

 

Link to comment
https://forums.phpfreaks.com/topic/63843-solved-wierd-error/#findComment-318217
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.