PHP Error with creating Log In

I take back the changing URL part. The page loads for a second after accepting the correct credentials then doesn’t do anything else.

What is your website name??

is this the one “uwrfintervarsity.000webhostapp.com”??

1 Like

http://www.uwrfintervarsity.com/

Yes that is it. Am I just missing some code to redirect to the new page after logged in successfully?

Let me check what’s the issue and then i’ll get back to you.

1 Like

@stevenhayes97 Sry was bit busy,
First it’s not allowing me to log in.
There seems to be issue with after database query in you script, can you check and then try again.

I think the issue is in here:

$count=mysql_num_rows($result);
if{
$_SESSION[‘user’]= “user”;
$_SESSION[‘pwd’]= “pwd”;
header(“location:studentdatabaseview.php”);
}
else {
echo “Wrong Username or Password”;
}

I am playin garound with it

I changed the code to this:

$count=mysql_num_rows($result);

if($count==1){

session_register(“user”);
session_register(“pwd”);
header(“location:studentdatabaseview.php”);
}
else {
echo “Wrong Username or Password”;
}
ob_end_flush();

It does the else statement when the password is correct so it gets that far.

Now this is the error:

Call to undefined function session_register() in /storage/ssd5/582/2185582/public_html/login.php on line 28

Try out this tutorial

1 Like

Call to undefined function session_register()

session_register() is a very old function which has been ruled out since PHP 5.3 - 5.4

If you want to continue with your code you’ll have to change the PHP version: 000webhost cPanel > Settings > General > Change PHP version > 5.3

1 Like

Thanks I will give that a try if all else fails.

I got rid of all the session_register() functions.

I tried this; session_start();
if(!isset($_SESSION[‘username’])){
header(“Location:Login.php”);
}

But it just redirects me back to log in page no matter what.

It’s hard to debug the entire code. Also, I see you are using old functions such as mysql_*, which are deprecated and ruled out on newer PHP versions.

Please follow @ckhawand’s tutorial :wink:

2 Likes

Alright thanks for your help I will!

@stevenhayes97 Let us know if you face any issue, we’ll try to help you out :slight_smile:

Thanks I am close. I followed all the steps and I created an email address in the database with all required things, but it just tells me “incorrect credentials”. The only thing I changed was the destination after correctly logging in.

I’ll investigate your issue
You cannot add people like that to the database, the passwords are hashed before they are sent to the database, so add the signup page, register the users, then delete it :wink:

That worked! Thanks for all the help sorry I have so many questions. I am new to PHP, and I have never created a log in page before.

No problem :wink:
If you need any more help feel free to open a new topic or PM any moderator :slight_smile:

1 Like