Create a table from a form.

A

Anonymous

Guest
Hello Can someone tell me what I am doing wrong here.

I want it to CREATE a new TABLE with the users name.

I can't get it to work.

Please help
Thank you.

Puto


Code:
<?php
$connect = @mysql_connect('server', 'login', 'password');
	if (!$connect) { // The ! means this - If it doesn't connect
		echo ( '<P> Unable to connect to database ' . ' database server at this time.</p>' );
		exit();
	}

	mysql_select_db ('magicbean', $connect); //Select the Database at this address with this login info.
		if (! @mysql_select_db('magicbean') ) {
			die ( '<p> Unable to connect to The Database ' . ' at this time.</p>' );
			}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<?php  

$query = "CREATE TABLE $username 
		(	id INT NOT NULL AUTO_INCREMENT, 
			name VARCHAR(20) NOT NULL, 
			PRIMARY KEY(id))";
$result = mysql_query($query); 
$username = $_POST['party']; 

		?>


<form action="<?php echo $result;?>" method="post">



	  
<table width="392" border="0" cellpadding="0">
  <tr>
    <th scope="col">Please enter the ID for the new party. </th>
  </tr>
  <tr>
    <td><div align="center">
      <input type="text" name="party" />
    </div></td>
    </tr>
  <tr>
    <td><div align="center">
      <input type="submit" name="Submit" value="Submit" />
    </div></td>
    </tr>
</table>
</form>
</body>
</html>
 
Try making something like, example:
Code:
<?php

$query = "CREATE TABLE  {$username} (
          id INT NOT NULL AUTO_INCREMENT,          
          name VARCHAR(20) NOT NULL,          
          PRIMARY KEY(id))";

?>
Or...
Code:
<?php

$query = "CREATE TABLE  " . $username . " (
          id INT NOT NULL AUTO_INCREMENT,          
          name VARCHAR(20) NOT NULL,          
          PRIMARY KEY(id))";

?>
 
Back
Top