Please make me understand :)
Please make me understand :)
Hello.
I love the videos and are working on them each day now.
I have to things right now that I can´t seem to work out.
Strict Standards: Only variables should be passed by reference in C:\xampp\htdocs\testtest\core\init.inc.php on line 7
Fatal error: Call to undefined function shal() in C:\xampp\htdocs\testtest\inc\user.inc.php on line 24
If I delete the shal function I only have the strict standards.
A other thing, I had to make the FIle path = $path = dirname(_FILE_); - - - - - - it just have ' ' more then in the video but now it works. $path = dirname('_FILE_'); this one works for me.
however I can´t work out the to other problems I have..
Best Regards
Wizzuriz
I love the videos and are working on them each day now.
I have to things right now that I can´t seem to work out.
Strict Standards: Only variables should be passed by reference in C:\xampp\htdocs\testtest\core\init.inc.php on line 7
Fatal error: Call to undefined function shal() in C:\xampp\htdocs\testtest\inc\user.inc.php on line 24
If I delete the shal function I only have the strict standards.
A other thing, I had to make the FIle path = $path = dirname(_FILE_); - - - - - - it just have ' ' more then in the video but now it works. $path = dirname('_FILE_'); this one works for me.
however I can´t work out the to other problems I have..
Best Regards
Wizzuriz
Re: Please make me understand :)
I may have missed this but I checked and I don't think I have, but what tutorial is this for?
And can we also have a look at your code and we will do our best to help you as with out them we cannot really help.
Sorry if I did miss the tutorial name!
And can we also have a look at your code and we will do our best to help you as with out them we cannot really help.
Sorry if I did miss the tutorial name!
I can't think of anything witty to put here!
Check out some of my projects on GitHub: https://github.com/DomTC
Check out some of my projects on GitHub: https://github.com/DomTC
Re: Please make me understand :)
It seems like you're typing shal() when the function is sha1.
Re: Please make me understand :)
wizzuriz wrote:Fatal error: Call to undefined function shal() in C:\xampp\htdocs\testtest\inc\user.inc.php on line 24
JelvinJS7 wrote:It seems like you're typing shal() when the function is sha1.
It should be __FILE__ not _FILE_ with two _ either side.wizzuriz wrote:A other thing, I had to make the FIle path = $path = dirname(_FILE_); - - - - - - it just have ' ' more then in the video but now it works. $path = dirname('_FILE_'); this one works for me.
This is php being ultra picky about the coding style, you can safely hide these errors by addingwizzuriz wrote:Strict Standards: Only variables should be passed by reference in C:\xampp\htdocs\testtest\core\init.inc.php on line 7
error_reporting(E_ALL & ~E_STRICT);To the top of the file (in the init.inc.php file would be easiest)
Re: Please make me understand :)
Hello Again.
First thanks for the fast replay, second sorry for not uploading the code.
The sha1 is now fine, thanks. hard to see it was a 1 and not a l in the video. ( shaOne)
First thanks for the fast replay, second sorry for not uploading the code.
The sha1 is now fine, thanks. hard to see it was a 1 and not a l in the video. ( shaOne)
<?php
session_start();
$exceptions = array('register', 'login');
$page = substr(end(explode('/', $_SERVER['SCRIPT_NAME'])), 0, -4); --- This is the 7 line that is giving my problems
if (in_array($page, $exceptions) === false){
if (isset($_SESSION['username']) === false){
header('location: login.php');
die();
}
}
mysql_connect('localhost', 'root', '');
mysql_select_db('user_system');
$path = dirname('_FILE_');
include("{$path}/inc/user.inc.php");
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<?php
// put your code here
?>
</body>
</html>
Last edited by jacek on Tue Jul 26, 2011 1:45 pm, edited 1 time in total.
Reason: code tags...
Reason: code tags...
Re: Please make me understand :)
jacek wrote:This is php being ultra picky about the coding style, you can safely hide these errors by addingwizzuriz wrote:Strict Standards: Only variables should be passed by reference in C:\xampp\htdocs\testtest\core\init.inc.php on line 7
error_reporting(E_ALL & ~E_STRICT);To the top of the file (in the init.inc.php file would be easiest)
Re: Please make me understand :)
Hi.
Thanks, that is now in the init.inc.php file and I don´t see the error anymore.
Now I did all videos and got it all working and when I got to the cookie part I got a problem.
I did check all the new code 5 times and I can´t see what the error is.
I can´t upload the php file what is best word or?
Best regards
Wizzuriz.
PS. if you are doing the video on user admin and user levels please let me know as I really like to see that.
Thanks, that is now in the init.inc.php file and I don´t see the error anymore.
Now I did all videos and got it all working and when I got to the cookie part I got a problem.
I did check all the new code 5 times and I can´t see what the error is.
I can´t upload the php file what is best word or?
Best regards
Wizzuriz.
PS. if you are doing the video on user admin and user levels please let me know as I really like to see that.
Re: Please make me understand :)
Unless you tell me what that problem is I cant helpwizzuriz wrote:Now I did all videos and got it all working and when I got to the cookie part I got a problem.
I may do, but I am a bit bored of user account stuff so it won;t be any time soon.wizzuriz wrote:PS. if you are doing the video on user admin and user levels please let me know as I really like to see that.
Re: Please make me understand :)
Hi again.
I don´t really know what the problem is, I tried to check the files my self but I can´t see any thing that is not like in the video.
what code are you doing right now? I might have some fun for you if you like a challenge.
Best regards
wizzuriz
I don´t really know what the problem is, I tried to check the files my self but I can´t see any thing that is not like in the video.
if (valid_credentials($_POST['username'], sha1($_POST['password'])) === false){ $errors[] = 'Username / Password incorrect.'; } if (empty($errors)){ if (isset($_POST['set_cookie']) && $_POST['set_cookie'] == '1'){ setcookie('username', $_post['username'], time() + 6048000); setcookie('password', sha1($_post['password']), time() + 6048000); } $_SESSION['username'] = htmlentities($_POST['username']); header('location: protected.php'); die(); }That should be all fine..
what code are you doing right now? I might have some fun for you if you like a challenge.
Best regards
wizzuriz
Last edited by jacek on Wed Jul 27, 2011 1:42 pm, edited 1 time in total.
Reason: code tags...
Reason: code tags...
Re: Please make me understand :)
This is my Init.inc.php file
error_reporting(E_ALL & ~E_STRICT); session_start(); $exceptions = array('register', 'login'); $page = substr(end(explode('/', $_SERVER['SCRIPT_NAME'])), 0, -4); mysql_connect('localhost', 'root', '0"'); mysql_select_db('user_system'); $path = dirname(__FILE__); include("{$path}/inc/user.inc.php"); if (isset($_COOKIE['username'], $_COOKIE['password']) && isset($_SESSION['username']) === false){ if (valid_credentials($_COOKIE['username'], $_COOKIE['password'])){ $_SESSION['username'] = htmlentities($_COOKIE['username']); setcookie('username', $_COOKIE['username'], time() + 604800); setcookie('password', $_COOKIE['password'], time() + 604800); } } if (in_array($page, $exceptions) === false){ if (isset($_SESSION['username']) === false){ header('location: login.php'); die(); } }
Last edited by jacek on Wed Jul 27, 2011 1:42 pm, edited 1 time in total.
Reason: code tags...
Reason: code tags...
Re: Please make me understand :)
on register I have
if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) === false){ $errors[] = 'The E-mail address you entered does not appear to be valid.'; } <p> <lable for="email">E-mail:</lable> <input type=="text" name="email" id="email" value="<?php if (isset($_POST['email'])) echo htmlentities($_POST['email']); ?>" /> </p> This is the user.inc.php file // adds a user to the database. function add_user($user, $email, $pass){ $user = mysql_real_escape_string(htmlentities($user)); $email = mysql_real_escape_string($email); $pass = sha1($pass); $charset = array_flip(array_merge(range('a', 'c'), range('A', 'Z'), range(0, 9))); $aid = implode('', array_rand($charset, 10)); $body = <<<EMAIL Hi, Thanks for registering, before you can login you need to activate your account. To do that simply click the following link. http://192.168.0.10/usersystem/activate.php={$aid} EMAIL; mail($email, 'you new account at intesira.com', $body, 'From: admin@intesira.com'); // insert into database, table_name user : colum user_name, & colum user_password. mysql_query("INSERT INTO `users` (`user_name`, `user_password`, `user_email`) VALUES ('{$user}', '{$pass}', '{$email}')"); $user_id = mysql_insert_id(); mysql_query("INSET INTO `user_activations` (`user_id`, `activation_code`) VALUE ({$user_id}, '{$aid}')"); }I don´t believe that there is anymore change in the code then that.
Last edited by jacek on Wed Jul 27, 2011 1:43 pm, edited 1 time in total.
Reason: code tags...
Reason: code tags...
Re: Please make me understand :)
What is the problem now ?
Also, please use the code buttons when posting code !
Also, please use the code buttons when posting code !
Re: Please make me understand :)
The problem is that I don´t get a E-mail with the link, I don´t see the activation code in the database and no user id. I can register fine and the E-mail go in to the users tabel but nothing in the user_activations
Sorry for the code posting.
Sorry for the code posting.
function user_exists($user){ $user = mysql_real_escape_string($user); $total = mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `user_name` = '{$user}'"); return (mysql_result($total, 0) == '1') ? true : false; } // checks if the given username and password combination is valid. function valid_credentials($user, $pass){ $user = mysql_real_escape_string($user); $pass = mysql_real_escape_string($pass); $total = mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `user_name` = '{$user}' AND `user_password` = '{$pass}'"); return (mysql_result($total, 0) == '1') ? true : false; } // adds a user to the database. function add_user($user, $email, $pass){ $user = mysql_real_escape_string(htmlentities($user)); $email = mysql_real_escape_string($email); $pass = sha1($pass); $charset = array_flip(array_merge(range('a', 'c'), range('A', 'Z'), range(0, 9))); $aid = implode('', array_rand($charset, 10)); $body = <<<EMAIL Hi, Thanks for registering, before you can login you need to activate your account. To do that simply click the following link. http://192.168.0.10/usersystem/activate.php={$aid} EMAIL; mail($email, 'you new account at website test.com', $body, 'From: admin@website.com'); // insert into database, table_name user : colum user_name, & colum user_password. mysql_query("INSERT INTO `users` (`user_name`, `user_password`, `user_email`) VALUES ('{$user}', '{$pass}', '{$email}')"); $user_id = mysql_insert_id(); mysql_query("INSET INTO `user_activations` (`user_id`, `activation_code`) VALUE ({$user_id}, '{$aid}')"); }
Re: Please make me understand :)
You email is probably running into spam filtering on what ever host you are sending it to. Or you may not have a SMTP server set up properly. But lets deal with the other problem first.
Try adding
Try adding
echo mysql_error();after the failing query and see if it tells you why the row is not being inserted.
Re: Please make me understand :)
When are you breaking out of php?wizzuriz wrote:if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) === false){ $errors[] = 'The E-mail address you entered does not appear to be valid.'; } //shouldn't there be a ?> here? <p> //now we're in HTML <lable for="email">E-mail:</lable>
Re: Please make me understand :)
I´m sorry, its because its very bad explained by me. its just a small bit of all this code.JelvinJS7 wrote:When are you breaking out of php?wizzuriz wrote:if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) === false){ $errors[] = 'The E-mail address you entered does not appear to be valid.'; } //shouldn't there be a ?> here? <p> //now we're in HTML <lable for="email">E-mail:</lable>
<?php include('core/init.inc.php'); $errors = array(); if (isset($_POST['username'], $_POST['password'], $_POST['repeat_password'])){ if (empty($_POST['username'])){ $errors[] = 'The username cannot be empty.'; } if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) === false){ $errors[] = 'The E-mail address you entered does not appear to be valid.'; } if (empty($_POST['password']) || empty($_POST['repeat_password'])){ $errors[] = 'The password cannot be empty.'; } if ($_POST['password'] !== $_POST['repeat_password']){ $errors[] = 'Password verification failed.'; } if (user_exists($_POST['username'])){ $errors[] = 'The username you entered is already taken.'; } if(empty($errors)){ add_user($_POST['username'], $_POST['email'], $_POST['password']); header('location: protected.php'); die(); } } ?>
Re: Please make me understand :)
Hello Again.
I did a review of all the videos checking all the code and now I get the activations code in the user_activations table.
Now my problem is that Even before I click the link I don´t get because my mail is not working ( not in spam or junk ) I can still log in even with the activations code in the database. I did try to check the code that checks for activations code but I don´t see any thing.
Btw, my cookie is not working
Now I´m on my 3 book on php & Mysql for beginners and its starting to make sense what your saying in all the videos. still some small problems but its getting better.
Thanks for all the help, I really like your videos and forum
Take care, best regards
Wizzuriz
I did a review of all the videos checking all the code and now I get the activations code in the user_activations table.
Now my problem is that Even before I click the link I don´t get because my mail is not working ( not in spam or junk ) I can still log in even with the activations code in the database. I did try to check the code that checks for activations code but I don´t see any thing.
Btw, my cookie is not working
Now I´m on my 3 book on php & Mysql for beginners and its starting to make sense what your saying in all the videos. still some small problems but its getting better.
Thanks for all the help, I really like your videos and forum
Take care, best regards
Wizzuriz