muzammil
04-12-2011, 01:20 PM
<html>
<head>
</head>
<body>
<form name="register" action="create.php" method="post">
username:<input type="text" name="user" />
e-mail:<input type="text" name="email" />
<input type="submit" name="submit" value="register" />
</form>
</body>
</html>
I want to create a table in my database and the name of the table should be fetched from the user name. Is it Possible?? I m trying following code its not working for me
<?php //create.php
$u=$_POST['user'];
$con = mysql_connect("localhost","peter","abc123");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
if (mysql_query("CREATE TABLE '$u'",$con))
{
echo "Database created";
}
else
{
echo "Error creating database: " . mysql_error();
}
mysql_close($con);
?>
So instead of using table name i am using '$u'.
Can we do that? Please help
<head>
</head>
<body>
<form name="register" action="create.php" method="post">
username:<input type="text" name="user" />
e-mail:<input type="text" name="email" />
<input type="submit" name="submit" value="register" />
</form>
</body>
</html>
I want to create a table in my database and the name of the table should be fetched from the user name. Is it Possible?? I m trying following code its not working for me
<?php //create.php
$u=$_POST['user'];
$con = mysql_connect("localhost","peter","abc123");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
if (mysql_query("CREATE TABLE '$u'",$con))
{
echo "Database created";
}
else
{
echo "Error creating database: " . mysql_error();
}
mysql_close($con);
?>
So instead of using table name i am using '$u'.
Can we do that? Please help