Jump to content

giraffemedia

Members
  • Posts

    180
  • Joined

  • Last visited

    Never

Everything posted by giraffemedia

  1. I've figured it out. Instead of putting $query="SELECT * FROM members WHERE login =$_SESSION[Login]"; $result=mysql_query($query); I put $query="SELECT * FROM members WHERE login ='$_SESSION[Login]'"; $result=mysql_query($query); Why is that? Is it because it was being treated as a string before?
  2. Ok. I have the pages working now where I have set the session assigning the variable name Login with the login name like so... session_start(); $_SESSION['Login'] = $login; What I would like to do is select all the data for that user from the database where the login name matches the one set in the session variable. I'm not sure what code to put in on my mysql query though. Is it something like this... $getuser="SELECT * FROM members WHERE login = $_SESSION['Login']"; $getuser_result=mysql_query($getuser); etc etc It's not working at the moment but is it in the right area? Regards James
  3. Sorry Blackwinter but that makes no sense to me at all. All I want to do is retrieve the users first and last name from the database and store that in a session variable so that when they visit another page I can print things like "hello James" and "you were last here at..." and so on. I want to do this by retrieving the session variables if this is possible, which i'm sure it is - I just don't know how to do it. Hope this helps. James
  4. Hello what is the best way to track a user who logs in to my site? I am currently using sessions and a mysql database (to authenticate the user login). What I would like to do is set session variables at the start when login is confirmed so that in later pages I can echo their name etc to personalise the site a bit more. Is this the correct way to do this? If so how do I recall the variables from the session? If anyone has a better idea of how to do this please let me know. Regards James
  5. *bump again! Can anyone help? Doesn't matter how much, just get the ball rolling. James
  6. I use a mac and have Mamp Pro installed. It's a great user intuitive program and works perfect. James
  7. Okay Revraz, thanks for your help. Here is the code I have so far... <?php //Start session session_start(); //Check whether the session variable //SESS_MEMBER_ID is present or not if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID'])=='')) { header("location: ./library/access_denied.php"); exit(); } require_once ('includes/config.php'); require_once ('includes/opendb.php'); $query = "SELECT player_profile_first_name, player_profile_last_name FROM player_profiles ORDER BY player_profile_last_name"; $result=mysql_query($query); if (!$result) { die('Invalid query: ' . mysql_error()); } $num=mysql_num_rows($result); //Set the number of rows returned from the query as a variable $query2 = "SELECT player_profile_first_name, player_profile_last_name FROM player_profiles ORDER BY player_profile_last_name"; $result2=mysql_query($query2); if (!$result2) { die('Invalid query: ' . mysql_error()); } $num2=mysql_num_rows($result2); //Set the number of rows returned from the query as a variable ?> <html> <head> <title>. : Kilve Cricket Club - Admin : .</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link href="../kilvecc.css" rel="stylesheet" type="text/css" media="screen" /> <script language="javascript" type="text/javascript" src="date_picker/datetimepicker.js"></script> </head> <body> <div id="wrapper"> <div id="header"></div> <div id="main_nav"> <?php include ('admin_nav.php'); ?> </div> <div id="main_content"> <div id="main_content_inner"> <form name="fixture_result" method="post" action="../library/add_fixture_result_exec.php"> <table width="500" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="150" align="right" valign="top"><p>Match Date: </p></td> <td align="left" valign="top"> <input name="match_date" type="text" id="match_date"> <a href="javascript:NewCal('match_date','yyyymmdd')"><img src="date_picker/cal.gif" width="16" height="16" border="0" alt="Pick a date" /></a> </td> </tr> <tr> <td width="150" align="right" valign="top"><p>Match Time: </p></td> <td align="left" valign="top"><input name="match_time" type="text" id="match_time" value="<? echo ($_POST['match_time']); ?>"> </td> </tr> <tr> <td width="150" align="right" valign="top"><p>Match Opponent: </p></td> <td align="left" valign="top"><input name="match_team" type="text" id="match_team"></td> </tr> <tr> <td width="150" align="right" valign="top"><p>Match Venue: </p></td> <td align="left" valign="top"><input name="match_venue" type="text" id="match_venue"></td> </tr> <tr> <td width="150" align="right" valign="top"><p>Match Result: </p></td> <td align="left" valign="top"><input name="match_date2" type="text" id="match_date2"></td> </tr> <tr> <td width="150" align="right" valign="top"><p>Match Comments: </p></td> <td align="left" valign="top"><textarea name="match_comments" id="match_comments"></textarea></td> </tr> <tr> <td width="150" align="right" valign="top"><p>Match Scorecard: </p></td> <td align="left" valign="top"><textarea name="match_scorecard" id="match_scorecard"></textarea></td> </tr> <tr> <td width="150" align="right" valign="top"><p> </p></td> <td align="left" valign="top"> </td> </tr> <tr> <td width="150" align="right" valign="top"><p> </p></td> <td align="left" valign="top"><input type="submit" name="Submit" value="Submit"> <input type="reset" name="Submit2" value="Reset"></td> </tr> </table> </form> <? if ($num > 0) {echo "<select name=\"select\" id=\"player_list\">\n"; while($row = mysql_fetch_array($result)){ ?> <option value="<?php echo $row['player_profile_first_name'].' '.$row['player_profile_last_name']; ?>"><?php echo $row['player_profile_first_name'].' '.$row['player_profile_last_name']; ?></option> <?php } ?> </select> <? while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) { echo '<p>'.$row['player_profile_first_name'].' '.$row['player_profile_last_name'].'</p>'; } mysql_free_result ($result);} else { echo 'There are none you twat'; } ?> <br /> <? if ($num2 > 0) {echo "<select name=\"select\" id=\"player_list\">\n"; while($row2 = mysql_fetch_array($result2)){ ?> <option value="<?php echo $row2['player_profile_first_name'].' '.$row2['player_profile_last_name']; ?>"><?php echo $row2['player_profile_first_name'].' '.$row2['player_profile_last_name']; ?></option> <?php } ?> </select> <? while ($row2 = mysql_fetch_array($result2,MYSQL_ASSOC)) { echo '<p>'.$row2['player_profile_first_name'].' '.$row2['player_profile_last_name'].'</p>'; } mysql_free_result ($result);} else { echo 'There are none you twat'; } ?> </div> </div> <div id="main_content_right"> <div id="main_content_right_inner"> <?php include ('latest_news.php'); ?> </div> </div> <div id="footer"></div> </div> </body> </html> James
  8. Can anyone help - or just let me know if what i'm doing is right? James
  9. Hi guys i've got a page on my website for a sports scorecard to be entered. This consists of a form with 11 rows (one for each player) each consisting of player_name, runs_scored and runs_total entries. I have a seperate table in my db called player_profiles and i'm using this to pull in a list/menu of player names in the player_name entry. I have this working fine for one name, however i'm trying to get 11 rows performing the same SELECT query and the only way I can get it to work is having multiple (11) SELECT queries and multiple (11) while loops to populate the lists. is there any other way of doing this, or am I doing the right thing? If I have 1 SELECT query and use more than 1 list/menu, the first one works fine, but all other return with blank values - I presume because i've already pulled the data from the db. Anyone have any idea? Regards James
  10. I did try it without the " " but got a blank page. echo $_SESSION['SESS_MEMBER_ID']; That works fine and the session is being set. I guess I need to learn more about debugging. I'm ordering the VTC training cd on php so hopefully i'll be able to learn a lot more soon. Thanks for all you help. James
  11. Thanks for all your help guys. I understand I need to use the UPDATE query instead of INSERT, but why did: WHERE member_id ='$member[member_id]'"; work instead of: WHERE member_id ='".$_SESSION['SESS_MEMBER_ID'])"' "; Does this mean the session is not being set correctly?
  12. Aaaah - I get it. The result is" SELECT member_id FROM members WHERE login='james_payne' AND passwd='3de0746a7d2762a87add40dac2bc95a0' If I echo the session id I get the correct member_id as well.
  13. How do I do that (i'm just starting out!). Do I use: echo $_SESSION['SESS_MEMBER_ID']);
  14. Does it matter where on the page the variable goes?
  15. No. Another blank page i'm afraid. Is it a syntax error somewhere? This is causing the problems: $query="INSERT INTO members (last_visit) VALUES (CURRENT_TIMESTAMP()) WHERE login='$login' "; $result=mysql_query($query or die mysql_error()); If I take it out I can log in ok
  16. I get a blank page Adam. If I replace the line: $query="SELECT member_id FROM members WHERE login='$login' AND passwd=md5('$_POST['password']')"; with: $query="SELECT member_id FROM members WHERE login='$login' AND passwd='".md5($_POST['password'])."'"; I can log in.
  17. If I use this for the processing page I can echo the input fields: <?php //Start session session_start(); include('../includes/config.php'); include('../includes/opendb.php'); //Sanitize the value received from login field echo $_POST['login']; echo $_POST['password']; ?>
  18. Do i need to take out the header location to stop it from redirecting me first?
  19. I think i'm logging in fine revrz, otherwise the session wouldn't work correctly would it?
  20. Would this go in the processing form or the admin page once the user had been confirmed as logged in?
×
×
  • 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.