Jump to content
Stef's Coding Community
Sign in to follow this  
lgabrielse

download files for login tutorial

Recommended Posts

Welcome to the forum, and I hope you are finding the videos useful. :)

 

This assumes you are a member of the KillerSites university... You can download the files by going to http://killersites.com/university/, logging in, and looking at the downloads within the PHP > PHP Login section.

 

I purchased the CompletePHP Programmer and downloaded it yesterday. I did 1-7 and now you give instruction to download.

Are you saying I need to pay for a subscription too now??

Share this post


Link to post
Share on other sites

Oh, sorry. I'm not super familiar with those packages -- Stefan handles that side of things. Can you PM me your email address, and I'll send you a link to the files?

 

I'll have to talk to Stefan about giving a place for people who download one of the "Complete" courses to find the source files. Sorry about that!

Share this post


Link to post
Share on other sites

Oh, sorry. I'm not super familiar with those packages -- Stefan handles that side of things. Can you PM me your email address, and I'll send you a link to the files?

 

I'll have to talk to Stefan about giving a place for people who download one of the "Complete" courses to find the source files. Sorry about that!

 

 

OK ... My Email is lgabrielse@verizon.net

 

Also, I am going crazy trying to find an error ... You will probably see it right away... :)

 

 

Do you see it on line 76 below, i.e. if ($check = $mysqli->("SELECT password FROM members WHERE id = ?"))

 

Parse error: syntax error, unexpected '(', expecting T_STRING or T_VARIABLE or '{' or '$' in C:\Inetpub\wwwroot\phproot\LoginKiller\change_password.php on line 76

 

Here is the code:

 

<?php

/*

* REGISTER.php

* Register New members

*/

 

//start session / load configs

session_start();

include('includes/config.php');

include('includes/db.php');

 

// check that the user is loggeed in

if(!isset($_SESSION['username']))

{

header("location: login.php");

}

 

// check for inactivity

if (time() > $_SESSION['last_active'] + $config['session_timeout'])

{

// log out user

session_destroy();

header("Location: login.php?timeout");

}

else

{

$_SESSION['last_active'] = time();

}

 

//form defaults

$error['alert'] = '';

$error['current_pass'] = '';

$error['pass'] = '';

$error['pass2'] = '';

$input['current_pass'] = '';

$input['pass'] = '';

$input['pass2'] = '';

 

if (isset($_POST['submit']))

{

// process form

if ($_POST['current_pass'] == '' || $_POST['password'] == '' || $_POST['password2'] == '')

{

// all fields need to be filled in

if ($_POST['current_pass'] == '') {$error['current_pass'] = 'required!';}

if ($_POST['password'] == '') {$error['pass'] = 'required!';}

if ($_POST['password2'] == '') {$error['pass2'] = 'required!';}

$error['alert'] = 'Please fill in the required fields!';

 

$input['current_pass'] = htmlentities($_POST['current_pass'], ENT_QUOTES);

$input['pass'] = htmlentities($_POST['password'], ENT_QUOTES);

$input['pass2'] = htmlentities($_POST['password2'], ENT_QUOTES);

// show form

include('views/v_password.php');

}

elseif ($_POST['password'] != $_POST['password2'])

{

// both password fields need to match

$error['alert'] = 'Password fields must match!';

 

$input['current_pass'] = htmlentities($_POST['current_pass'], ENT_QUOTES);

$input['pass'] = htmlentities($_POST['password'], ENT_QUOTES);

$input['pass2'] = htmlentities($_POST['password2'], ENT_QUOTES);

 

//show form

include('views/v_password.php');

 

}

else

{

// get data from form

$input['current_pass'] = $_POST['current_pass'];

$input['pass'] = $_POST['password'];

$input['pass2'] = $_POST['password2'];

 

if ($check = $mysqli->("SELECT password FROM members WHERE id = ?"))

{

$check->bind_param("s", $_SESSION['id']);

$check->execute();

$check->bind_result($current_pass);

$check->fetch();

$check->close();

}

if (md5($input['current_pass'] . $config['salt']) != $current_pass)

{

// error

$error['alert'] = "Your current password is incorrect!";

$error['current_pass'] = "incorrect";

include('views/v_password.php');

}

else

{

//update database

if ($stmt = $mysqli->prepare("UPDATE members SET password = ? where ID = ?"))

 

$stmt->bind_param("ss", md5($input['current_pass'] . $config['salt']), $_SESSION['id']);

$stmt->execute();

$stmt->close();

 

$error['alert'] = 'Member added successfully!';

//clear varaibles

$input['current_pass'] = '';

$input['pass'] = '';

$input['pass2'] = '';

include('views/v_password.php');

 

}

else

{

echo "ERROR: Could not prepare MYSQLi statement.";

}

}

}

else

{

 

include('views/v_password.php');

}

 

 

// close db connection

$mysqli->close();

 

?>

Share this post


Link to post
Share on other sites

I would need to double check, but I think that this line:

 

$mysqli->("SELECT password FROM members WHERE id = ?")

 

should be:

 

$mysqli->query("SELECT password FROM members WHERE id = ?")

 

...or something similar -- I can't remember the syntax off the top of my head. Double check my video.

 

EDIT: Just sent you the files.

Share this post


Link to post
Share on other sites

I would need to double check, but I think that this line:

 

$mysqli->("SELECT password FROM members WHERE id = ?")

 

should be:

 

$mysqli->query("SELECT password FROM members WHERE id = ?")

 

...or something similar -- I can't remember the syntax off the top of my head. Double check my video.

 

EDIT: Just sent you the files.

 

 

OK, Thanks

 

even though it is not in your video, adding the 'query' to the statement fixed it... Thank You!

 

Have a great weekend.. Leonard

Share this post


Link to post
Share on other sites
even though it is not in your video, adding the 'query' to the statement fixed it... Thank You!

Well, I'm not perfect, so it's possible I made an error in the video and you'll see me fix it a little later in the video when I tested things. I'm happy to hear that you got it fixed though.

Share this post


Link to post
Share on other sites
Sign in to follow this  

×
×
  • Create New...