Jump to content

MDCode

Members
  • Posts

    640
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by MDCode

  1. Eh, was worth a try I suppose *shutting up*
  2. I'm not really following your descriptions well, but here's a guess $sql = "INSERT INTO `table` (column_name) VALUES ('Value')"; This will insert into only one column, the rest will be filled with null
  3. if(isset($_POST['accessory'])) { $_POST['accessory'] = "Accessory"; } else { // Not sure what you're trying to accomplish here $_POST['N/A']; }
  4. But you're asking for completed code...I'm sure help can be found if you post what you've tried so far
  5. There's a freelancer section for this. At least make an attempt first if you post here
  6. My bad, you also want to use either htmlspecialchars() or htmlentities() on that too since you're emailing them their information
  7. Make sure you filter that, the way you seem to be inputting is vulnerable to sql injection
  8. when you get a redeclare error it is most likely you are calling a file(s) with the same function twice. You can not require functions twice
  9. There's really no way to know if you don't post anything...
  10. Taking a closer look at your code: You do not need a while loop as long as there are no users with the same user_id. Which is also a bad idea. This can be changed to: <?php $rs_settings = mysql_query("select * from users where id='$_SESSION[user_id]'"); ?> <?php $row_settings = mysql_fetch_array($rs_settings); ?> <font size="2"> Points: <b> <?php $points= $row_settings['points']; echo $points; $checker = 0; } ?> Also will cause an error because you're redirecting after you ouput html
  11. Wait, so you reload after you purchase, then you're resending your form. It's natural, your ignoring of the alert message is normal because all the form data you had just sent was resent when you reloaded. I'm not much of a javascript expert so I'll leave it to someone else.
  12. You can use <?php if(isset($_POST['Submit'])) { // execute } else { // error ?> where "Submit" would be the name you assigned to your submit button, to check whether the submit button has been clicked. However some browsers have difficulties with it sometimes
  13. Errors and other issues resulting in a solution may occur by other sections of code based on past experiences. And that's not all of it; just the uploading part. As for names I just want them different from the original at this point. There shouldn't been an issue with duplicate names in the nature it's being used. But ty for your response lol I feel dumb now
  14. I have an image upload page and I want to rename the file using md5. I've run into some problems and I'm not sure how to solve it. I'm successfully renaming the file but I am not able to add the extension (i.e. .jpg) no matter what I do if(!$_SESSION['username']) { echo "You must be logged in."; } else { // upload the file if ((isset($_POST["submitted_form"])) && ($_POST["submitted_form"] == "image_upload_form")) { include('connection.php'); if (($_FILES["image_upload_box"]["type"] == "image/jpeg" || $_FILES["image_upload_box"]["type"] == "image/pjpeg" || $_FILES["image_upload_box"]["type"] == "image/gif" || $_FILES["image_upload_box"]["type"] == "image/x-png") && ($_FILES["image_upload_box"]["size"] < 4000000)) { $max_upload_width = "500"; $max_upload_height = "250"; // if uploaded image was JPG/JPEG if($_FILES["image_upload_box"]["type"] == "image/jpeg" || $_FILES["image_upload_box"]["type"] == "image/pjpeg"){ $image_source = imagecreatefromjpeg($_FILES["image_upload_box"]["tmp_name"]); } // if uploaded image was GIF if($_FILES["image_upload_box"]["type"] == "image/gif"){ $image_source = imagecreatefromgif($_FILES["image_upload_box"]["tmp_name"]); } // BMP doesn't seem to be supported so remove it form above image type test (reject bmps) // if uploaded image was BMP if($_FILES["image_upload_box"]["type"] == "image/bmp"){ $image_source = imagecreatefromwbmp($_FILES["image_upload_box"]["tmp_name"]); } // if uploaded image was PNG if($_FILES["image_upload_box"]["type"] == "image/x-png"){ $image_source = imagecreatefrompng($_FILES["image_upload_box"]["tmp_name"]); } if(file_exists("Upload/image_files/".$_FILES["image_upload_box"]["name"])) { header("Location: upload.php?upload_message=The+requested+file+already+exists,+Please+rename+the+file+and+try+again.&upload_message_type=error"); exit; } else { // RENAME FILE $new_file = md5($_FILES["image_upload_box"]["name"]); $remote_file = "Upload/image_files/".$new_file; imagejpeg($image_source,$remote_file,100); chmod($remote_file,0644); // get width and height of original image list($image_width, $image_height) = getimagesize($remote_file); if($image_width>$max_upload_width || $image_height >$max_upload_height){ $proportions = $image_width/$image_height; if($image_width>$image_height){ $new_width = $max_upload_width; $new_height = round($max_upload_width/$proportions); } else{ $new_height = $max_upload_height; $new_width = round($max_upload_height*$proportions); } $new_image = imagecreatetruecolor($new_width , $new_height); $image_source = imagecreatefromjpeg($remote_file); imagecopyresampled($new_image, $image_source, 0, 0, 0, 0, $new_width, $new_height, $image_width, $image_height); imagejpeg($new_image,$remote_file,100); imagedestroy($new_image); } $image_link = $_FILES["image_upload_box"]["name"]; $path = "--deleted website name--/Upload/image_files/$image_link"; $sql = "UPDATE `User_Profiles` SET `avatar` = '$path' WHERE `username` = '$username'"; $result = mysql_query($sql,$connection) or die("Error connecting to the database."); imagedestroy($image_source); header("Location: upload.php?upload_message=image uploaded&upload_message_type=success&show_image=".$_FILES["image_upload_box"]["name"]); exit; } } else{ header("Location: upload.php?upload_message=Error:+Please+make+sure+the+file+is+jpg,+gif+or+png+and+that+it+is+smaller+than+4MB&upload_message_type=error"); exit; } } ?> Sorry pasting removed all organization...any tips would be greatly appreciated!
  15. $num=mysql_numrows($result); needs to be: $num=mysql_num_rows($result);
  16. This forum is not for giving you answers, it is to help you to find your errors on your own so you may learn to debug your own code in the future. If you want straight forward answers, there is a freelancer section.
  17. In your code, increment is not defined. It's not even used as a variable.
  18. First, you should have that in single quotes after set ratings, and increment is not doing anything which is most likely the source of your error
  19. If there is an error associated with line 23, you are not showing all the code. Please show the full error as well
  20. I'm not sure on that one as I've never attempted it. You could try a simple space between: --> ' ' <-- as shown. If not idk
  21. str_replace will replace all words associated within $badwords with nothing. If you wish to replace them with certain text, use the second parameter of str_replace and add whatever you want displayed. If you wish to filter words simply edit/add to what barand has shown
  22. This thread is not for writing the code for you. If you wish for that to be done, there is a freelance section. Please make an attempt at it first and I will try to help with any errors you find.
  23. You will need to learn pagination if you are going to display on one file but to get started just add LIMIT 30 to the query.
  24. You may also have an error on line one of index.php, posting the code may help for finding the solution
×
×
  • 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.