PHP account system - php

I have a complicate question which I can't find answers from online, or maybe I just don't know the best word to describe it,but hopefully you all and help out little bit, thanks you so much.
I want to create a user account system in php
I know how to store user date when they registra an account in form, but next time when people log in how do you know whether they has an account already or not, other words how do you validate their username and password when they come to your side.

You must store the users data they provide on sign up, using a database such as MySQL or a flat-file system such as this class.
May I suggest you search up tutorials etc. using Google or Bing, if you look hard enough you can find anything on the internet ;)
You can always try this out - PHP Login
Dom.
Ps- check out PHPSquad, Tizag and w3schools they helped me massively when first learning PHP!

It is better if you use SQL database to store the users so you have to create a register page to insert the user data into the SQL database then a login page to read the user data from the database and you can make a profile page with the data you asked to the user on the register form you can do this with ASP and PHP I recomend you PHP cause is easier.
Here is a link that shows how to make a simple user registration system with PHP and MySQL but you have to add some security to your system.

Related

Whenever a new user registers, he keeps seeing the data entered by another user in my php project [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
Please how can I make every new user not to have access to another user data in php script, Am already on a live server and whenever a new user registers and enters his dashboard he will be seeing the database of another registered user. The project that am having this issue is an Inventory management system project. Am a newbie can I get detailed instructions on this
This is very very very bad I recommend you shut your site down temporarily and check your code for any leaks as this is not a PHP or Mysql problem it is your script that is incorrect.
If you can't find the problem you can ask me in the comments and I will help you find your problem.
But from what I can read it sounds like one of your SQL queries is not set up correctly.
Also, I saw in the comments the one person is recommending you use a framework I personally code all of my websites is pure PHP as this is what I like and what I feel comfortable with if the framework is needed and you are comfortable using it then yes you can use a framework but honestly coding in pure PHP is not bad you just have to be extra careful in the way you code.
Have a great day and stay safe :)
because you didn't provide enough details about your problem i'll try to outline how a login system works in a concise way. if you don't have any experience writing login system, work with databases or sessions, please study these topics carefully through many articles & videos that exist out there. this topic can't be settled in details in an answer on stackoverflow.
#1 step so, first you need a sign-up page where you collect some data from user, like username, email, phone number, password, etc. then you store this data in database, in a table called users for example. alongside this data you should store a randomly created number like 666187 or an unguessable long string for this user in users table in a field call verification_code (or whatever you like). i'll explain why in the next paragraph.
some parts of this collected data may need verification, email for example, if you did collect the email from user, you'll send an email trying to confirm the entered email truly belongs to the user. your application needs files & codes dedicated to send email whenever you want. after sign-up & storing user data in users table you use your email sending system to email the verification code to the user's entered email (because if user entered an email he/she owns, he/she can access it ). this email contains a link to your application, dedicated to verify users email. (this is not the whole story, but again can't be fit in an answer)
#2 step after completing sign-up page you need the sign-in page. this page contains a form which gets username or email & password of user & checks to find an identical match in users table. if it is found then this is a true user to your application & you should start the session & store user's id in a session variable.
#3 step from now on, on every page which could be accessed only be logged-in users, you fill parts of those pages which is user-specific by retrieving user's id from session & executing queries on database to get data specific to the logged-in user.
a lot of these problems are solved in the start of your project automatically when you use backend frameworks like laravel.
so i suggest you to move toward backend frameworks when you're done with basics & got a good grasp of concepts
maybe it was too generic or vague, i hope you understood something from this answer, sorry if it became long, best regards :)

Logging php actions that are sended to mysql in file

I´m currently working on a big project with is based on php and its connected to a mysql database. I wanna track the actions the clients are doing in a file. If they login I wanna log who is logging in. I wanna log when someone is adding data with a submit button to the db and who is adding the data.
Does someone of you have a example how he did it, or have an idea how to do that?
I hope you understand what I mean :)
Best regards
There are already libraries that can do it for you. One of them is Monolog. Follow doc in README in order to set it up in your project.

