Jump to content

PHP Check Stored Data Help


tebrown

Recommended Posts

Hey Guys,

 

I have got 3 chained select boxes working. Basically what you do is check for a region with the country, then once you pick a region, you select a club within that region. Once you have selected the club, you can then choose a team from within that club.

 

Screenshot: Attchment

 

 

As part of this chained select boxes's, a user can register. Although, the user has to FIRST check if the TEAM has already been registered in the database.

 

I have taken a screenshot of my database, which shows the regions, clubs, and teams from the chained select boxes. What i want to do now is be able to check if a TEAM is already registered in the database. So as you can see in the database, the team 'NPOB, Senior As' has already been taken.

 

Database Screenshot: Attachment

 

 

*** How do i check if a user has been registered to one of the teams? And if there is not a registered user to that team, they can then register it.

 

Here is my code:

 

<?php
include"database.php";
?>

<script type="text/javascript">

/*
Triple Combo Script Credit
By Philip M: http://www.codingforums.com/member.php?u=186
Visit http://javascriptkit.com for this and over 400+ other scripts
*/

var categories = [];
categories["startList"] = ["Taranaki","Auckland"]
// Regions + Clubs
categories["Taranaki"] = ["NPOB","Tukapa"];
categories["Auckland"] = ["Marist","Takapuna"];
// Clubs + Teams within that Club
categories["NPOB"] = ["Senior As","Senior Bs","Colts U21s"];
categories["Tukapa"] = ["Senior As","Senior Bs","Colts U21s"];
categories["Marist"] = ["Senior As","Senior Bs","Colts U21s"];
categories["Takapuna"] = ["Senior As","Senior Bs","Colts U21s"];

var nLists = 3; // number of select lists in the set

function fillSelect(currCat,currList){
var step = Number(currList.name.replace(/\D/g,""));
for (i=step; i<nLists+1; i++) {
document.forms['tripleplay']['List'+i].length = 1;
document.forms['tripleplay']['List'+i].selectedIndex = 0;
}
var nCat = categories[currCat];
for (each in nCat) {
var nOption = document.createElement('option'); 
var nData = document.createTextNode(nCat[each]); 
nOption.setAttribute('value',nCat[each]); 
nOption.appendChild(nData); 
currList.appendChild(nOption); 
} 
}

// function getValue(L3, L2, L1) {
// alert("Your selection was:- \n" + L1 + "\n" + L2 + "\n" + L3);
// }

function init() {
fillSelect('startList',document.forms['tripleplay']['List1'])
}

navigator.appName == "Microsoft Internet Explorer" ? attachEvent('onload', init, false) : addEventListener('load', init, false);	

</script>


<form name="tripleplay" action="testingdropdown.php" method="post">
<select name='List1' onchange="fillSelect(this.value,this.form['List2'])">
<option selected>Choose Region</option>
</select><br /><br />

<select name='List2' onchange="fillSelect(this.value,this.form['List3'])">
<option selected>Choose Club   </option>
</select><br /><br />

<select name='List3' onchange="getValue(this.value, this.form['List2'].value, 
this.form['List1'].value)">
<option selected >Choose Team  </option>
</select>
<input type="submit" name="tripleplay" value="Register">
</form>


<?php
     if (isset($_POST['tripleplay'])) {
         
         
     $region = addslashes(strip_tags($_POST['List1']));
     $club = addslashes(strip_tags($_POST['List2']));
     $team = addslashes(strip_tags($_POST['List3']));

    $email = 'email';

$check = mysql_query("SELECT * FROM managers WHERE email='$email'");
           if ($email == '') {
         echo "You can register that club";
         } else {
echo "Sorry that team has already been registered";
}
}

?>

post-132578-13482403368309_thumb.png

post-132578-13482403391175_thumb.png

Link to comment
https://forums.phpfreaks.com/topic/260306-php-check-stored-data-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.