Need Login/Register page helps
Moderator: General Moderators
-
terror2012
- Forum Newbie
- Posts: 3
- Joined: Wed Apr 15, 2015 9:32 am
Need Login/Register page helps
Hello. I tried until today around 50 tutorials. After it I tried myself but nothing works. I just don't know why it's not working.
Every php login/register page I created have some errors. Sometime, the session don't start. Sometime I got a bunch of errors. Can someone give me a simple login page with username and password (which get the encrypted md5 pass from database and check it with current) and if the data are correct, this page should start a session with username and a register page with username, password and email? I just need php scripts.
I'm a php beginner and even with a lot of youtube tutorials, I couldn't do this login. I know the basics of php, but until now I didn't make any serious php script.
Thanks.
Every php login/register page I created have some errors. Sometime, the session don't start. Sometime I got a bunch of errors. Can someone give me a simple login page with username and password (which get the encrypted md5 pass from database and check it with current) and if the data are correct, this page should start a session with username and a register page with username, password and email? I just need php scripts.
I'm a php beginner and even with a lot of youtube tutorials, I couldn't do this login. I know the basics of php, but until now I didn't make any serious php script.
Thanks.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Need Login/Register page helps
Or, if you show us the code that makes the most sense to you, we could walk you through getting it to work.
(#10850)
Re: Need Login/Register page helps
Hi everyone,
I'm facing almost same helps. After searching I've found a script which looks good. Here's the link :
http://www.wikihow.com/Create-a-Secure- ... -and-MySQL
I've written all the codes as perfect as possible. But after starting Apache when I'm trying to run index.php. It fails with an error in terminal :
I've also created a database with the same name. If you want I can post the database list screen shot here.
Maybe I can't make this work, as I'm so new to PHP, but I believe with your help guys, I can make this work.
Please help. Thanks in advance.
I'm facing almost same helps. After searching I've found a script which looks good. Here's the link :
http://www.wikihow.com/Create-a-Secure- ... -and-MySQL
I've written all the codes as perfect as possible. But after starting Apache when I'm trying to run index.php. It fails with an error in terminal :
At the line 7 of psl-config.php, this line exists :PHP Parse error: syntax error, unexpected 'define' (T_STRING) in /var/www/html/psl-config.php on line 7
Code: Select all
define("DATABASE", "secure_login");Maybe I can't make this work, as I'm so new to PHP, but I believe with your help guys, I can make this work.
Please help. Thanks in advance.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Need Login/Register page helps
According to the link you gave, that line is in the script:fahim wrote:I've written all the codes as perfect as possible. But after starting Apache when I'm trying to run index.php. It fails with an error in terminal :
At the line 7 of psl-config.php, this line exists :PHP Parse error: syntax error, unexpected 'define' (T_STRING) in /var/www/html/psl-config.php on line 7
Code: Select all
define("DATABASE", "secure_login");
Code: Select all
<?php
/**
* These are the database login details
*/
define("HOST", "localhost"); // The host you want to connect to.
define("USER", "sec_user"); // The database username.
define("PASSWORD", "eKcGZr59zAa2BEWU"); // The database password.
define("DATABASE", "secure_login"); // The database name.
define("CAN_REGISTER", "any");
define("DEFAULT_ROLE", "member");
define("SECURE", FALSE); // FOR DEVELOPMENT ONLY!!!!
?>(#10850)
Re: Need Login/Register page helps
Really thanks for your reply.
Still unable to find the error in the code
.
Here's the full code :
I believe you'll find it.
Still unable to find the error in the code
Here's the full code :
Code: Select all
<?php
// These are the database login details
define("HOST", "localhost"); // The host you want to connect to.
define("USER", "sec_user"); // The database username.
define("PASSWORD", "eKcGZr59zAa2BEWU") // The database password.
define("DATABASE", "secure_login"); // The database name.
define("CAN_REGISTER", "any");
define("DEFAULT_ROLE", "member");
define("SECURE", FALSE); // FOR DEVELOPMENT ONLY!!!!
?>- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Need Login/Register page helps
Can you see what is missing in the line before the error?
Code: Select all
define("PASSWORD", "eKcGZr59zAa2BEWU") // The database password.(#10850)
Re: Need Login/Register page helps
Ufffff !!!! Now I can see it !!! Just a semicolon !!! I'll add it and post the o/p here.
Thank you very much.
Thank you very much.
Re: Need Login/Register page helps
Sorry for late post 
Now when I want to run index.php, the following error appears :
I can't understand the PHP Warning error, as I've jsut copied and pasted the username and password 
Regarding the final one PHP Parse error, I can't also understand it correctly. The code is here :
I'm drowning in the errors 
Now when I want to run index.php, the following error appears :
First four errors are complaining about "undefined constant" in the db_connect.php file. But I can't find any problems in the code. The code is here :PHP Notice: Use of undefined constant localhost - assumed 'localhost' in /var/www/html/includes/db_connect.php on line 3
PHP Notice: Use of undefined constant sec_user - assumed 'sec_user' in /var/www/html/includes/db_connect.php on line 3
PHP Notice: Use of undefined constant eKcGZr59zAa2BEWU - assumed 'eKcGZr59zAa2BEWU' in /var/www/html/includes/db_connect.php on line 3
PHP Notice: Use of undefined constant secure_login - assumed 'secure_login' in /var/www/html/includes/db_connect.php on line 3
PHP Warning: mysqli::mysqli(): (28000/1045): Access denied for user 'sec_user'@'localhost' (using password: YES) in /var/www/html/includes/db_connect.php on line 3
PHP Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR) in /var/www/html/includes/functions.php on line 31
Code: Select all
<?php
include_once 'psl-config.php'; // As functions.php is not included
$mysqli = new mysqli(localhost, sec_user, eKcGZr59zAa2BEWU, secure_login);
?>Regarding the final one PHP Parse error, I can't also understand it correctly. The code is here :
Code: Select all
if ($stmt = mysqli->prepare("SELECT id, username, password, salt FROM members WHERE email = ? LIMIT 1"))- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Need Login/Register page helps
Looks like you need some quotes around the string parameters:
Code: Select all
$mysqli = new mysqli(localhost, sec_user, eKcGZr59zAa2BEWU, secure_login);(#10850)
Re: Need Login/Register page helps
OH Christopher !!! Really thanks for the help.
After putting the quotes around the string parameters, it is much better. First four messages is now gone, only last two are there. Here it is :
Best regards.
After putting the quotes around the string parameters, it is much better. First four messages is now gone, only last two are there. Here it is :
Please help.PHP Warning: mysqli::mysqli(): (28000/1045): Access denied for user 'sec_user'@'localhost' (using password: YES) in /var/www/html/includes/db_connect.php on line 3
PHP Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR) in /var/www/html/includes/functions.php on line 31
Best regards.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Need Login/Register page helps
Well ... they mean exactly what they say. You don't show the code, but you should be able to find the problems.
On line 3 it is trying to connect to the database with user 'sec_user'@'localhost' and the supplied password, but the user does not have access to this database or the password is wrong, or the connection failed altogether, etc.PHP Warning: mysqli::mysqli(): (28000/1045): Access denied for user 'sec_user'@'localhost' (using password: YES) in /var/www/html/includes/db_connect.php on line 3
On line 31, somewhere before the '->' there is a syntax error that is causing the parser to not know what to do when it reaches the '->'. Once you fix the error, the '->' will make sense to the parser.PHP Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR) in /var/www/html/includes/functions.php on line 31
(#10850)
Re: Need Login/Register page helps
Thanks for the clarification. user access problem is solved already. Working with the "syntax error" now.
Re: Need Login/Register page helps
Christopher, I've to thank you again, because according to your advice I've solved both of the errors.
But now I'm facing a new error. This time it's showing :
[text]PHP Notice: Undefined variable: secure in /var/www/html/includes/functions.php on line 20[/text]
The line 20 is a simple variable. You can check here :
Fact is that, I've checked several times to find the mistake on the line 20, but failed to get any error comparing with the main script. I even copy pasted the code,but same errors continues.
I believe you'll show me some lights.
Thanks in advance.
But now I'm facing a new error. This time it's showing :
[text]PHP Notice: Undefined variable: secure in /var/www/html/includes/functions.php on line 20[/text]
The line 20 is a simple variable. You can check here :
Code: Select all
// Gets current cookies params.
$cookieParams = session_get_cookie_params();
session_set_cookie_params($cookieParams["lifetime"],
$cookieParams["path"],
$cookieParams["domain"],
$secure,
$httponly);I believe you'll show me some lights.
Thanks in advance.
Re: Need Login/Register page helps
That shows where $secure is being called. Where is it being defined? You should see $secure = some_value_here farther up. Alternately, var_dump($secure) to check.