Jump to content


  • Posts

  • Joined

  • Last visited


Everything posted by john010117

  1. You should put a { after the last line that you've posted. Did you do that?
  2. Since I have very little experience in working with GD library, I need advice on how to improve this simple CAPTCHA code (don't worry, I have other security precautions in place, since CAPTHA aren't that secure). I've only included the page that actually displays the image. <?php session_start(); $RandomStr = md5(microtime());// md5 to generate the random string $ResultStr = substr($RandomStr,0,5);//trim 5 digit // Select a random background image $dir=opendir("./images/captcha/"); $i=0; while($imgfile=readdir($dir)) { if ($imgfile != "." && $imgfile!="..") { $imgarray[$i]=$imgfile; $i++; } } closedir($dir); $rand=rand(0,count($imgarray)-1); if($rand >= 0) { $RandomImage = $imgarray[$rand]; } $NewImage =imagecreatefrompng("./images/captcha/$RandomImage");//image create by existing image and as background $randcolR = rand(100,230); $randcolG = rand(100,230); $randcolB = rand(100,230); $LineColor = imagecolorallocate($NewImage,233,239,239);//line color $TextColor = imagecolorallocate($NewImage, ($randcolR - 20), ($randcolG - 20), ($randcolB - 20)); imageline($NewImage,1,1,40,40,$LineColor);//create line 1 on image imageline($NewImage,1,100,60,0,$LineColor);//create line 2 on image imagestring($NewImage, 5, 20, 10, $ResultStr, $TextColor);// Draw a random string horizontally $_SESSION['key'] = $ResultStr;// carry the data through session header("Content-type: image/png");// out out the image imagepng($NewImage);//Output image to browser imageDestroy($NewImage); ?> Before you suggest any suggestions, please not that I only have GD library available on my server (that means no FreeType). Ok, now, any suggestions please?
  3. ...after you've posted some code. There are good tuts here on phpfreaks.com. Check 'em out.
  4. You haven't even connected to the database....
  5. Put the form on one page (ex: form.html). Then put all of the processing stuff in another (ex: process.php). Your form.html will have something like this: <form action="process.php" method="POST"> ...form code goes here </form> And your process.php will have the PHP code in there.
  6. If you've got a MySQL database available, store it on there.
  7. What exactly is "missing"? And for everyone's sake, put [ code ][ /code ] tags around your code (without the spaces).
  8. Google is your friend. This forum is only for PHP-specific related questions.
  9. I've never heard of EDIRECTORY_ROOT being used before... Just try ./ or ../ instead of that (inside of the quotes)
  10. CMS should work. Google it. There are tons of scripts out there.
  11. To start building a CMS, you'll need a MySQL database, as well as PHP.
  12. Make sure you've moved ALL of the files from your old site to new (to the correct directories). That's what the error messages are about.
  13. How are you getting the $question variable? If it's the same as others (by sessions), do this: $question = $_SESSION[question]; $question = addslashes($question); ...and for your query: $sql = "INSERT INTO $table (user_id, video_id, question) VALUES ('$_SESSION[id]', '$_SESSION[video_id]', '$question')";
  14. Looking it up helps. mysql_fetch_array mysql_fetch_assoc
  15. session_start(); session_destroy(); You must first start the session again before you destroy it.
  16. You put the "?>" after "if(!isset($_SESSION['username'])){". Not sure why you did that. That's why the rest of the code is not processing. Put echo instead.
  17. Why do you need to save it in a php file? Sending the data to your e-mail is MUCH easier (I believe).
  18. I have no idea why I put that in the code. Heh, maybe I should slow down on coding stuff. Ok, thank you. It worked.
  19. Sure thing. <?php $upload_dir = "images/"; $upload_file = $upload_dir . pathinfo($_FILES['comicfile']['tmp_name']); $filename = $_FILES['comicfile']['name']; $ok=1; //This is our size condition foreach ($_FILES['comicfile']['size'] as $filesize){ $comicfile_size = $filesize; if ($comicfile_size > 100000000) { echo "<font color=\"#FF0000\">Failed</font>: Your file is too large."; $ok=0; } } //This is our limit file type condition foreach ($_FILES['comicfile']['type'] as $filetype){ $comicfile_type = $filetype; if ($comicfile_type =="text/php") { echo "<font color=\"#FF0000\">Failed</font>: No PHP files."; $ok=0; } } //Here we check that $ok was not set to 0 by an error if ($ok==0) { Echo " Sorry your file was not uploaded"; } //If everything is ok we try to upload it else { foreach ($_FILES['comicfile']['error'] as $key => $error){ if ($error == UPLOAD_ERR_OK) { $tmp_name = $_FILES['comicfile']['tmp_name'][$key]; $name = $_FILES['comicfile']['name'][$key]; move_uploaded_file($tmp_name, "images/$name"); } } echo "<br />"; echo "<a href=\"index.php\">Comic Index</a><br />"; echo "<a href=\"http://rvb.allaroundhalo.org/index.php\">RvB Index</a><br />"; echo "<a href=\"http://www.allaroundhalo.org/index.php\">AAH Index</a>"; } ?>
  20. Whoops! I forgot to change pathinfo() to basename() in the code that I posted above. That's the part of the code that I'm having trouble with.
  21. I've retrieved a multiple file upload code sample from php.net and extended/modified it to suit my needs (that uses arrays). For some reason, it uploads and moves the file from the temp directory to the folder I specified, but I get this error: And here's the part of the code that I'm having trouble with. <?php $upload_dir = "images/"; $upload_file = $upload_dir . basename($_FILES['comicfile']['tmp_name']); $filename = $_FILES['comicfile']['name']; ?> (I just put the PHP tags in to help others be able to read the code clearly) I've also tried pathinfo(), but to no avail. Can anybody help please?
  22. Ok, stripslashes() worked! Thank you everyone for helping.
  23. I think I have found the problem. When I put "$word" in the echo part, my common search term shows up like this: So it has to do with the comma's being replaced with "\". How would I fix that?
  24. If you have a script that works on other places, leave it (just check the user/pass/db/host to see that they're 100% correct.
  • 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.