1. How do I make users be able to change their password?
I'm using a MySQL
2. How do I express the time? I've already got the date but I don't know how to do the time. Thanks!
Printable View
1. How do I make users be able to change their password?
I'm using a MySQL
2. How do I express the time? I've already got the date but I don't know how to do the time. Thanks!
The question is too broad.
Not enough information to know how you currently have the users registered and logged-in.
They have to be logged-in to change their password. So you must already have the login?
And no way to show you a script because my script examples will be for a totally different
MySQL setup, and my scripts will be nothing like what you currently have for your site.
Date and time ...
You have to define a timezone, because a guy in Australia will be viewing your site one
day ahead of you.
Start here:
http://php.net/manual/en/function.da...mezone-set.php
then:
http://php.net/manual/en/timezones.php
Now, determine if you want to use MySQL date/time column types, or do you want to use UNIX time?
Again ... not enough information to answer this.
Alright, let's tackle the password change first. I'm using a MySQL databse with PHP. They register with their email and username, and it emails them a randomly generated password. I want them to be able to change it (currently they can't).
This free script (PHP/MySQL) will give you a lot of examples on what to do.
http://php-login-script.com/
It allows users to register, confirm it by email (which you have now), and then login.
When they login, they have a "profile" page where they can change information about
themselves, as well as password.
An "admin" person can also view and change all users information.
I think you'll see a lot there by downloading and looking at the scripts.
Perhaps you'll want to implement that script. Customize the HTML/CSS so it
looks the way you want on your website.
Funny, I was going to use that script yesterday but I found one that looked much eaier and only required two files. Instead of like 10. I mean, since there's gonna be hundreds of files a few won't make a difference... however, on the other hand, I want to keep it as simple as possible.
Can I stick with the one I'm using?
Isn't there just some PHP code I can use to interact with the database to change the password?
Thank you!
Sure there is, but you have to write it all.
You have to make a form that displays so the user enters their current password,
and then enters the new password twice. If the two new passwords don't match,
you go back and tell them to try again. Then, you process it and update their row
in the database table ... then you email them letting them know the password changed.
You also need to allow the admin login to change the users' profile. There are different
levels of users 1-9 ... where 9 would be the admin person that can do everything.
That's a lot of scripting ... but go for it if you want.
F*** it, I just used the Php-Login-Script :)
Alright so I read the timezone thing; but it doesn't make sense. How do I even show the time (I don't care about timezone, I can add that later)
You'll use PHP's date function. It can grab the current time down to the microsecond!
So looking at the documentation, if I wanted to have the date to show as 17:32 which is the time looking at the clock now, I'd use G (24-hour format of the hour) and i which is the minutes with leading zeros. So <?php echo date("G:i"); ?>
PHP Code:
<?php
// set the server timezone to be your time (in California).
date_default_timezone_set('America/Los_Angeles');
echo date("m-d-Y H:i:s");
?>