I'm making a registration page. How I have everything working is the user registers and there are three different checkboxes that can check for what classes they want, then their credentials get stored in their own table in a user DATABASE. Then for each class they choose(for each checkbox that is checked) I want to enter their name into each database(one checkbox = one database).
I have this working manually, but I was trying to do this through an include page. So I can use that page on the other pages of the website.
Heres the code working manually:
foreach($_POST["class"] as $database)
{
mysql_connect("localhost", "***", "***");;
@mysql_select_db("$database");
mysql_query("insert into users (name, status) values('$full_name', 'not approved')");
mysql_close();
}
This is what I want, but it's not working at the minute:
foreach($_POST["class"] as $database_name)
{
require_once('../includes/main_server_settings.php');
mysql_query("insert into users (name, status) values('$full_name', 'not approved')");
mysql_close();
}
This is the main_server_settings.php file:
$database_user="****";
$database_password="****";
$database_server="localhost";
mysql_connect($database_server, $database_user, $database_password);
@mysql_select_db($database_name) or die("Unable to connect to database.");