PHP Error with creating Log In


#4

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


#5

What is your website name??

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


#6

http://www.uwrfintervarsity.com/


#7

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


#8

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


#9

@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.


#10

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


#11

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


#12

Try out this tutorial


#13

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


#14

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


#15

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.


#16

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:


#17

Alright thanks for your help I will!


#18

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


#19

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.


#20

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:


#21

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.


#22

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


Membership Tutorial
#23

Black Friday Sale 90% OFF
0
DAYS
0
HOURS
0
MINUTES
0
SECONDS
×