hdshngout
07-18-2005, 07:59 PM
ok, is this at all possible. i have a database with 3 tables
blogs, other_pages, and users.
is it possible to have 1 form that the user fills out and it takes data from the form and puts it into different databases. for example
username field data goes to users database
blog_title field data goes to blogs database
etc.
help is really needed.
(if possible explain it to me like im stupid.) (LOL)
Douglas
07-18-2005, 09:26 PM
in your form processing page add something like this (MOST CAPITALS CAN BE CHANGED):
$username=$_POST['username'];
$blog_title=$_POST['blog_title'];
$VARIABLE_IN_THIRD_TABLE=$_POST['NAME_OF_FIELD'];
$servername="YOUR SERVER NAME";
$dbusername="YOUR DATABASE USERNAME";
$dbpassword="YOUR DATABASE PASSWORD";
$dbname="YOUR DATABASE NAME";
mysql_connect("$servername","$dbusername","$dbpassword") or die(mysql_error());
mysql_select_db("$dbname");
mysql_query("INSERT INTO users (ROW_NAME) VALUES ('$username')") or die(mysql_error());
mysql_query("INSERT INTO blogs (ROW_NAME) VALUES ('$blog_title')") or die(mysql_error());
mysql_query("INSERT INTO other_pages (ROW_NAME) VALUES ('$VARIABLE_IN_THIRD_TABLE')") or die(mysql_error());
^^^^^^^ thats for multiple tables this one is for multiple databases
$username=$_POST['username'];
$blog_title=$_POST['blog_title'];
$VARIABLE_IN_THIRD_TABLE=$_POST['NAME_OF_FIELD'];
$servername="YOUR SERVER NAME";
$dbusername="YOUR DATABASE USERNAME";
$dbpassword="YOUR DATABASE PASSWORD";
mysql_connect("$servername","$dbusername","$dbpassword") or die(mysql_error());
mysql_select_db("users");
mysql_query("INSERT INTO users (ROW_NAME) VALUES ('$username')") or die(mysql_error());
mysql_select_db("blogs");
mysql_query("INSERT INTO blogs (ROW_NAME) VALUES ('$blog_title')") or die(mysql_error());
mysql_select_db("other_pages");
mysql_query("INSERT INTO other_pages (ROW_NAME) VALUES ('$VARIABLE_IN_THIRD_TABLE')") or die(mysql_error());
hope this helps :)
hdshngout
07-18-2005, 09:55 PM
thanks. so simple. now i feel kinda dumb. oh well. Thanks!!!