Here is how I want it to work...
Name:
Filename:
Category:
Header Image:
"Name" would be used for the print output saying that "NameHere has been added to the database" and also be used in inserting a value in a table that has already been created called "pageheaders".
The Filename will be used many times...this will be the from portion of the names of the tables as well as part of the insert into pageheaders.
Category will just be part of the insert into pageheaders.
Header Image is also just part of the insert.
Here is the form portion of what I am trying to do...the action is calling to another page where the sql stuff is because that is the only way I knew to do it but if you know a better way to have them in the same file then I am more than happy to use that.
Form Code:
Expand|Select|Wrap|Line Numbers
- <form action="tablesandinsert.php" method="post">
- Name: <input type="text" name="name"><br>
- Filename: <input type="text" name="filename"><br>
- Category: <input type="text" name="category"><br>
- Header Image: <input type="text" name="headerimage"><br>
- <input type="submit" value="Submit">
- </form>
SQL Stuff:
Expand|Select|Wrap|Line Numbers
- $name=$_POST['name'];
- $filename=$_POST['filename'];
- $category=$_POST['category'];
- $headerimage=$_POST['headerimage'];
- $query="CREATE TABLE `$filename_fins` (
- `gif_id` mediumint(9) NOT NULL auto_increment,
- `fingifurl` text NOT NULL,
- PRIMARY KEY (`gif_id`)
- ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
- CREATE TABLE `$filename_trons` (
- `gif_id` mediumint(9) NOT NULL auto_increment,
- `trongifurl` text NOT NULL,
- PRIMARY KEY (`gif_id`)
- ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
- CREATE TABLE `$filename_misc` (
- `gif_id` mediumint(9) NOT NULL auto_increment,
- `miscgifurl` text NOT NULL,
- PRIMARY KEY (`gif_id`)
- ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
- INSERT INTO `pageheaders` VALUES ('$name', '$filename', '$headerimage', '$category/$filename/index');";
- $result=mysql_query($query);
- Print "$name has been successfully added to the database.";
- ?>