Edited and Solved (Thanks to Prix)
Here is the Full Script, An amazing Visitor Tracker: https://github.com/solarisedesign/Visitor-Tracker-PHP-MySQL
I found a solution with the help of user Prix! An amazing and awesome person! He helped me create a new SQL Table!
Here is an image of an example I found online, and this is how I want to build it:
http://i39.tinypic.com/106aghx.png
Here is an image of the new Database by Prix:
Direct Link to the Database query, by Prix: http://sqlfiddle.com/#!2/4bc83/5/0
Many thanks to Prix for helping me out....... Check the full Topic below... Thank you
My Question was:
I am simply trying to create my own script for users to log Visitor IPs and also go in and Track who was visiting their site and everything will be logged inside a MySQL database!
When launching the script, they users will be asked to choose a Name inside a "textarea".
So when a user picks a name and clicks on CREATE URL, then the script will create a SQL database table called test
. Right now the Script is only used for 1 Person or user! But I want to make it available for everyone, so users only have to visit our site and simply create a user, and all the files and tables will be automatically added in the folder and ready for use.
I want to know how I can create a Table for each user that choose a name in textarea
! So when a user chooses the name "mike" in the textarea
, then the script should create a table named "mike" and simply add the rest of the tables inside the table "mike"!
The textarea is called "$name" in the sql code below, and when I add "$name" infront of the this part:
CREATE TABLE $name
Then I simply get an error. I don't know how to add the textarea
so it can create the same table as the name chosen in the text area:
This is my full script:
<form action="" method="post" >
<table width="400" border="0" cellspacing="0" cellpadding="5">
<tr>
<td colspan="3" align="center">Please choose a Folder or Name?</td>
</tr>
<tr>
<td>Name </td>
<td> </td>
<td><input type="text" name="name" id="text" value=""></td>
</tr>
<tr>
<td colspan="3" align="center"><input type="submit" name="submit" id="submit" value="Submit"></td>
</tr>
</table>
</form>
<?php
if (isset($_POST['submit'])) {
$name = $_POST['name'];
echo " ";
echo "Conguradulations. Your new URL is sucessfully created.!";
echo " ";
echo " ";
echo "Your new URL name is $name";
}
$dbhost = 'host';
$dbuser = 'dbuser';
$dbpass = 'dbpass';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn ) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
$sql = 'CREATE TABLE test('.
'entry_id int(11) NOT NULL AUTO_INCREMENT, '.
'visitor_id int(11) default NULL, '.
'ip_address varchar(15) NOT NULL, '.
'page_name text, '.
'query_string text, '.
'timestamp timestamp NOT NULL default CURRENT_TIMESTAMP, '.
'PRIMARY KEY ( entry_id ), '.
'KEY visitor_id ( visitor_id , timestamp )) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=22 ;';
mysql_select_db('dbname');
$retval = mysql_query( $sql, $conn );
if(! $retval ) {
die('Could not create table: ' . mysql_error());
}
mysql_query($sql,$conn);
?>
So the script above has the everything in it and done. I just need help to attach the textarea
so it can create the a table in MySQL using the text from the textarea!
I was thinking that this could help me out, and if someone could help me create a code from that to help me out.