Hi all,
I'm more or less a PHP/Database newbie and I'm having some problems with code. I'm making a user login/members area for a client. The user registers for an account and when they login to the members area, they're able to create a team to enter a competition.
The user login is working fine as far as I can tell. I found some tutorials online and was able to get it working. I'm having problems with the team registration part, however.
My problem is this: the team registration goes through 4 pages (or steps first step is register a team name, second is to register a primary contact, third is secondary contact, last is general team information). My database is working in such a way that I have a table for team, primary contact, secondary contact and team information. What I need help with is when they enter a primary contact, I can't get it to link to that specific team. I have the tables linked fine with foreign keys and I think I'm doing that right (the foreign key for primary contact, secondary contact and team information is teamID).
My understanding is I need to run a query to determine the teamID and then put the result of that query into my insert for primary, secondary and team info. I'm just unsure how to run the query and store the output into a variable.
Here's what I have so far (only showing primary contact page):
$user = $_SESSION['SESS_MEMBER_ID'];
$qry = "SELECT teamID FROM dboat_team WHERE userID = $user";
mysql_query($qry);
if($qry) {
if(mysql_num_rows($qry) == 1) {
$results = mysql_fetch_assoc($qry);
$theTeam = $results['teamID'];}
}
//get values from previous page
$fName = "'" . $_POST['FirstName'] . "'";
$lName = "'" . $_POST['LastName'] . "'";
$Country = "'" . $_POST['Country'] . "'";
$Address = "'" . $_POST['Address'] . "'";
$City = "'" . $_POST['City'] . "'";
$Province = "'" . $_POST['provincestate'] . "'";
$postalcode = "'" . $_POST['postalZipCode'] . "'";
$email = "'" . $_POST['Email'] . "'";
$phonenum = "'" . $_POST['Phone'] . "'";
$phoneType = "'" . $_POST['phonetype'] . "'";
//run query to insert team
$goodJobQuery = "INSERT INTO dboat_pcontact VALUES(NULL, $fName, $lName, $Address, $City, $Province, $postalcode, $Country, $phonenum, $phoneType, $email, $theTeam)";
mysql_query($goodJobQuery);
The session is working, because if I echo out the userID on the page it gives me the proper one. I'm just unsure about how to do the rest. I'm sure it's a simple thing I'm just overlooking.
Any help is greatly appreciated. Sorry for my post but I'm really stuck and could use some help!