How to Create table in mysql5

Posted on 2008-10-17
Last Modified: 2013-12-13
i m developing a login page with the combination of php and mysql, how i can create a table which stores usernames and password and other informations ?
Question by:cbpandya
LVL 13

Accepted Solution

marchent earned 250 total points
ID: 22740851
create table info(

    username varchar(255) not null,

    password varchar(255) not null,

    firstname varchar(2255) not null,

    primary key(username)


Open in new window


Expert Comment

ID: 22740863
I hope this helps you.

Kind regards,

Matthias Vance

	// Connect to DB server

	$connection = mysql_connect(DB_HOST, DB_USER, DB_PASS);

	// Select database


	// Initialize query

	$query = "CREATE TABLE `ee_test`.`users` ("

	$query .= "  `username` VARCHAR(255) NOT NULL,"

	$query .= "  `password` VARCHAR(32) NOT NULL,"

	$query .= "  `fullname` VARCHAR(255) NOT NULL,"

	$query .= "  `country` VARCHAR(255) NOT NULL,"

	$query .= "  PRIMARY KEY (`username`)"

	$query .= ")"

	$query .= "ENGINE = InnoDB;"

	// Execute query

	mysql_query($query, $connection);

	// Insert something to our newly created table

	$query = "INSERT INTO `ee_test`.`users` VALUES('mvance', MD5(test), 'Matthias Vance', 'N/A');"

	mysql_query($query, $connection);


Open in new window


Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now