Jump to content

Some problem here, Need help


chand.sethi77

Recommended Posts

see, i had a simple Name and Username sectioned registration page. It actioned to process.php Now here is process .php

<?php//connecting to database$connect = mysql_connect ("localhost", "root", "");	if (!$connect) {		die ("sorry, there is an error here. " . mysql_error());	}?><?phpif (mysql_query("CREATE DATABASE kiddo",$connect))  {  echo "Being redirected." . "<a href='process2.php'>" . "Click here" . "</a>" . "to enter";  }else  {  echo "Error creating database: " . mysql_error();  }$select_db = mysql_select_db("kiddo", $connect);?><?php$sql = mysql_query("CREATE TABLE users (name varchar(15),username varchar(15))")?><?php$name = $_POST['name'];$username = $_POST['username'];?><?php$insert = "INSERT INTO users (					name,					username,					)				VALUES (					$name,					$username					)";if (!$insert) {	die ("Could not insert data." . mysql_error() );}?><?php echo "Thanks for registering. Just another click to go" . "<a href='registered.php'>" .  "here" . "</a>"; ?><?php mysql_close ($connect);?>

The problem is that when ever someone registers, it is ok, but when some one registers again, it says that database is already created! Please tell me what to do. It is too much important.

Link to comment
Share on other sites

genaraly in production creating database,creating table,setting up the database schema are being done in phpmyadmin. your should only insert it here.everytime the scirpt will be executed it will try to create the same databse and same table. which is not possible.

Link to comment
Share on other sites

right. creating a database and table are typically done through something like phpMyAdmin or MySQL workbench, typically because this process only needs to occur once. After that, you can modify the table and it's records as you need using INSERT/UDPATE/etc.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...