PHP - Problems With Members Area Script
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. Similar Tutorialshey 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); ?> 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> 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] Hi there I am having some issues with my site login. When a user logs in, it loads the page as a logged in user. But often when you click on a link inside the page, for some reason the user is logged out. After logging in again it sometimes does work, it's weird.. Also, even if you keep the page loaded in the browser yet you don't interact with it for a couple of minutes, and you click something, you're logged out again.. Here's my code, this is on the top of the page. When a user logs in, the $_POST['login'] is set. Code: [Select] <?php session_start(); setlocale(LC_ALL, 'nl_NL'); require_once('mysql_connect.inc.php'); date_default_timezone_set('Europe/Brussels'); $verbinding = mysql_connect(MYSQL_SERVER, MYSQL_GEBRUIKERSNAAM, MYSQL_WACHTWOORD) or die("Connection failed: " . mysql_error()); function CleanMyDirtyData($dirtydata){ return mysql_real_escape_string(htmlentities($dirtydata, ENT_QUOTES,'UTF-8')); } if(isset($_COOKIE['LoginCookie'])){ $hash = mysql_real_escape_string($_COOKIE['LoginCookie']); mysql_select_db('db'); $sql = "SELECT * FROM leden WHERE cookie_hash = '".$hash."'"; if($result = mysql_query($sql)){ $row = mysql_fetch_array($result); if(empty($row)){ setcookie('LoginCookie','',time()-3600); } if(mysql_num_rows($result) == 1){ $_SESSION['loggedin'] = true;//this is the parameter throughout the site that determines wether to show logged in data or not-logged in data. //extra parameters for identification $_SESSION['loggedinnick'] = $row['nick']; $_SESSION['loggedinvoornaam'] = $row['voornaam']; $_SESSION['loggedinachternaam'] = $row['achternaam']; $_SESSION['loggedinid'] = $row['id']; $_SESSION['loggedintype'] = $row['type']; } } } if(isset($_POST['login'])){ if(empty($_POST['username']) || empty($_POST['wachtwoord'])){ $_SESSION['melding'] = "You need to fill in both fields."; header('Location: index.php'); exit(); } $username = CleanMyDirtyData($_POST['username']); $wachtwoord = sha1(CleanMyDirtyData($_POST['wachtwoord'])); mysql_select_db('db'); $sqlmail = mysql_query("SELECT * FROM leden WHERE email='$username' AND wachtwoord = '$wachtwoord'"); $sqlnaam = mysql_query("SELECT * FROM leden WHERE nick='$username' AND wachtwoord = '$wachtwoord'"); if(mysql_num_rows($sqlmail) == 1 || mysql_num_rows($sqlnaam) == 1){ if(mysql_num_rows($sqlmail) == 1){ $row = mysql_fetch_array($sqlmail); }else{ $row = mysql_fetch_array($sqlnaam); } if(isset($_POST['remember'])){ $hash = sha1($whatev);//combination of 3 parameters; time, salt, and something else. setcookie('LoginCookie',$hash,time()+30000000); mysql_query("UPDATE leden SET cookie_hash='" . $hash . "' WHERE id='" . $row['id'] . "'")or die(mysql_error()); } $_SESSION['loggedin'] = true; $_SESSION['loggedinnick'] = $row['nick']; $_SESSION['loggedinvoornaam'] = $row['voornaam']; $_SESSION['loggedinachternaam'] = $row['achternaam']; $_SESSION['loggedinid'] = $row['id']; $_SESSION['loggedintype'] = $row['type']; $_SESSION['melding'] = "You have successfully logged in."; header('Location: index.php'); exit(); }else{ $_SESSION['melding'] = "Wrong combination."; header('Location: index.php'); exit(); } } ?> Code: [Select] <?php $ip = $_POST['ip']; $httpref = $_POST['httpref']; $httpagent = $_POST['httpagent']; $visitor = $_POST['visitor']; $visitormail = $_POST['visitormail']; $notes = $_POST['notes']; $attn = $_POST['attn']; #================================================================================================== #this looks for email if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,"."))) #================================================================================================== { echo "<h2>Use Back - Enter valid e-mail</h2>\n"; $badinput = "<h2>Feedback was NOT submitted</h2>\n"; echo $badinput; die ("Go back! ! "); } #================================================================================================== #this making sure all fields have been filled if(empty($visitor) || empty($visitormail) || empty($notes )) { #================================================================================================== echo "<h2>Use Back - Please fill in all fields</h2>\n"; die ("Use back! ! "); } #================================================================================================== #This is looking for captcha ====================================================================== session_start(); if ($_POST['captcha'] == $_SESSION['captcha']) #==================================================================================================== { $todayis = date("l, F j, Y, g:i a") ; $attn = $attn ; $subject = $attn; $notes = stripcslashes($notes); $message = " $todayis [EST] \n Attention: $attn \n Message: $notes \n From: $visitor ($visitormail)\n Additional Info : IP = $ip \n Browser Info: $httpagent \n Referral : $httpref \n "; $from = "From: $visitormail\r\n"; if ($attn == "Chairperson") mail("emailhere", $subject, $message, $from); if ($attn == "Securtary") mail("email here", $subject, $message, $from); if ($attn == "Treausure") mail("email here", $subject, $message, $from); if ($attn == "Training") mail("email here", $subject, $message, $from); if ($attn == "Expeditions") mail("email here", $subject, $message, $from); if ($attn == "Webmaster") mail("email here", $subject, $message, $from); ?> ok the thing is that it sends a email to Chairperson email but it will not send to the rest shuld i be useing "elseif"? I'm sorry this code is a mess, this is my attempt at a online youtube tutorial http://www.youtube.com/user/phpacademy#p/c/9CC58D1B2A2D83D6/9/cBJZZlLrXGo The script runs with no parse errors but it does not the following: - present error messages when input is incorrect - enter correct input into the database - retain the user input in the form so the user does not need to re enter the information. I would just use another script but this is the 2nd part of a tutorial that will really help me learn so I need this to work . Any help appreciated. 1. 2. <?php 3. include("design/header.php"); 4. require("connect.php"); 5. 6. //register code 7. 8. 9. if(isset($POST['submit'])) 10. { 11. //grab submitted data 12. $firstname = $_POST['firstname']; 13. $lastname = $_POST['lastname']; 14. $username = $_POST['username']; 15. $password = $_POST['password']; 16. $password_repeat = $_POST['password_repeat']; 17. 18. $dob_year = $_POST['dob_year']; 19. $dob_month = $_POST['dob_month']; 20. $dob_day = $_POST['dob_day']; 21. 22. $gender = $_POST['gender']; 23. 24. if ( 25. $firstname&& 26. $lastname&& 27. $username&& 28. $password&& 29. $password_repeat&& 30. $dob_year&& 31. $dob_month&& 32. $dob_day&& 33. $gender 34. ) 35. { 36. 37. //validation 38. if(strlen($firstname)>25 || strlen($lastname)>25 || strlen($username)>25) 39. echo "Firstname, lastname and username must be no more than 25 characters."; 40. 41. 42. else 43. { 44. if (strlen($password)>25 || strlen($password)<6) 45. echo "Password must be between 6 and 25 characters."; 46. 47. else 48. { 49. if (is_numberic($dob_year)&&is_numberic($dob_month)&&is_numberic($dob_day)) 50. { 51. 52. if (strlen($dob_year)>4||strlen($dob_year)>2||strlen($dob_year)>2) 53. echo "Date of birth must be 4 characters, month and must be 2."; 54. else 55. { 56. if ($gender=="Male"||$gender=="Female") 57. { 58. //compare pass 59. if ($password==$password_repeat) 60. { 61. //check dob limits for month and day 62. if ($dob_month>12||$dob_day>31) 63. echo "Date of birth month or day is bigger than expected!"; 64. else{ 65. //check for existing user 66. $query =mysql_query("SELECT * FROM users WHERE username='$username'"); 67. if (mysql_num_rows($query)>=1) 68. echo "That username is already taken."; 69. else { 70. //success!! 71. $dob_db = "$dob_year-$dob_month-$dob_day"; 72. $password_db = md5($password); 73. 74. switch ($gender) 75. { 76. case "Male": 77. $gender_db = "M"; 78. break; 79. case "Female": 80. $gender_db = "F"; 81. break; 82. $register = mysql_query("INSERT INTO user VALUES ('','$firstname','$lastname','$username','$password_db','$dob_db','$gender_db')"); 83. echo "success!"; 84. } 85. } 86. } 87. } 88. else 89. {echo "Passwords must match"; 90. } 91. } 92. else 93. echo "Gender must be Male or Female."; 94. } 95. } 96. else 97. echo "Date of birth must be in number form. For example 1993/05/30"; 98. } 99. } 100. }else{ 101. echo "Please enter your details and click Register!"; 102. } 103. } 104. 105. ?> 106. 107. <p> 108. <form action='register.php' method='POST'> 109. 110. <table width='60%'> 111. <tr> 112. <td width='40%' align='right'> 113. <font size='2' face='arial'>Firstname: 114. </td> 115. <td> 116. <input type='text' value='<?php echo $firstname; ?>' name='firstname' maxlength='25'> 117. </td> 118. </tr> 119. <tr> 120. <td width='40%' align='right'> 121. <font size='2' face='arial'>Lastname: 122. </td> 123. <td> 124. <input type='text' value='<?php echo $lastname; ?>' name='lastname' maxlength='25'> 125. </td> 126. </tr> 127. <tr> 128. <td width='40%' align='right'> 129. <font size='2' face='arial'>Username: 130. </td> 131. <td> 132. <input type='text' value='<?php echo $username; ?>' name='username' maxlength='25'> 133. </td> 134. </tr> 135. <tr> 136. <td width='40%' align='right'> 137. <font size='2' face='arial'>Password: 138. </td> 139. <td> 140. <input type='password' name='password' maxlength='25'> 141. </td> 142. </tr> 143. <tr> 144. <td width='40%' align='right'> 145. <font size='2' face='arial'>Repeat Password: 146. </td> 147. <td> 148. <input type='password' name='password_repeat' maxlength='25'> 149. </td> 150. </tr> 151. <tr> 152. <td width='40%' align='right'> 153. <font size='2' face='arial'>Date of birth: 154. </td> 155. <td> 156. <input type='text' name='dob_year' maxlength='4' size='3' value='<?php if ($dob_year) echo $dob_year; else echo "YYYY";?>'> /<input type='text' name='dob_month' maxlength='2' size='1' value='<?php if ($dob_month) echo $dob_month; else echo "MM";?>'> / <input type='text' name='dob_day' maxlength='2' size='1' value='<?php if ($dob_day) echo $dob_day; else echo "DD";?>'> 157. </td> 158. </tr> 159. <tr> 160. <td width='40%' align='right'> 161. <font size='2' face='arial'>Gender: 162. </td> 163. <td> 164. <select name='gender'> 165. <option>Female</option> 166. <option>Male</option> 167. </select> 168. </td> 169. </tr> 170. 171. </table> 172. <div align='right'><input type='submit' name='submit' value='Register'> 173. </form> 174. 175. 176. <?php 177. include("design/footer.php"); 178. 179. ?> 180. 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? Ok, I submit the form, and when the next page displays, it says recieved with the persons name, but it wont post their email, and it wont ever send the message to the email address......... i've been playing with it all day long and just cannot figure it out, about to rip my hair out... any help would be appreciated. Contact.php page Code: [Select] <?php // Header Include include('includes/header.php'); ?> <!-- BEGIN SITE CONTENT INCLUDES HERE --> <!-- Index page included --> <table border="0" cellpadding="5" cellspacing="0" width="300" align="center"> <tr> <td><font face="verdana" size="2" color=#"000000"><b>Feedback Form</b></font></td> <tr> <td><form name="contact" method="post" action="contact_submit.php"> <font face="verdana" size="1" color="#1b4a1b">Your Name:<br /> <input type="text" name="name" size="25" /> <br /> Email:<br /> <input type="text" name"email" size="25" /> <br /> Comments:</font><br /> <textarea name="comments" rows="5" cols="30"></textarea> <br /><input type="submit" name="submit" value="Send" /> </form></td> </tr> </table> <br /><br /> <!-- / End Index Page --> <!-- / END SITE CONTENT INCLUDES HERE --> <!-- Footer Include --> <?php include('includes/footer.php'); ?> Form Processing Script contact_submit.php Code: [Select] <?php $to = "tonyagmatrix@gmail.com"; $re = "Feedback Form"; $msg = $comments; mail($to,$re,$msg); ?> <html><head><title>Message Recieved</title></head> <body> <h3>Thank you for your feedback <?PHP echo ($name); ?></h3> <br />We value your opinions and any questions will be replyed to your email address: <?php echo ($email); ?> </body></html> Does anyone have any idea wtf is wrong? Hi guys, I've got an image uploader based on Uploadify, first let me set out what I want the script to do and what it currently does/doesn't do: Upload files of various types into folders named with the Order ID - OK Process the files by checking the file type and acting accordingly - OK Create thumbnails of the images in the /thumbs subdirectory - OK If the file is a PDF, create JPEG images of all pages and subsequent thumbnails - OK If the file is a ZIP, unzip and re-process the contents based on the above rules - FAIL As you can see I'm nearly at the end of my wishlist with this script, currently when it receives a ZIP file is unzip's it correctly placing the contents in the parent (Order-ID) directory however I'm then left with the same situation I have at the very beginning of the script, for example: File in -> "What kind of file are you?" -> Process file based on the answer. What I need to do is: File in -> "What kind of file are you? Oh! a Zip File, let's unzip and ask the same question of the contents!" -> Process contents. So basically I need to ask the same question twice, once of the zip and once of the contents of the unzipped file. This is where I'm struggling, someone told me to use a function which I tried but it kept breaking and I wasn't sure why. Therefore I have attached 2 files. 1 which currently works 99% except for "asking the question again" and one which doesn't work but I was told is the right way to do it File 1: Works 99%. Code: [Select] <?php /* TomBigFile v2.0 Based on Uploadify v2.1.4 Automatic folder creation dependant on order number with a thumbnail subdirectory. All files in are subject to a process which determines their type and acts accordingly. PDF's are automatically converted on the fly to 2 sets of JPEG's and stored accordingly to be accessed by Customer Accounts and Sales Order details area. Revised May 2011 */ // RECEIVE THE DATA FROM THE UPLOAD AND ASSIGN THE VARIABLES if (!empty($_FILES)) { $tempFile = $_FILES['Filedata']['tmp_name']; $targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/'; $targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name']; // $fileTypes = str_replace('*.','',$_REQUEST['fileext']); // $fileTypes = str_replace(';','|',$fileTypes); // $typesArray = split('\|',$fileTypes); // $fileParts = pathinfo($_FILES['Filedata']['name']); // if (in_array($fileParts['extension'],$typesArray)) { // CREATE THE PARENT DIRECTORY BASED ON ORDER ID AND THE THUMBS SUBDIRECTORY mkdir(str_replace('//','/',$targetPath), 0755, true); mkdir($targetPath . "thumbs", 0755, true); // create thumbs dir move_uploaded_file($tempFile,$targetFile); echo str_replace($_SERVER['DOCUMENT_ROOT'],'',$targetFile); // } else { // echo 'Invalid file type.'; // } } // BEGIN CHECKING THE IMAGE LOOKING AT THE FILE TYPE AND ACTING ACCORDINGLY $imgsize = getimagesize($targetFile); switch(strtolower(substr($targetFile, -3))){ case "pdf": $large = substr_replace($targetFile , 'jpg', strrpos($targetFile , '.') +1); $thumbnail = dirname($large).'/thumbs/'.basename(substr($large, 0, -4)."_thumb".strtolower(substr($large, -4))); $cmd = "$targetFile -write $large -thumbnail 64x64 $thumbnail "; exec("convert $cmd "); exit; break; case "jpg": $image = imagecreatefromjpeg($targetFile); break; case "png": $image = imagecreatefrompng($targetFile); break; case "gif": $image = imagecreatefromgif($targetFile); break; case "zip": $zip = new ZipArchive(); $zip->open($targetFile); $zip->extractTo($targetPath); $zip->close(); break; default: exit; break; } $width = 60; //New width of image $height = $imgsize[1]/$imgsize[0]*$width; //This maintains proportions $src_w = $imgsize[0]; $src_h = $imgsize[1]; $picture = imagecreatetruecolor($width, $height); imagealphablending($picture, false); imagesavealpha($picture, true); $bool = imagecopyresampled($picture, $image, 0, 0, 0, 0, $width, $height, $src_w, $src_h); // SAVE THE IMAGE(S) if($bool){ switch(strtolower(substr($targetFile, -3))){ case "jpg": //header("Content-Type: image/jpeg"); $bool2 = imagejpeg($picture,$targetPath."thumbs/".substr($_FILES['Filedata']['name'], 0, -4)."_thumb".strtolower(substr($targetFile, -4))); break; case "png": //header("Content-Type: image/png"); imagepng($picture,$targetPath."thumbs/".substr($_FILES['Filedata']['name'], 0, -4)."_thumb".strtolower(substr($targetFile, -4))); break; case "gif": //header("Content-Type: image/gif"); imagegif($picture,$targetPath."thumbs/".substr($_FILES['Filedata']['name'], 0, -4)."_thumb".strtolower(substr($targetFile, -4))); break; } } imagedestroy($picture); imagedestroy($image); echo '1'; // Important so upload will work on OSX ?> File 2: Doesn't work for me but I was told is correct method(s). Code: [Select] <?php /* TomBigFile v2.0 Based on Uploadify v2.1.4 Automatic folder creation dependant on order number with a thumbnail subdirectory. All files in are subject to a process which determines their type and acts accordingly. PDF's are automatically converted on the fly to 2 sets of JPEG's and stored accordingly to be accessed by Customer Accounts and Sales Order details area. Revised May 2011 */ if (!empty($_FILES)) { $tempFile = $_FILES['Filedata']['tmp_name']; $targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/'; $targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name']; // $fileTypes = str_replace('*.','',$_REQUEST['fileext']); // $fileTypes = str_replace(';','|',$fileTypes); // $typesArray = split('\|',$fileTypes); // $fileParts = pathinfo($_FILES['Filedata']['name']); // if (in_array($fileParts['extension'],$typesArray)) { // Uncomment the following line if you want to make the directory if it doesn't exist mkdir(str_replace('//','/',$targetPath), 0755, true); mkdir($targetPath . "thumbs", 0755, true); // create thumbs dir move_uploaded_file($tempFile,$targetFile); echo str_replace($_SERVER['DOCUMENT_ROOT'],'',$targetFile); // } else { // echo 'Invalid file type.'; // } } // start again here after ZIP!!!! function fileScanner($targetFile, $targetPath) { $imgsize = getimagesize($targetFile); $width = 60; //New width of image $height = $imgsize[1]/$imgsize[0]*$width; //This maintains proportions $src_w = $imgsize[0]; $src_h = $imgsize[1]; $picture = imagecreatetruecolor($width, $height); imagealphablending($picture, false); imagesavealpha($picture, true); $bool = imagecopyresampled($picture, $image, 0, 0, 0, 0, $width, $height, $src_w, $src_h); if($bool){ switch(strtolower(substr($targetFile, -3))){ case "jpg": //header("Content-Type: image/jpeg"); $bool2 = imagejpeg($picture,$targetPath."thumbs/".substr($_FILES['Filedata']['name'], 0, -4)."_thumb".strtolower(substr($targetFile, -4))); break; case "png": //header("Content-Type: image/png"); imagepng($picture,$targetPath."thumbs/".substr($_FILES['Filedata']['name'], 0, -4)."_thumb".strtolower(substr($targetFile, -4))); break; case "gif": //header("Content-Type: image/gif"); imagegif($picture,$targetPath."thumbs/".substr($_FILES['Filedata']['name'], 0, -4)."_thumb".strtolower(substr($targetFile, -4))); break; } } imagedestroy($picture); imagedestroy($image); } $imgsize = getimagesize($targetFile); switch(strtolower(substr($targetFile, -3))){ case "pdf": $large = substr_replace($targetFile , 'jpg', strrpos($targetFile , '.') +1); $thumbnail = dirname($large).'/thumbs/'.basename(substr($large, 0, -4)."_thumb".strtolower(substr($large, -4))); $cmd = "$targetFile -write $large -thumbnail 64x64 $thumbnail "; exec("convert $cmd "); exit; break; case "jpg": $image = imagecreatefromjpeg($targetFile); break; case "png": $image = imagecreatefrompng($targetFile); break; case "gif": $image = imagecreatefromgif($targetFile); break; case "zip": $zip = new ZipArchive(); $zip->open($targetFile); $zip->extractTo($targetPath); $zip->close(); fileScanner($targetFile, $targetPath); break; default: exit; break; } fileScanner($targetFile, $targetPath); // $width = 60; //New width of image // $height = $imgsize[1]/$imgsize[0]*$width; //This maintains proportions // // $src_w = $imgsize[0]; // $src_h = $imgsize[1]; // // // $picture = imagecreatetruecolor($width, $height); // imagealphablending($picture, false); // imagesavealpha($picture, true); // $bool = imagecopyresampled($picture, $image, 0, 0, 0, 0, $width, $height, $src_w, $src_h); // // if($bool){ // switch(strtolower(substr($targetFile, -3))){ // case "jpg": // //header("Content-Type: image/jpeg"); // $bool2 = imagejpeg($picture,$targetPath."thumbs/".substr($_FILES['Filedata']['name'], 0, -4)."_thumb".strtolower(substr($targetFile, -4))); // break; // case "png": // //header("Content-Type: image/png"); // imagepng($picture,$targetPath."thumbs/".substr($_FILES['Filedata']['name'], 0, -4)."_thumb".strtolower(substr($targetFile, -4))); // break; // case "gif": // //header("Content-Type: image/gif"); // imagegif($picture,$targetPath."thumbs/".substr($_FILES['Filedata']['name'], 0, -4)."_thumb".strtolower(substr($targetFile, -4))); // break; // } // } // // imagedestroy($picture); // imagedestroy($image); echo '1'; // Important so upload will work on OSX ?> If anyone could help me with this I'd greatly appreciate it, I've been reading so many guides on functions and arguments my brain is fried and I fear I've strayed from the subject of what I want to do! Many thanks. 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 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! 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> <? } ?> $_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!"; } } ?> 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. 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? 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"; ?> 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 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=317715.0 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. Hello to all!
I ask myself the following question: Is there a way that is better to calculate the number of members / guests online |