Hi there i am currently trying to do a register page for a manager to register for my website i need the data to go into 2 tables in my database because they are linked and no data is being inserted into my database at all im just wondering were i am going wrong many thanks for looking.
Register Page.
<?php
//Insert managers into users table
//users Table
##### Table Structure #######
## username - password - name - teamname ####
##### Team table structure ######
### teamid - teamname ###
include "common.php";
//make connection to database
DBConnect();
$username = $_REQUEST['email'];
$password = $_REQUEST['password'];
$name = $_REQUEST['name'];
$teamname = $_REQUEST['teamname'];
$teamid = NULL
$action = $_REQUEST['action'];
//If statement to check if the user has entered anything into the feilds.
if($action=="Register"){
if(!$username&&!$password&&!$name&&!$teamname){
$message = "Please fill in all fields!";
header("location: register.php?message=$message");
}elseif(!$username){
$message = "Please fill in your Email Address";
header("location: register.php?message=$message");
}elseif(!$name){
$message = "Please fill in your Name";
header("location: register.php?message=$message");
}elseif(!$teamname){
$message = "Please fill in your Team Name";
header("location: register.php?message=$message");
}elseif(!$password){
$message = "Please fill in your Password";
header("location: register.php?message=$message");
}else{$Link = mysql_connect($Dhost, $Duser, $Dpassword);
// Query is inserting data into the database using the Values from the from.
$Query = "INSERT into $tbl_user values ('$username', '$password', '$name', '$teamname')";
$Query = "INSERT into $tbl_team values ('$teamid', '$teamname' )";
if (mysql_db_query ($DBName, $Query, $Link)){
//Is not showing message needs fixing.
$message = "A record was successfully created! Please continue to the homepage and Login using your email as your Username";
}else{
$message = "The record could not be created! please try again";
mysql_close($Link);
}
}
}
?>
<?php
$message = $_GET['message'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>FYP - Teesside Football United</title>
<link rel="stylesheet" href="style.css" type="text/css" media="screen" />
</head>
<body>
<p> </p>
<div id="header"></div>
<div id="content">
<div id="right">
<div id="introwrap" class="clearfix">
<h1>Register</h1>
</div>
<h2>Register Your Team here:</h2>
<form id="form1" method="post" action="register.php?action=Register">
<p>
<label>Email Address
<input type="text" name="email" id="email" />
</label>
</p>
<p>
<label>Name
<input type="text" name="name" id="name" />
</label>
</p>
<p>
<label>Team Name
<input type="text" name="teamname" id="teamname" />
</label>
</p>
<p>
<label>Password
<input type="password" name="password" id="password" />
</label>
</p>
<p>
<label>
<input type="submit" name="submit" id="submit" value="Register" />
</label>
</p>
<p> </p>
<p><?php echo $message ; ?></p>
</form>
<p>
<p>
<label>
<p> </label>
<p></p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
</div>
<div id="left">
<h3>Teams</h3>
<ul>
<li><a href="index.php">Home Page</a></li>
<li><a href="comp.php">Competition</a></li>
<li><a href="contact.html">Contact Us</a></li>
<li><a href="teams.php">Teams</a></li>
<li><a href="adminlogin.php">admin page</a></li>
<li><a href="manager.php">Manager Page</a></li>
</ul>
</div>
</div>
</body>
</html>
Common.php
<?php
//Connection To MYSQL DataBase
//Function called in external scripts
function DBConnect(){
//global vars
global $Dhost, $Duser, $Dpassword, $DBName, $tbl_admin, $tbl_user, $tbl_team ;
$Dhost = "xxxxx";
$Duser = "xxxx";
$Dpassword = "xxxx";
$DBName = "xxxxxxxx";
$tbl_admin = "admin";
$tbl_user = "user";
$tbl_team = "team";
}
?>
Thank you for looking 🙂