0

I want to create a login member area for a website. This is the form I use to log in:

<table width="300" border="0"       

align="center" cellpadding="0"  

cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form name="form1" method="post" action="/mainsite/home/login/validate_login.php">
<td>
<table width="100%" border="0"   cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td colspan="3"><strong>Member Login   

</strong></td>
</tr>
<tr>
<td width="78">Username</td>
<td width="6">:</td>
<td width="294"><input  

name="myusername" type="text"  

id="myusername"></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input name="mypassword"   

type="text" id="mypassword"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><input type="submit" name="Submit"   

value="Login"></td>
</tr>
</table>
</td>
</form>
</tr>
</table>

So I have this code for the page that the form data gets sent to

<?php

$host="localhost"; // Host name 
$username=""; // Mysql username 
$password=""; // Mysql password 
$db_name="test"; // Database name 
$tbl_name="members"; // Table name 

// Connect to server and select databse.
mysql_connect("$host", "$username",      

"$password")or die("cannot connect"); 
mysql_select_db("$db_name")or    

die("cannot select DB");

// username and password sent from form 
$myusername=$_POST['myusername']; 
$mypassword=$_POST['mypassword']; 

// To protect MySQL injection (more detail    

about MySQL injection)
$myusername =    

stripslashes($myusername);
$mypassword =                

stripslashes($mypassword);
$myusername =    

mysql_real_escape_string($myusername);
$mypassword =   

mysql_real_escape_string($mypassword);
$sql="SELECT * FROM $tbl_name  

WHERE username='$myusername' and  

password='$mypassword'";
$result=mysql_query($sql);

// Mysql_num_row is counting table row
$count=mysql_num_rows($result);

// If result matched $myusername and    

$mypassword, table row must be 1 row
if($count==1){

// Register $myusername, $mypassword     

and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword"); 
header("location:login_success.php");
}
else {
echo "Wrong Username or Password";
}
?>

However, when I try to log in, it gives me this error:

Fatal error: Call to undefined function session_register() in /home/scaledtothee/public_html/mainsite/home/login on line 33

What does this mean?

RiggsFolly
  • 89,708
  • 20
  • 100
  • 143
David
  • 23
  • 6
  • session_register has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0 – Pardeep Poria May 08 '16 at 11:48
  • 1
    It means exactly what it says. You are using a function the software has no knowledge of. If you had copy pasted the function in Google you would have found more than a few topics on this. One of them being this one http://stackoverflow.com/questions/3682615/how-to-fix-the-session-register-deprecated-issue. Please search before posting. – RST May 08 '16 at 11:51
  • I actually did search it...I've been searching it for the past two weeks... What made you think I didn't? – David May 08 '16 at 11:55
  • _What made you think I didn't?_ The fact it was so easy to search and find many answers. What version of PHP are you using. – RiggsFolly May 08 '16 at 12:07

1 Answers1

1

session_register has deprecated since PHP 5.3
Instead of session_register use $_SESSION[ ]

rocky
  • 608
  • 4
  • 14