Jump to content

silverglade

Members
  • Posts

    727
  • Joined

  • Last visited

    Never

Everything posted by silverglade

  1. i thought about starting another account but I am too lazy to hide my ip. how many posts i have , does that offend you personally? i am not sure why i still am crappy at php. I know i did take like a year or more away from it, and when i came back could not remember much. but either way, my number of posts, is that your personal and important business? when you judge a person on the forums, do you say to yourself "well this guy have 1k posts and is asking a dumb question, let me not help him and send him an insult" after all i am the guru moderator here. i am going to try to start a new account now despite of this websites monitoring and displaying everyone's ip which i think is lame.
  2. you obviously don't remember my username Thorpe. you just deleted my previous thread and replaced it with MOVED" someone elses thread here". You have done nothing in ALL of my previous thread but put nasty comments in, about my number of posts, etc. You come on at about 3 in the morning my time and start posting crap on my threads, i have had enough of you. next admin comes on i am reporting you , enough is enough. if you are offended by my threads and post number keep it to yourself. i just pray you are not the owner of this site
  3. here is my final public and private profile code people helped me with here. IT WORKS!! HAHAH. first the "edit profile page" put this in your page. echo "<p> </p><strong><a href='viewProfile.php?userPage=".$currentUser."'>View Profile</a></strong><p>&nbsp</p>"; //checks if the form has been submitted echo "<h3>EDIT PROFILE PAGE FOR ".$currentUser."</h3>"; then on the public profile page, put this in your page. $_GET["userPage"]; if($_GET["userPage"]==$currentUser) { echo "<p> </p><strong><a href='profileUpload.php'".$currentUser."'>Edit Profile</a></strong><p>&nbsp</p>'"; } enjoy!! thanks for helping everyone
  4. maybe this is right? echo "<a href='viewProfile.php?userPage='. $currentUser. '>View Profile</a></strong><p> </p>'"; LMAO!! I think this is the right one. echo "<p> </p><strong><a href='viewProfile.php?userPage=".$currentUser."'>View Profile</a></strong><p>&nbsp</p>";
  5. can someone please help me with this link? It is not looking right in my editor every time I try to do the quotations. Here it is messed up. Please if someone can show me the right way to do it in code, I would really appreciate it. (The quotations) echo "<a href='viewProfile.php?userPage='" . $currentUser. " >View Profile</a></strong><p> </p>";
  6. using google does not equal someone not being able or not wanting to think. Have you ever used Google? yes you have.
  7. thank you. this is what I did so far. echo "viewProfile.php?user=" . $currentUser.'>View Profile</a></strong><p> </p>"; now I have to somehow check for that on the viewProfile.php page not sure how to do that, googling it now. what would newbie php guys do without google? they'd be in bad shape. LOL
  8. That is intelligent. great thank you very much. I didn't know how to make different users based on number id's so I am using session CurrentUser as the variable . I am using the usernames. so if I have $currentUser=$_SESSION['name_of_user']; how do I make the link do this? viewProfile.php?currentUser=thomas assuming $currentUser=="thomas" I know I should have used the user number Id but I used the unique usernames to check for identity in the script. I don't want to change it now. EDIT: this is what I have so far on the edit profile page echo "viewProfile.php?user=" . $currentUser.'>View Profile</a></strong><p> </p>"; now I have to somehow check for that on the viewProfile.php page
  9. thank you. Yes I figured out that I would have 2 pages, one is the public and one is the private, and the only difference between them is that the "public" will have the option of showing a link back to the "edit profile" page if the current user is the owner of the pages, but if it is a viewing member, the edit profile link on the public profile page should not be shown. so basically if viewinguser, don't show edit profile link, if viewinguser==currentUser, show edit profile link I don't know how to do this in code, to define "viewinguser", I don't know how to do it without creating a million individual named pages like "tomsProfile.php" "JoesProfile.php", and then check if the currentUser is equal to the name on the individual page. but that solution seems ridiculous and I am pretty sure there is a way to do it with just using one changing public profile page with some simple little code, but I am not that smart yet. LOL. please if anyone knows please help. thanks
  10. thank you for that. I have come up with some pseudocode that I can't solve. Here is the little puzzle. if viewinguser= user of that page, show edit profile link, otherwise, do not. I don't know how to define or check for the "viewing user" in the database or the member's page. basically I am using a "viewProfile.php" page so the member can view their own profile as it looks to others, and this view profile page will only have a link back to the "edit profile" page if the current user is the owner of that page. but please, how do I identify in code the "viewing user" to differentiate that from the "currentUser" or the owner of the page being viewed?
  11. Hi, I am making a dating site where I have made the user profile edit page visible to the user when they log in, and I think I can get away with not showing the user their "public" profile view. But I definitely need to show other users on the site the "public" non editing profile page view. But I don't know how to do this. I have yet to create the search, search results, thumbnails with optional descriptions of the possible dating results. But I first want to just get 2 versions of the user profile page view. One that the user sees that I have already done. (The editable one). And the other I need to make which is the page the other users will see, (The public profile) Please if anyone has any idea how to do this I would greatly appreciate it, especially if you have any pseudocode ideas. thank you.
  12. Ok I was able to fix 2 and 4 on your list. Thank you very much for pointing out my not checking for png, gif or jpeg and not just jpg on my file delete. That was pretty serious. I will have to leave the other numbers on your list as I don't understand it totally. I am using a mix of my own code and tutorial code. So the page works, but it is not done totally correctly. I guess for now I will have to leave it as is except for fixing 2 and 4. thanks.
  13. WOW. lol. I just woke up a while ago. That stinks. I am going to have to work on all of that. Thanks for pointing it out. Will take me a while to digest what you have just said.
  14. ok thank you. I can't get anything on that linked page to work, I guess I will just have to deal with it .
  15. this does not force a refresh either. echo "<img src='{$dir}{$newname}?<? echo rand(1,3000); ?>' />";
  16. I added this to the top of the script ob_start(); and this to the end of the script ob_end_flush(); and I get the error "The image http://mysite...blah blah" cannot be displayed because it contains errors"
  17. I think I can use this to force an image refresh, header('Content-type: image/jpeg'); readfile('images/'.$_GET['image']); but it gives me a "headers already sent" error because on the page I echo out a few things like the page header at the top from another php file. any help appreciated. thanks. ps: there is no extra whitespace at the top of my header file.
  18. Hi, I have a "user profile" page and it has a profile image upload form. I have it so that the old profile image is deleted, and the new image is uploaded and the new image is echoed out using the name of the new file from the database. The problem is, when I click submit to add the new image, the old image still stays there and the new image does not show up. Only when I manually click refresh on my browser does the new image show up. That is going to be bad for my users. Please if anyone can help, I'd greatly appreciate it. Below is the code I am using to delete the old image, and code to upload the image as well, when the photo upload form is used. if(isset($_POST['photoUpload'])) { if(file_exists("images/".$currentUser.".jpg")){ unlink("images/".$currentUser.".jpg"); clearstatcache(); } //reads the name of the file the user submitted for uploading $image=$_FILES['image']['name']; //if it is not empty if ($image) { //get the original name of the file from the clients machine $filename = stripslashes($_FILES['image']['name']); //get the extension of the file in a lower case format $extension = getExtension($filename); $extension = strtolower($extension); //if it is not a known extension, we will suppose it is an error and will not upload the file, //otherwise we will do more tests if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { //print error message echo '<h1>Unknown extension!</h1>'; $errors=1; } } //end if here //was else here //get the size of the image in bytes //$_FILES['image']['tmp_name'] is the temporary filename of the file //in which the uploaded file was stored on the server $size=filesize($_FILES['image']['tmp_name']); //compare the size with the maxim size we defined and print error if bigger if ($size > MAX_SIZE*1024) { echo '<h1>You have exceeded the size limit!</h1>'; $errors=1; } //we will give an unique name, for example the time in unix time format $image_name= $currentUser .'.'.$extension; //$image_name=time().'.'.$extension; //the new name will be containing the full path where will be stored (images folder) $newname=$image_name; //"images/". // Connects to your Database mysql_connect("host", "user", "pass") or die(mysql_error()); mysql_select_db("database") or die(mysql_error()) ; //we verify if the image has been uploaded, and print error instead $copied = copy($_FILES['image']['tmp_name'], "images/".$newname); // update the photo name in the database $result = mysql_query("UPDATE users SET profilePhoto='$newname' WHERE username='$currentUser'") or die(mysql_error()); if (!$copied) { echo '<h1>Copy unsuccessful!</h1>'; $errors=1; } else{ $dir="images/"; echo "<p>Profile Picture Change Successful!</p>"; echo "<img src='{$dir}{$newname}' alt='{$newname}' height='200' width='200' />"; echo "<p></p>"; } }
  19. awesome thank you. I FIXED IT!! hehe. Does anyone know how I can replace a user profile image and have it refresh to the new image as soon as I submit the form? The image is not refreshing, I have to reload the whole page for the new profile image to be seen. here is the code I am using to do the image replacement. if(file_exists("images/".$currentUser.".jpg")){ unlink("images/".$currentUser.".jpg"); clearstatcache(); }
  20. thank you very much for that. I used error reporting and it caught if(result) should be if($result). which would be the reason why the images did not show. But they don't show up still. I used the mysqlconnect(); to indicate to the viewers of the post that that is where I connected to the database at that point, because when I did not paste in the database connecting information at those spots, I got error messages, so I started pasting in the database connection information right in the spots where I posted "mysqlconnect();" in this post. the images are not uploading to the "images" directory on the server, and I think move_uploaded_file is to move existing files on the server. I don't think there is move_uploaded_photo? thank you for helping me to this point.
  21. Hi, I am storing image names in the database, and the image in the server directory "image". I am using time() to rename the images. Basically what I do is, check the images, rename them, upload to server (or supposed to), and insert the name of the image into the database, then I use the database image name in an img src, to output the uploaded image. Here is the code. Basically it looks like the images are not uploading to the "images" directory on the server. Any help GREATLY appreciated. thanks. here is the upload code. to put image in the server renamed, and then under that the image display code taken from the database. <?php if(isset($_POST['photoUpload'])) { //reads the name of the file the user submitted for uploading $image=$_FILES['image']['name']; //if it is not empty if ($image) { //get the original name of the file from the clients machine $filename = stripslashes($_FILES['image']['name']); //get the extension of the file in a lower case format $extension = getExtension($filename); $extension = strtolower($extension); //if it is not a known extension, we will suppose it is an error and will not upload the file, //otherwise we will do more tests if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { //print error message echo '<h1>Unknown extension!</h1>'; $errors=1; } } //end if here //was else here //get the size of the image in bytes //$_FILES['image']['tmp_name'] is the temporary filename of the file //in which the uploaded file was stored on the server $size=filesize($_FILES['image']['tmp_name']); //compare the size with the maxim size we defined and print error if bigger if ($size > MAX_SIZE*1024) { echo '<h1>You have exceeded the size limit!</h1>'; $errors=1; } //we will give an unique name, for example the time in unix time format $image_name=time().'.'.$extension; //the new name will be containing the full path where will be stored (images folder) $newname=$image_name; //we verify if the image has been uploaded, and print error instead $copied = copy($_FILES['image']['tmp_name'], $newname); if (!$copied) { echo '<h1>Copy unsuccessful!</h1>'; $errors=1; } else{ mysqlconnect(); // update the photo name in the database $result = mysql_query("UPDATE users SET profilePhoto='$newname' WHERE username='$currentUser'") or die(mysql_error()); echo "<h1>Photo Update Successful!</h1>"; } //replace and upload pic name to the database for later output from database. //echo out all images /* $dir = "images/"; if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if($file == ".") continue; if($file == "..") continue; echo "<img src='{$dir}{$file}' alt='{$file}' height='200' width='200' />"; } closedir($dh); } } */ mysqlconnect(); // SELECT FOR THE IMAGE $mysql = "SELECT profilePhoto FROM users WHERE username ='$currentUser'"; $result = mysql_query($mysql); $dir = "images/"; // if there is a result, echo out the pic using the new name of the pic if(result) { echo "<img src='{$dir}{$newname}' alt='{$newname}' height='200' width='200' />"; } if (!$result) { echo "Could not successfully run query ($sql) from DB: " . mysql_error(); exit; } if (mysql_num_rows($result) == 0) { echo "No rows found, nothing to print so am exiting"; exit; }//isset photo if ?>
  22. well to save face I figured I would put in my solution. not sure if it's kosher but it works. //update user profile info based on logged in username $result = mysql_query("UPDATE users SET firstName='$firstName', lastName='$lastName', birthday='$birthday',country='$country',city='$city',state='$state',aboutMe='$aboutMe' WHERE username='$currentUser'") or die(mysql_error()); /////////////////////////////////output user info $sql = "SELECT firstName, lastName, birthday, country, city, state, aboutMe FROM users WHERE username='$currentUser'"; $result = mysql_query($sql); if (!$result) { echo "Could not successfully run query ($sql) from DB: " . mysql_error(); exit; } if (mysql_num_rows($result) == 0) { echo "No rows found, nothing to print so am exiting"; exit; } //ECHO OUT CURRENT PROFILE INFORMATION FOR LOGGED IN USER. echo "Current Profile Information. Fill out form to update.<p></p>"; while ($row = mysql_fetch_assoc($result)) { echo "First Name: ".$row["firstName"]."<br />"; echo "Last Name: ".$row["lastName"]."<br />"; echo "Birthday: ".$row["birthday"]."<br />"; echo "Country: ".$row["country"]."<br />"; echo "State/Region: ".$row["state"]."<br />"; echo "City: ".$row["city"]."<br />"; echo "About Me: ".$row["aboutMe"]."<br />"; } mysql_free_result($result); }//end submit
  23. thank you. I changed it to update. I am getting the following error now. the username is 'd'. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(firstName,lastName,birthday,country,city, state, aboutMe) VALUES ('d', '' at line 1 and my new code for putting the data in for the user is //Writes the information to the database $result= mysql_query("UPDATE users (firstName,lastName,birthday,country,city, state, aboutMe) VALUES ('$firstName', '$lastName', '$birthday', '$country', '$city','$state','$aboutMe') WHERE username = $currentUser") or die(mysql_error()); // get the first (and hopefully only) entry from the result $row = mysql_fetch_assoc($result); echo $row['firstName']." <br />".$row['lastName']. "<br />".$row['birthday']."<br />".$row['country']. "<br />".$row['city']."<br />".$row['state']."<br />".$row['aboutMe'];
  24. hi, can anyone please tell me why this statement does not work please? I get the following error. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE username = 1' at line 2 the $currentUser for the session is "1". so I know that is working. but to update the existing row for the current user profile data, this is not working below. //Writes the information to the database $result= mysql_query("INSERT INTO users (firstName,lastName,birthday,country,city, state, aboutMe) VALUES ('$firstName', '$lastName', '$birthday', '$country', '$city','$state','$aboutMe') WHERE username =$currentUser") or die(mysql_error()); there is some info for that user already in the database row, but the firstName, lastname, etc fields are empty.
×
×
  • 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.