Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 1 of 1
  1. #1
    Senior Member [Li] Brad's Avatar
    Join Date
    Oct 2003
    Location
    Saskatoon, Canada
    Posts
    578
    Member #
    3689
    I have a PHP script that lets a user add a hockey player from a list onto his own "team". Now, to do this I pass the name variables through the page URL and then catch them with the same page.
    This way, it gives the MySQL the information it needs to enter, and the page needs just a quick reload. (There may be (probably is) a better way to do this, but as of now I just want to get this thing working)

    The problem is when the user clicks on the same guy twice, it adds him in twice. I have code such as:
    PHP Code:
    function addplayers ($fname$lname){    // $fname and $lname passed from addplayers.php
     
      // If there is data for the player clicked
      
    if($fname != '' && $lname != '') {
      
        
    // If the player added isn't in the team already
        
    $dbl mysql_query("SELECT FirstName, LastName FROM `rosters` WHERE Team='" 
    $_SESSION['teamname'] . "' AND FirstName = '" $fname "' AND LastName = '" $lname "'");
        if(
    $db1 0){    // If he wasn't found, add him in
          // Connect to the poolID database
          
    echo "<div align=\"center\"><font color=\"#0033CC\">Player already on the team</font></div>";
            
        } else {    
    // If he was found, show message 
          
    $teamnamedb mysql_query("SELECT ID FROM `rosters` WHERE Team='" $_SESSION['teamname'] . "'");
          
    $teamname mysql_fetch_array($teamnamedb);
          
    mysql_query("INSERT INTO `rosters` (ID,Team,FirstName,LastName) VALUES ('" $teamname['ID'] . "','" 
    $_SESSION['teamname'] . "','" $_GET['fname'] . "','" 
    $_GET['lname'] . "')");
          echo 
    "<script language=\"javascript\">location.replace(\"http://www.lithiumwebdesign.com/
    admin.php?inc1=team&inc2=addplayers&alpha=" 
    $_GET['alpha'] . "\")</script>";
        }
      }

    Logically it should work, but I think I'm missing a while statement or something. Can anyone see what the problem is? Hopefully it's clear from my explenation and the code what I'm trying to do.

    Thanks in advance,
    [Li] Brad

    EDIT: Pay no attention to the comments, a lot of them are out of place from me making changes
    "Art strives for form, and hopes for beauty." - George Bellows

  2.  


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 03:03 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com