Link to home
Start Free TrialLog in
Avatar of cbpandya
cbpandya

asked on

How to Create table in mysql5

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 ?
ASKER CERTIFIED SOLUTION
Avatar of marchent
marchent
Flag of Bangladesh image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I hope this helps you.

Kind regards,

Matthias Vance
<?php
	// Connect to DB server
	$connection = mysql_connect(DB_HOST, DB_USER, DB_PASS);
	// Select database
	mysql_select_db("ee_test");
	// 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