Is it possible to create a table and insert data into the table on the same page?
Here is what I am using:
THE HTML FORM:
The input form (input.html)
<form action="insert.php" method="POST" enctype="multipart/form-data">
Table Name (Which would be the address)<input type="text" name="table_name" SIZE="60"><P>
Would be the field names starting with address again<input type="text" name="fulladdress" SIZE="60"><P>
<input type="submit" value="Submit Questionaire" name="func" > <INPUT NAME="reset" type="reset" value="Start Over" ALIGN=absbottom>
</FORM>
THE PHP PAGE
<HTML>
<HEAD>
<?
$username="";
$password="";
$database="";
$server="";
$con = mysql_connect($server,$username,$password);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$newtable = $_POST["$table_name"];
// Create table in my_db database
mysql_select_db("buysellnh_com_showings", $con);
$sql = "CREATE TABLE $newtable IF NOT EXISTS
(
id INT,
address VARCHAR(100),
cur_timestamp TIMESTAMP(
)";
mysql_query($sql,$con);
$sql="insert into $newtable (id,address,cur_timestamp) values ('',".$_POST['fulladdress'].",NOW())";
mysql_query($sql,$con);
mysql_close($con);
?>
Nothing happens to the DB when this is executed (There is a simple form that populates the variables)
when I remove the insert into line, I get the new table in the DB but when I add back the INSERT INTO I get no table and no rows...
What am I doing wrong?
The customer (A realtor) wants to be able to add an address and then add showings to that address. The address would be the table and the showings would be the rows....
Greatly appreciate anybody's help...
Ken