Jump to content

netman182

Members
  • Posts

    43
  • Joined

  • Last visited

    Never

Everything posted by netman182

  1. i have a question. i am trying to send a variable from a page with a drop down list to a page where i can check for approval and update the approval as nesscesary. i have the code there but i am not seeing results. but i am not getting any errors. could i get some help? thanks here is the code for the drop down menu: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <form id="teamsearch" name="teamsearch" method="post" action="playercheck.php"> <p> </p> <p> <label> <?php include 'dbc.php'; $query="SELECT teamname,teamid FROM teams"; /* You can add order by clause to the sql statement if the names are to be displayed in alphabetical order */ $result = mysql_query ($query); echo "<select name=teamname value=''>Team Name</option>"; // printing the list box select command while($nt=mysql_fetch_array($result)){//Array or records stored in $nt echo "<option value=$nt[teamid]>$nt[teamname]</option>"; /* Option values are added by looping through the array */ } echo "</select>";// Closing of list box ?> <input name="submit" type="submit" id="submit" value="Submit" /> </form> <p> </p> <p> </p> </body> </html> here is the page that will show the teamid from the page with the drop down menu: <?php /* For the following details, ask your server vendor */ $dbhost = "localhost"; $dbuser = "netman13_adminbc"; $dbpass = "95887rj"; $dbname = "netman13_bccsltest"; mysql_connect( $dbhost, $dbuser, $dbpass ) or die ( "Unable to connect to MySQL server" ); mysql_select_db( "$dbname" ); mysql_query( "SET NAMES utf8" ); if(isset($_POST["update"]) AND isset($_POST["hiddenid"])) { $updated=false; $activateapproved=array(); $deactivateapproved=array(); foreach($_POST["hiddenid"] AS $value) { if(isset($_POST["checkboxapproved"][$value])) $activateapproved[]=intval($value); else $deactivateapproved[]=intval($value); } if(count($activateapproved)>0) { $SQL=sprintf("UPDATE players SET approved=1 WHERE id in (%s)" , implode(",", $activateapproved)); mysql_query($SQL) OR DIE(mysql_error()); $updated=true; } if(count($deactivateapproved)>0) { $SQL=sprintf("UPDATE players SET approved=0 WHERE id in (%s)" , implode(",", $deactivateapproved)); mysql_query($SQL) OR DIE(mysql_error()); $updated=true; } if($updated==true) { header("Location: ".$_SERVER["PHP_SELF"]."?todo=updated"); exit(); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php if(isset($_GET["todo"]) AND $_GET["todo"]=="updated") { echo "Updated succesfully"; } ?> <form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post" name="Form"> <table border="1"> <tr> <td>First name</td> <td>Last Name</td> <td>Address</td> <td>City</td> <td>Postal Code</td> <td>Phone Number</td> <td>Height Ft</td> <td>Height In</td> <td>Weight</td> <td>Birthdate</td> <td>Teamid</td> <td>Player Type</td> <td>Approved</td> </tr> <?php $sql="select * from players where teamid='$nt[teamid]'"; $res=mysql_query($sql) or die(mysql_error()); while($r=mysql_fetch_assoc($res)) { ?> <tr> <input type="hidden" name="hiddenid[]" value="<?php echo $r["id"]?>"> <td> <div align="center"><?php echo empty($r["fname"])?' ':htmlspecialchars($r["fname"]); ?> </div></td> <td> <div align="center"><?php echo empty($r["lname"])?' ':htmlspecialchars($r["lname"]); ?> </div></td> <td> <div align="center"><?php echo empty($r["address"])?' ':htmlspecialchars($r["address"]); ?> </div></td> <td> <div align="center"><?php echo empty($r["city"])?' ':htmlspecialchars($r["city"]); ?> </div></td> <td> <div align="center"><?php echo empty($r["postal"])?' ':htmlspecialchars($r["postal"]); ?> </div></td> <td> <div align="center"><?php echo empty($r["phone"])?' ':htmlspecialchars($r["phone"]); ?> </div></td> <td> <div align="center"><?php echo empty($r["hfeet"])?' ':htmlspecialchars($r["hfeet"]); ?> </div></td> <td> <div align="center"><?php echo empty($r["hinches"])?' ':htmlspecialchars($r["hinches"]); ?> </div></td> <td> <div align="center"><?php echo empty($r["weight"])?' ':htmlspecialchars($r["weight"]); ?> </div></td> <td> <div align="center"><?php echo empty($r["birthdate"])?' ':htmlspecialchars($r["birthdate"]); ?> </div></td> <td> <div align="center"><?php echo empty($r["teamid"])?' ':htmlspecialchars($r["teamid"]); ?> </div></td> <td> <div align="center"><?php echo empty($r["status"])?' ':htmlspecialchars($r["status"]); ?> </div></td> <td> <div align="center"> <input type="checkbox" name="checkboxapproved[<?php echo $r["id"]?>]" value="1"<?php echo empty($r["approved"])?'':' checked="checked"'; ?> /> </div></td> </tr> <?php } ?> </table> <input type="submit" value="update" name="update"> </form> </body> </html>
  2. I am having a brain fart right now and i cant remember how to do this. if anyone could help that would be great. I have search google and this forum but have not found what i am looking for. thanks when an employee registers they must be approved by a manager to have access to the login pages. I have a table with a record called approved. It's initial value is 0. I want a query to show all that are 0. but at the same time i need to be able to click a checkbox to make the value 1. I need this to be a mass check box list. Here is an idea of the SQL: Select * from users where approved ='0' i then need to to display all the rows and fields for each user where the approved is '0' i also want to be able to update the approved with a checkbox. how possible is this for someone to give me a hand. thanks alot.
  3. i actually did it on my own. i looked at BenInBlack's suggestion. and looked closer at it. i then realized i overlooked : list($id,$full_name,$approved) = mysql_fetch_row($result); I then noticed i overlooked put in teamid list($id,$full_name,$approved,$teamid) = mysql_fetch_row($result); thanks
  4. i am having a problem with a variable and turning it into a session. i don't want a code re-write or anything like that but something i might be doing wrong. I am trying to get `teamid` a session variable. I have included code. i know it is not working because i am trying to echo it on the next page to see if it is working.' <?php include 'db_conn.php'; if ($_POST['doLogin']=='Login') { $user_email = mysql_real_escape_string($_POST['usr_email']); $md5pass = md5(mysql_real_escape_string($_POST['pwd'])); if (strpos($user_email,'@') === false) { $user_cond = "user_name='$user_email'"; } else { $user_cond = "user_email='$user_email'"; } $sql = "SELECT `id`,`full_name`,`approved`,`teamid` FROM managers WHERE $user_cond AND `pwd` = '$md5pass' AND `banned` = '0' "; $result = mysql_query($sql) or die (mysql_error()); $num = mysql_num_rows($result); // Match row found with more than 1 results - the user is authenticated. if ( $num > 0 ) { list($id,$full_name,$approved) = mysql_fetch_row($result); if(!$approved) { $msg = "Account not activated. Please check your email for activation code"; header("Location: login.php?msg=$msg"); exit(); } // this sets session and logs user in session_start(); // this sets variables in the session $_SESSION['user_id']= $id; $_SESSION['user_name'] = $full_name; $_SESSION['teamid'] = $teamid; //set a cookie witout expiry until 60 days if(isset($_POST['remember'])){ setcookie("user_id", $_SESSION['user_id'], time()+60*60*24*60, "/"); setcookie("user_name", $_SESSION['user_name'], time()+60*60*24*60, "/"); } header("Location: myaccount.php"); } else { $msg = urlencode("Invalid Login. Please try again with correct user email and password. "); header("Location: login.php?msg=$msg"); } } ?> <html> <head> <title>Members Login</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script language="JavaScript" type="text/javascript" src="js/jquery-1.3.2.min.js"></script> <script language="JavaScript" type="text/javascript" src="js/jquery.validate.js"></script> <script> $(document).ready(function(){ $("#logForm").validate(); }); </script> <link href="styles.css" rel="stylesheet" type="text/css"> </head> <body> <table width="100%" border="0" cellspacing="0" cellpadding="5" class="main"> <tr> <td colspan="3"> </td> </tr> <tr> <td width="160" valign="top"><p> </p> <p> </p> <p> </p> <p> </p> <p> </p></td> <td width="732" valign="top"><p> </p> <h3 class="titlehdr">Login Users </h3> <p> <? /******************** ERROR MESSAGES************************************************* This code is to show error messages **************************************************************************/ if (isset($_GET['msg'])) { $msg = mysql_real_escape_string($_GET['msg']); echo "<div class=\"msg\">$msg</div>"; } /******************************* END ********************************/ ?></p> <form action="login.php" method="post" name="logForm" id="logForm" > <table width="65%" border="0" cellpadding="4" cellspacing="4" class="loginform"> <tr> <td colspan="2"> </td> </tr> <tr> <td width="28%">Username / Email</td> <td width="72%"><input name="usr_email" type="text" class="required" id="txtbox" size="25"></td> </tr> <tr> <td>Password</td> <td><input name="pwd" type="password" class="required password" id="txtbox" size="25"></td> </tr> <tr> <td colspan="2"><div align="center"> <input name="remember" type="checkbox" id="remember" value="1"> Remember me</div></td> </tr> <tr> <td colspan="2"> <div align="center"> <p> <input name="doLogin" type="submit" id="doLogin3" value="Login"> </p> <p><a href="register.php">Register Free</a><font color="#FF6600"> |</font> <a href="forgot.php">Forgot Password</a> <font color="#FF6600"> |</font> <a href="activate.php">Activate Account</a></p> </div></td> </tr> </table> <div align="center"></div> <p align="center"> </p> </form> <p> </p> </td> <td width="196" valign="top"> </td> </tr> <tr> <td colspan="3"> </td> </tr> </table> </body> </html>
  5. i understand that. but what is the easy way to grab fields from the record where username and password match. eg. Name, Teamid, Team Name??? thanks
  6. I have searched this forum and on the googles. I have been looking for a way to make a few session variables. i found some code to do the username but i need to make a session that will take some fields from the specific users information in their DB record. the table is managers. the fields I need to grab from the DB are: fname, lname, teamid, tname how do i from my login page send those variables from the db in the checklogin.php to the session variables for the managers session? here is the checklogin.php <?php include("db_include.php"); $table = 'managers'; // username and password sent from form $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; // To protect MySQL injection (more detail about MySQL injection) $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT * FROM $table WHERE email='$myusername' and password='$mypassword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "login_success.php" session_register("myusername"); session_register("mypassword"); header("location:login_success.php"); } else { echo "Wrong Username or Password"; } ?>
  7. Thank you. that helped. I couldnt figure it out for the life of me. it is always something stupid. thanks again
  8. Here is my form. it is basic right now to get it working then i will CSS it to death. <html> <head> <title>manager add</title> </head> <body> <form action="insert.php" method="post" name="manger" id="manger"> <p>Firstname: <input type="text" name="firstname" /> </p> <p> Lastname: <input type="text" name="lastname" /> </p> <p> Address <input type="text" name="Address" id="address"> </p> <p> City <input type="text" name="City" id="city"> </p> <p> Postal <input type="text" name="Postal" id="postal"> </p> <p> Home <input type="text" name="Home" id="home"> </p> <p> Cell <input type="text" name="Cell" id="cell"> </p> <p> Email <input type="text" name="email" id="email"> </p> <p> Password <input type="text" name="password" id="password"> </p> <p> Church <input type="text" name="Church" id="church"> </p> <p> Team Name <input type="text" name="TeamName" id="team"> </p> <p> <input type="submit" /> </p> </form> </body> </html> sql insert: <?php $host="localhost"; // Host name $username="root"; // Mysql username $password="95887rj"; // Mysql password $db_name="bccsl"; // Database name $tbl_name="managers2"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql = sprintf("INSERT INTO Managers (First, Last, Address, City, Postal, Home, Cell, Email, Password, Church, Team)VALUES ('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')",$_POST['firstname'],$_POST['lastname'],$_POST['address'],$_POST['city'],$_POST['postal'],$_POST['home'],$_POST['cell'],$_POST['email'],$_POST['password'],$_POST['church'],$_POST['team']); if (!mysql_query($sql)) { die('Error: ' . mysql_error()); }else echo "1 record added $sql"; ?>
  9. this is what i am currently seeing. my form is fine. and every field has data "test" in it. i am new to php and trying to learn it am i missing something? 1 record added INSERT INTO Managers (First, Last, Address, City, Postal, Home, Cell, Email, Password, Church, Team)VALUES ('test','test','','','','','','test','test','','')
  10. I am having a small problem with my sql statement. it is inserting into 4 of the fields. fields it is inserting into: First Last email password it is saying the record has been added. is there something wrong with the sql statement? <?php $host="localhost"; // Host name $username="root"; // Mysql username $password="95887rj"; // Mysql password $db_name="bccsl"; // Database name $tbl_name="managers2"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql = sprintf("INSERT INTO Managers (First, Last, Address, City, Postal, Home, Cell, Email, Password, Church, Team)VALUES ('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')",$_POST['firstname'],$_POST['lastname'],$_POST['address'],$_POST['city'],$_POST['postal'],$_POST['home'],$_POST['cell'],$_POST['email'],$_POST['password'],$_POST['church'],$_POST['team']); if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } echo "1 record added"; ?>
  11. thanks gayner for being captian dumbass. solved it by a PM. thanks to all who helped.
  12. now i am getting this error: Error: Column count doesn't match value count at row 1
  13. ok i changed the first single qoute and added the {} to the rest. now i get this: Parse error: syntax error, unexpected '}', expecting ']'
  14. i am having problems with this. i can't seem to figure it out. I am getting this error: You have an error in your SQL syntax phpmyadmin server version: Server version: 5.1.37 PHP version: 5.3 here is the code. can anyone help? it is probably a simple problem. ID is an auto increment field. the rest are text <?php $host="localhost"; // Host name $username="root"; // Mysql username $password="95887rj"; // Mysql password $db_name="bccsl"; // Database name $tbl_name="managers2"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="INSERT INTO Managers2 (ID, First, Last, City, Address, Postal, Home, Cell, Email, Username, Password, Church, Team) VALUES ('',$_POST[firstname]','$_POST[lastname]','$_POST[city]','$_POST[address]','$_POST[postal]','$_POST[home]','$_POST[cell]','$_POST[church]','$_POST[team]','$_POST[username]','$_POST[password]')"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con) ?>
  15. can't i see how it works. it is giving errors. thanks for this btw
  16. typically 7 in some occasions 12
  17. initiallly there will be two drop boxes. one with divisions and another with teams when the divsion is selected the teams drop box will be filled with the divisions teams then they will submit that page and be taken to another page where they will fill in the players information.
  18. first time posting. did some searches but didnt find exactly what i am looking for. dont flame cause i am posting in the wrong area. I am starting from scratch with a new registration form for a soccer league i manage a website for. I am having a brain cramp on how to do a few things. i have a layout in my head but i cant seem to get it to code. so i am starting over. what we want is managers to register their players for the rosters of their own club. We have 6 divisions with 42 teams. so on page one we would like to have to selection boxes which take info from DB Tables. One for division and one for team. on the second page we would like to have the players information filled in so it can be put into another table for that team. and a master table for the entire league. we need to have tracking dates for the additions as well. my question is would i need to the following tables and how can i do this with the least amount of code as possible: - Divisions - Teams - Master Player list - Team List i will probably have more questions regarding this as i go along. thanks stefan
×
×
  • 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.