Building a Online Lotto Web Application. Tutorial -2 : Creating User data storing and management database by SQL.

in #utopian-io6 years ago

PicsArt_10-10-09.37.32.png

Repository

https://github.com/kibriakk/lotto

You will learn From This full tutorial.

  • How to make a online lottery managemment script & Site
  • Steem Payment Getway Setup
  • Auto Payment getway Building
  • User login,Registration System Building
  • Php to MySql Data input
  • MySql to Php data showing
  • Token Transaction System Building
  • Buy & Sell ticket System Build via Php and mysql
  • Text to QR code generator builder
  • Online live Chat plugin Builder
  • Admin mode build via php
  • Php from Builder.

You will learn from this tutorial part

  • How to create mysql in cpanel
  • How to create table in mysql database via sql command
  • How to create columns and set data type and other option via sql command
  • How to set auto increasement function in a column
  • How to build a database to keep user information safe.

Requirements

  • Php 5.1 or higher
  • My SQL 5.1 or higher
  • Hosting or Server
  • Basic knowledge on Php, My SQL, HTML,CSS

Difficulty

Basic

Description

I am kibria a web and blockchain Developer.

This is the 2nd part of "How to build a lotto /lottery /gambling site using Php and MySQL without using any framework."

The tutorial is so large. So I will post every tutorial part by part in my steemit blog.

Part -1 : Building a Online Lotto Web Application. Tutorial -1 : basic function of the lotto web application.(connecting mysql in website by function.php)
Part -2 : Creating Database for user management and keeping safe users information.

So lets start-

In the previous tutorial we have learn how to make function.php and build the connection between web application to mysql.

In this part we will learn, how to make the database and how to create users information table for keeping users all information. This is the most nessesary step.

I have shared a link of mysql database file. which can directly import users table and structure, column into your database. But We need to learn Everything about making this. So please avoid the shortcut rules and use the original methood.

  1. First we need to login to our Cpanel and create database and database users. If you don't know to create it see the screenshot

IMG_20181011_204601_848.JPG

In the database section click on the "Mysql® Database" Then you can see this picture.
IMG_20181011_204621_749.JPG

write your database name and create.

IMG_20181011_204713_861.JPG

Then create database user.

IMG_20181011_204732_996.JPG

Add user into database

IMG_20181011_204759_811.JPG

Select "all previllage" and click on "make changes"

IMG_20181011_204817_775.JPG

Open php myadmin from cpanel.
you can see that a new database in the left bar. click on the database.

IMG_20181011_204852_099.JPG

  1. you can create manually table from it. But I tech you the SQL system. Which can help you to know SQL command.

IMG_20181011_204909_019.JPG

open the sql tab and write down bellow code,

CREATE TABLE `users` (
  `id` int(11) NOT NULL,
  `username` varchar(16) NOT NULL,
  `fullname` varchar(255) NOT NULL,
  `password` varchar(40) NOT NULL,
  `email` varchar(40) NOT NULL,
  `phone` varchar(255) NOT NULL,
  `country` varchar(255) NOT NULL,
  `ref` int(11) NOT NULL DEFAULT 1,
  `balance` varchar(20) NOT NULL DEFAULT '0',
  `sid` varchar(255) NOT NULL,
  `ticket` varchar(20) DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

CREATE TABLE `users` is a command to create a table and table name is "users".
In the bracket () there is some command which is used to create column in the table. first word in '' is the column name. 2nd word is data_type(size). 3rd word is null value and 4th word is default value. All the column is divided by commas.

Click on go now.

Here is the column name
  1. id
  2. username
  3. fullname
  4. password
  5. email
  6. phone
  7. country
  8. ref
  9. balance
  10. sid
  11. ticket

IMG_20181011_204944_207.JPG

IMG_20181011_204957_572.JPG

3)Index 'id' and 'username' :
Now we will modify 'id' column as primary and 'username' column as username. So need to write this command line.

ALTER TABLE `users`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `username` (`username`);
  • Here "ALTER TABLE" is the command which means create a condition.
  • users means the table name.
  • ADD PRIMARY KEY ('id') is the command to add the 'id' column as primary and ADD UNIQUE KEY 'username'('username') is the command to add 'username' column as a unique key for username function.
    IMG_20181011_205656_857.JPG
  1. Now we need to add a system to increase value automatically for 'id'.
    For example, if a new user add the id will be 1. if another user add the new users id will be 2. then 3,4,5...

So we should write this command

IMG_20181011_205034_672.JPG

ALTER TABLE `users`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;

Then click on go.

So the Creating 'user' table finished.

Here is the full code.

--
-- Table structure for table `users`
--
CREATE TABLE `users` (
  `id` int(11) NOT NULL,
  `username` varchar(16) NOT NULL,
  `fullname` varchar(255) NOT NULL,
  `password` varchar(40) NOT NULL,
  `email` varchar(40) NOT NULL,
  `phone` varchar(255) NOT NULL,
  `country` varchar(255) NOT NULL,
  `ref` int(11) NOT NULL DEFAULT 1,
  `balance` varchar(20) NOT NULL DEFAULT '0',
  `sid` varchar(255) NOT NULL,
  `ticket` varchar(20) DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


--
-- Indexes for table `users`
--
ALTER TABLE `users`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `username` (`username`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
COMMIT;

The Table structure is look like this picture.

IMG_20181011_205115_801.JPG

I hope everyone realize the methood. Please comment if you have any problem. I will be happy for your commemt.

The tutorial of part -2 has been finished. We will learn user login and registration in the next tutorial tommorow.

Previous tutorial

Proof of work done

https://github.com/kibriakk/lotto

Sort:  
Loading...

Hi @kibria365!

Your post has been upvoted by @bdcommunity.

You can support us by following our curation trail or by delegating SP to us.

20 SP, 50 SP, 100 SP, 300 SP, 500 SP, 1000 SP.

If you are not actively voting for Steem Witnesses, please set us as your voting proxy.

Feel free to join BDCommunity Discord Server.

Your tutorial is very interesting. Keep update this tutorial.


Total line :219
Total Words:1122


Support from @steem-contest.

Nice, this is quite interesting

Thank you for updating the 2nd tutorial. I finished all the work. All codes are working fine and i successfully build my mYsql database.

😆😆😆

Hi @kibria365!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server

Hey, @kibria365!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!