I want to set up a form that will send its input data to a database. But I have no idea where to start

This is for a school project.
I have a website. I want this form to send its data into a database, but I have no idea where to start.
I want each field (Title, Name, Email, Inquiry) to be sent to an accessible database where the data is stored.
This is the code I have for the form. As you can see I have a "demo.php" page its linked to but that is empty. It's from a YouTube tutorial that I struggled to follow.
I understand that some level of PHP is involved to achieve this, so I have left it in. Is there anybody that could provide me with a basic guide on how to get around this? Treat me like a 5 year old, as this stuff really confuses me.
Please follow the link.It will explain the whole process of form submission & save in database:
http://www.tutorialspoint.com/php/mysql_insert_php.htm
I would suggest to continue watching videos if that is how you learn best, thenewboston has pretty good videos for beginners. To do what you want you will need to create a database and a file that handles the data before completing a database query which would insert the data.
https://www.youtube.com/playlist?list=PL442FA2C127377F07

Should I use sessions for "LOGINS" on my site?

I have a classifieds website, where anyone (no need for login currently) can post a classified. It is PHP based.
The procedure for posting is currently like this:
click on "New Classified" --->
fill in a form of all information and hit "View classified before publishing it" --->
the form submits to a "verify classifieds" page, where users verify their inputs --->
If everything is okay in the "verify" page, then the user hits OK and the classified is published.
The above procedure isn't exactly optimized. The first page (new_classified) where the form is, is pretty good, but the second page (verify) uses x number of hidden inputs in another form, used to contain the previous pages form inputs.
Now you know how it works on my site.
The issue today is that alot of companies want to publish their classifieds, and alot of classifieds at the same time. This means they have to fill out the form again and again currently.
I am thinking about creating a login, for companies only, so that their information is automatically inputted into the form, so all they would have to do is fill out the specific classified details like "headline" and "description" etc.
How should I do this in my case? Sessions?
This means I will have to create a new MySql table (I use MySql mainly) and store company-profiles there.
So do you think converting to sessions is alot of work? Worth it? More reliable?
I have never used sessions so I wouldn't know.
As a last note, you should know that I use a picture upload tool on the first page of "new_classified". When a user choses a file to upload, the page is automatically *refreshed*, and then the image is displayed on the same page under section "images uploaded". I hope the session wont interfere with this approach.
Thanks
I think it is worth your while to do logins, and even on a very basic level it will help you to identify who is using your site etc.
This is probably a big debate around developers, what is the best way to do a good login system, whether it's basic or not doesn't matter, I think the concepts still stay the same.
In your case I would suggest session cookies along with a login table consisting of user details. This would help you to verify the user on more than one occasion during his/her visit to the site.
A login is checked against a user entry in a table and then a session cookie is created. This session you can choose to never expire also.
You can then on every step check that the user is the user that is supposed to be logged in and get the companies details by checking the username. This would make for a better query in my opinion.
Sessions aren't a lot of work and it's relatively easy to learn.
http://www.php.net/manual/en/book.session.php
http://www.9lessons.info/2010/02/php-login-script-with-encryption.html is a good example of what you can do with this. Have a look around still. There are a bunch of these great tutorials on the web.

SQL database with Phorum

I was just exploring Phorum for my website. I already have a separate log in system associated with the main website, which I was hoping to be able to carry over to Phorum, so people don't have to sign up twice.
I saw the way to hook in a SQL database through include/db/config.php, but there seems to be no good documentation on what's going to be carried in the table I set it to. Will is just be username/password?
Assuming it is, is there a way I can have it so if you signed in on my site, you don't have to re sign in for phorum? Even just a link pointing in the right direction would be outstanding. Thanks!
You could modify your site to use the Phorum database and user registration system. This would be the best way to do it. You could write a small SQL import script for your existing users and then just link to the phorum rego page from your site.
If you are not keen on taking this approach, you'd need to update both user tables (yours and phorums) when data was changed / inserted. Also you'd both need to use the same cookie.
Does that help?

Categories