PHP - Members Not Displaying How I Want It
i been working on my view Members page for a while now i can't seem to get it to work right
this is how i shows up for me and i want it to show up like this i think it has something to do with the loop, but have no idea how to fix this :S <?php require_once('settings.php'); checkLogin('1 2'); $Members = mysql_query("SELECT * FROM users") or die(mysql_error()); $numRowsMembers = mysql_num_rows($Members); ?> <?php for($count = 1; $count <= $numRowsMembers; $count++) { $name = mysql_fetch_array($Members); ?> <table border=2> <tr><td><img src="<? echo $name['main_P']?>" width="50" height="50"/> <a href="view_profile.php?username=<? echo $name['Username']?>"><? echo $name['Username']?></a> <? $onlinestatus = $name['ON_OFF']; if ( $onlinestatus == OFFLINE ) { echo ""; } else { echo "<font color=green>Online Now!</font>"; } ?> </td></tr></table> <? } ?> Similar Tutorials$_GET["find"] displays all users including the current user. The current user should not be displayed. I would like to display members that are NOT friends with the current user. Do I need to join the tables to make this work? $_GET["add"] inserts "screen_name" into "member and friendwith" Code: [Select] <?php if(isset($_GET["find"])) { $username = $_POST["screen_name"]; $query = "SELECT * FROM users WHERE screen_name LIKE '%$username%'"; $result = mysql_query($query); $exist = mysql_num_rows($result); if($exist=='0') { echo "No match found"; } else { echo "Matches for search: $username<br>"; while($currow = mysql_fetch_array($result)) { ?> <a href="users/member?addfriend=<?php echo $currow['screen_name']; ?>"><img src="avatars/<?php echo $currow["image"]; ?>" ></a> <?php } } } if(isset($_GET["add"])) { $username = $_SESSION["screen_name"]; $friend = $_GET["add"]; $query = "SELECT * FROM friends WHERE member='$username' AND friendwith='$friend'"; $result = mysql_query($query); $exist = mysql_num_rows($result); if($exist=='0') { $query = "INSERT INTO friends(member,friendwith) VALUES('$username','$friend')"; mysql_query($query); echo "$friend is now your friend!"; } else { echo "$friend is already your friend!"; } } ?> I created a field in "b_users" table as "banned" with default value="no". i.e, all members by default are set to "banned"="no". I was testing this code in my some pages to ban member and prevent access to my pages: $getid="SELECT * from b_users where id='$user_id'"; if($getid[banned]=="yes") { die("<center>You have been banned from posting</center>"); } else { show page Above code is banning all members. But i want to show ban message to members who's "banned" field value is set to "yes" only. How to do that? Hi Guys, I was wondering how I could wrap my members page so that only 5 members appear at a time and you have to click the next button to go onto the next page. Here is the current code. Code: [Select] $userid = $_SESSION['userid']; $query = "SELECT username, first_name, last_name, password, email, dob, mob, yob, year, gender FROM spotty WHERE user_id = '" . $userid . "'"; $query2 = "SELECT user_id FROM spotty WHERE user_id = '" . $userid . "'"; $result = mysql_query($query) or die('Error Getting Information Requested'); $result2 = mysql_query($query2) or die('Error Getting user_id'); $row = mysql_fetch_array($result); $row2 = mysql_fetch_array($result2); //$result = mysql_query($query); $num = mysql_num_rows($result2); $username = $row['username'] ; if($_SESSION['userid'] == NULL) { echo "Sorry, wrong username or password. You will be redirected in 5 seconds."; echo "<meta http-equiv='refresh' content='7;url=http://www.klueless.net/daisysite'>"; } else { echo "Members."; echo "<br />"; $membsquery="SELECT * FROM spotty WHERE showmem = '0'"; $membs=mysql_query($membsquery); $num=mysql_numrows($membs); $membresult = mysql_result($membs,$i,"user_id"); $useridname = $membresult['username']; echo "<br /> <br />" ; echo "<table border='0' cellspacing='2' cellpadding='2'> <tr> <font face='Comic Sans MS, cursive'>Click on a username to see their profile.</font> <br /> <br /> </tr>"; $i = 0; while ($i < $num) { $f1 = "<font face='Verdana, Geneva, sans-serif'><a href='profile.php?id=" . mysql_result($membs,$i,"user_id") . "'>" . mysql_result($membs,$i,"username") . "</a><br /><br />"; echo "<tr> <td>" . $f1 ."</font></td> </tr> </table>" ; $i++; } } mysql_close() ?> Thanks in advance! Hi guys, Im trying to get my members_profile.php to display the users profile.... I.e members_profile.php?boxerman will display my information. I've been at it for hours but no luck... This is what im trying to code: <?php include ("connect.php") $username = $_GET['username']; $user = mysql_query("SELECT * FROM user WHERE username = '$username'"); $user=mysql_fetch_assoc($user); echo "<h1>User Info</h1>"; echo "<b>Username:".$user['username']."<br>"; echo "<br>"; echo '<form name="backlistfrm" method="post" action="members.php">'; echo '<input type="submit" value="Back to The List">'; echo '</form>'; echo "<br>"; ?> It displays nothing when going to members_profile.php?boxerman Any advice as to why? Regards, B-Man Hi all, I am trying to write a script where the user can update their details. The html form sends the details across to this php file below. All the php variables echo after the query however the values do not replace the current values in the mysql database. Also for some reason the fname is the only one that changes no matter what the value is. It is entered in to mysql as '0'. I think the problem will be in the php below. As all the information below is echoed correctly, and because the value of 'fname' changes I know the connection is working fine. I guess the error must be in the query I have written, however there is no error that comes up... Hope you can point me in the right direction. Thanks <?php include("../cxn.php"); $fname = $_POST['fname']; $lname = $_POST['lname']; $newemail = $_POST['newemail']; $telephone = $_POST['telephone']; $icao = $_POST['icao']; $newpassword = $_POST['newpassword']; $id = $_POST['id']; $sql = "UPDATE Members SET fname='$fname' AND lname='$lname' AND email='$newemail' AND telephone='$telephone' AND password='$newpassword' AND icao='$icao' WHERE id='$id'"; $result = mysqli_query($cxn,$sql) or die ("Couldn't execute query"); echo "Your new details a <p>"; echo "$fname <br> $lname <br> $newemail <br> $telephone <br> $icao <br> $newpassword"; ?> This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=317715.0 Hi, Im getting better at this php lark! ok so now I have a signup website page, all details get added to the database including an email address, all works fine. now I would like a page, with a simple text box, that when you hit submit, it send the contents of the text box to all email address` in the members table, a really really simple newsletter so to speak. Its purely for my learning curve and Ill set up recapacha on it anyway. but Im getting a bit lost in the code, could someone guide me please? I can grab the contents of the text box like this: $letter = $_POST['letter]; but how do I send to all recipients? $recipient = ("SELECT email FROM members"); thanks Hi i followed a tutorial to create a register, login, members list and member profile pages but when i register, login and go to members list, the page its blank, i viewed the source code for the members page and its clearly trying to show something but i dont know what to do? Can any body help me please. I'm using 3 files to try and mass mail my members, massmail.php massmail-exe.php and elist.php massmail.php <form name="massmail" method="post" action="./massmail-exe.php"> <table width="450px"> <tr> <td valign="top"> <label for="subject">Subject</label> </td> <td valign="top"> <input type="text" name="subject" maxlength="50" size="30" id="subject"> </td> </tr> <tr> <td valign="top"> <label for="message">Email Content</label> </td> <td valign="top"> <textarea name="message" maxlength="9001" cols="100" rows="18" id="message"></textarea> </td> </tr> <tr> <td colspan="2" style="text-align:center"> <input type="submit" value="Submit"> </td> </tr> </table> </form> massmail-exe.php <?php // read the list of emails from the file. $email_list = file("./elist.php"); // count how many emails there are. $total_emails = count($email_list); // go through the list and trim off the newline character. for ($counter=0; $counter<$total_emails; $counter++) { $email_list[$counter] = trim($email_list[$counter]); } // implode the list into a single variable, put commas in, apply as $to value. $to = implode(",",$email_list); if ( mail($to,$_POST["subject"],$_POST["message"]) ) { echo "The email has been sent!"; } else { echo "The email has failed!"; } ?> and elist.php which has the email addresses. What is wrong because every time i try and send it it say query failed. Thanks so much. hey guys, im new to PHP and im trying to use a login script that allows users to register and login to my site from my database. on my login/register pages i get this error Warning: mysql_pconnect() [function.mysql-pconnect]: Unknown MySQL server host 'host' (1) in /home/hullcale/public_html/dbConfig.php on line 12 Error connecting to database. Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'hullcale'@'localhost' (using password: NO) in /home/hullcale/public_html/dbConfig.php on line 20 Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /home/hullcale/public_html/dbConfig.php on line 20 it seems like al my problems are from my page dbConfig.php on line 12 and 20, problem is i dont know how to edit them, here is the code from that page... things you may need to know is my databse is called hullcale_database, user is Admin, password is password, as for host im not actually sure where i get this from? any tips?! <? // Replace the variable values below // with your specific database information. $host = "localhost"; $user = "UserName"; $pass = "Password"; $db = "dbName"; // This part sets up the connection to the // database (so you don't need to reopen the connection // again on the same page). $ms = mysql_pconnect(host, $user, $pass); if ( !$ms ) { echo "Error connecting to database.\n"; } // Then you need to make sure the database you want // is selected. mysql_select_db($db); ?> Let me make this clear really quick, I am not talking about this forum. Ok, so how do I set up a way that I can make a simple messaging system on my website and make it so that I can have check boxes of who I can send a message to on my website. I have a recipient field and I need to know how I can make it so that only the specific members that are checked will get the message.........does this make sense? Can someone help me I have been working on this problem for some time. I have coded my page to welcome, firstname. At first in my insert I had used the id I have not switched it to the username as id was including everyone of my test names in the welcome. It looks like the sessions are continuing as I am able to go to the private section of the pages. However I am not sure what I have to do to produce the welcome, firstname to go to all the pages and let me know it is allowing the one member to access the private sessions. Also when I use the login form it does not recognize the users. It is like the connection to the database dies i guess. here is my codes. <?php session_start(); ini_set ("display_errors", "1"); error_reporting(E_ALL); ?> <!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>Welcome</title> <style type="text/css"> .background {color: #B56AFF; } </style> </head> <body> <p> <?php /* Program: login.php * Desc: Displays the new member welcome page. Greets * member by name and gives a choice to enter * restricted section or go back to main page. */ if (isset($_SESSION['username'])) { // Set the users session ID include("Connections/connect_to_mysql.php"); //Formulate Query //This is the best way to perform an SQL query $query = mysql_query ("SELECT * FROM `Members` WHERE username={$_SESSION['username']}"); $result = mysql_query($query); $numrows = mysql_num_rows($query); //Check result //This shows the actual query sent to MySQL and the error. Useful for debugging. if(!$result){ $message = 'Invalid query:' . mysql_error() . "\n"; $message .= 'Whole query:' . $query; die($message); } //Use result //Attempting to print $result won't allow access to information in the resource //One of the mysql result functions must be used //See also mysql_result(), mysql_fetch_array(), mysql_fetch_row(), etc. if($numrows!=0){ while($row = mysql_fetch_assoc($query)); $dbusername = $row['username']; $dbpassword = $row['password']; //check to see if they match! if($username==$dbusername&&md5($password)==$dbpassword){ echo "Welcome, ".$_SESSION['firstname']. "!<br><a href='logout_test.php'>Logout</a>"; } } } ?> </p> <p> </p> <p>Your new Member accounts lets you enter the members only section of our web site. You'll find special discounts, a profile of matches, live advise from experts, and much more.</p> <p>Your new Member ID and password were emailed to you. Store them carefully for future use.</p> <div style="text-align: center"> <p style="margin-top: .5in; font-weight: bold"> Glad you could join us!</p> <form action="profile.php" method="post"> <input type="submit" value="Enter the Members Only Section"> </form> <form action="index.php" method="post"> <input type="submit" value="Go to Main Page"> </form> </div> </body> </html> <?php session_start(); ini_set ("display_errors", "1"); error_reporting(E_ALL); ?> <!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>Welcome</title> <style type="text/css"> .background {color: #B56AFF; } </style> </head> <body> <p> <?php /* Program: login.php * Desc: Displays the new member welcome page. Greets * member by name and gives a choice to enter * restricted section or go back to main page. */ if (isset($_SESSION['username'])) { // Set the users session ID include("Connections/connect_to_mysql.php"); //Formulate Query //This is the best way to perform an SQL query $query = mysql_query ("SELECT * FROM `Members` WHERE username={$_SESSION['username']}"); $result = mysql_query($query); $numrows = mysql_num_rows($query); //Check result //This shows the actual query sent to MySQL and the error. Useful for debugging. if(!$result){ $message = 'Invalid query:' . mysql_error() . "\n"; $message .= 'Whole query:' . $query; die($message); } //Use result //Attempting to print $result won't allow access to information in the resource //One of the mysql result functions must be used //See also mysql_result(), mysql_fetch_array(), mysql_fetch_row(), etc. if($numrows!=0){ while($row = mysql_fetch_assoc($query)); $dbusername = $row['username']; $dbpassword = $row['password']; //check to see if they match! if($username==$dbusername&&md5($password)==$dbpassword){ echo "Welcome, ".$_SESSION['firstname']. "!<br><a href='logout_test.php'>Logout</a>"; } } } ?> Hi, i have a site www.gnetuk.net where people can register and login,. thats all fine but what code can i use on my php pages to see whos logged in im sure its going to be a simple line of code or smthink but i am new to this stuff. PLEASE HELP <G> Hey, Im having a problem where it wont show the members name only TBA, i was wondering if anyone could spot whats wrong Code - http://pastebin.com/8mEGcTqd page - http://tw.tghq.org/rosters/hto_roster_blistig.php Hello, I just joined today! I am very new to php, I'm sure you'll be able to tell I created a 'members area only' thanks to some awesome online tutorials!! The only part that isn't working is the page protection for the 'members only area'. I am using $_SESSION and ISSET, but wonder why page shows when the address to the protected page is typed directly in, (no session should exist) if I understand correctly ... Any help will be wonderful, I really can't do this on my own yet. I have tried many different combinations, I may have them all mixed together by now. Currently, I have this code to the top of the page I am trying to protect ... <? ob_start(); session_start(); //The users login details should be stored either in the post array or session array so we pull those login credentials $username = isset($_POST['username']) ? $_POST['username'] : $_SESSION['username']; $password = isset($_POST['password']) ? $_POST['password'] : $_SESSION['password']; //if no username session variable exists, redirect user: if(!isset($username)) { header("Location: login_form.php"); } ?> <html> <head> </head> <body> <p> This is the members only area</p> </body> </html> Hi all, I'm trying to write a function to return an array. But it keeps returning an empty array with NULL values .... This is my code. function ShowUserData ($uid) { $con = mysql_connect("localhost","user","pass"); if (!$con) { die('Oops !! something went wrong with the DB connection, Server said ' . mysql_error()); } mysql_select_db("db", $con); $password = md5($password); $query = mysql_query("SELECT * FROM `table` WHERE `uid` = '".$uid."'"); $num = mysql_num_rows($query); while ($row = mysql_fetch_array($query, MYSQL_NUM)) { $outArray = array('uid' =>$row['uid'], 'email' => $row['email'], 'name' => $row['name']); } return $outArray; } what am i doing wrong? When a user logs in and clicks on the update link they get sent to update.php. On the bottom of this page there is a "Back to Index" link which leads back to the page they were just on (index.php). However all the records in the mysql table is being listed instead if just the users. Any ideas why? I'm using sessions for my members area and echoing it to make sure it's being passed between both pages correctly and it is. Hey everyone! Thanks for taking the time to help. I have two files..a membership area and a commenting section. I am fairly new at these subjects but I am a quick learner. First off, I need help figuring out why my "register.php" in the members area file isn't working properly, everything looks to be ok but maybe I have been working on this too long. Quite frankly I can't check and see if all of the other scripts are correct because I can't get past the "register.php". So if you all wouldn't mind helping me out on this part, I would greatly appreciate it Secondly, I have a commenting section and in the "demo.php", there is a warning that appears as follows: "Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\Program Files (x86)\EasyPHP-5.3.8.1\www\comments\demo.php on line 17 " If someone could tell me what is missing or help me figure out what to do in simple terms, I would greatly appreciate that as well. Thanks! Gene [attachment deleted by admin] In my database I have a field for DOB for each of the records. This field is of mysql type 'date'. I would like to have a script to select only the members who's birthday it will be within the next month.. I'm very unsure as to how to approach the comparison of the current date and the date that is stored in the database... Anyone able to help me? Thanks Denno ok i have been trying for over a week now, and i just relearning php again after a few years of being lazy. lol here is a code snippet. Quote //prep the members $myFile2 = "members.txt"; $fh2 = fopen($myFile2, 'r'); $theData2 = fread($fh2, filesize($myFile2)); fclose($fh2); //echo $theData2; //grab the stats! $url = 'http://link'; $postdata = 'players='.$theData2.'&fields=all'; $ch = curl_init($url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); $data = curl_exec($ch); curl_close($ch); $data = json_decode($data,true); the orininal code Quote //prep the members $members = "member,member1,member two,member blue"; //grab the stats! $url = 'http://link'; $postdata = 'players='.$members.'&fields=all'; $ch = curl_init($url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); $data = curl_exec($ch); curl_close($ch); $data = json_decode($data,true); now the problium i am having is that with the original way, listing the members indevidualy is not the way i would like it, it would be easyer if it was in .txt form so i can add top it easyer. Also i have 300 people to add and the string doesnt seem to like that many people in it.....so i made a txt file, and it all works except that when i load the page it does not display the members stats from the external link. each players stats gets posted on the page and sorted who is ranked highest. echo works for echoing the contents of the file. however thats usless to me as i want the contents of the file to work like the orininal code. sorry if its confusing.... basicaly there is data from the link for each player asociated with there name. which is seperated by a , in the code. so each time a , is reached the code repeats its self posting each player till there are no more to post. the string is to short for me or just seems to not work with 300 people. i need it to read the external .txt file or something simular and work in the same mannor. |