OK niko,
I can't debug without seeing all your code,
so here I made an example that will work
with your
forum database and the
users table.
Call up data_input.php
fill in the boxes and submit
then data_input_script.php will insert your entries into the database
If your successful, then you can build back up to 3 queries, etc...
GOOD LUCK!!
your current database name:
forum
current table name and description:
users
user_id int(10) NOT NULL AUTO_INCREMENT, (primary key)
user_name - varchar(20) DEFAULT NULL,
password - varchar(50) DEFAULT NULL,
firstname - varchar(50) DEFAULT NULL,
lastname - varchar(50) DEFAULT NULL,
bad - tinyint(1) DEFAULT NULL,
email - varchar(255) DEFAULT NULL,
role_id - int(10) DEFAULT NULL,
put this in a file named data_input.php
<?php
echo "<html>";
echo "<body>";
echo "<form action='data_input_script.php' method='post'>";
echo "<br />User Name: <input type='text' name='input_name' size='20' maxlength='20' /><br />";
echo "<br />Password: <input type='text' name='input_password' size='50' maxlength='50' /><br />";
echo "<br />First Name: <input type='text' name='input_first' size='50' maxlength='50' /><br />";
echo "<br />Last Name: <input type='text' name='input_last' size='50' maxlength='50' /><br />";
echo "<br />Email: <input type='text' name='input_email' size='255' maxlength='255' /><br />";
echo "<br /><br />";
echo "<br /><input type='submit' />";
echo "</form>";
echo "</body>";
echo "</html>";
?>
fill in your password at $passwordname = " " and put this
code in a file named data_input_script.php
<?php
$databasename = "forum";
$hostname = "localhost";
$username = "root"
$passwordname = "your_password"
//OPEN MYSQL CONNECTION
$connectionname = mysql_connect($hostname, $username, $passwordname) or die ("Unable to Connect");
//SELECT DATABASE
mysql_select_db($databasename, $connectionname) or die ("Unreachable Database");
//QUERY
$queryname = "INSERT INTO users
(user_name,
password,
firstname,
lastname,
email)
VALUES
('$_POST[input_name]',
'$_POST[input_password]',
'$_POST[input_first]',
'$_POST[input_last]',
'$_POST[input_email]')
//EXECUTE QUERY
mysql_query($queryname, $connectionname);
//CLOSE CONNECTION
mysql_close($connectionname);
print("Record Inserted");
?>
Don't build a released internet site with this structure,
you need to hide the database connection info
in a directory ABOVE the public one, but for testing
this structure is easily understood.
Edited by debtboy, 01 September 2009 - 10:48 PM.