john010117
-
Posts
492 -
Joined
-
Last visited
Never
Posts posted by john010117
-
-
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?
-
ok thanks, hope someone helps me out
...after you've posted some code. There are good tuts here on phpfreaks.com. Check 'em out.
-
You haven't even connected to the database....
-
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.
-
If you've got a MySQL database available, store it on there.
-
What exactly is "missing"? And for everyone's sake, put [ code ][ /code ] tags around your code (without the spaces).
-
Google is your friend. This forum is only for PHP-specific related questions.
-
I've never heard of EDIRECTORY_ROOT being used before... Just try ./ or ../ instead of that (inside of the quotes)
-
CMS should work. Google it. There are tons of scripts out there.
-
To start building a CMS, you'll need a MySQL database, as well as PHP.
-
Warning: main(EDIRECTORY_ROOT/layout/header.php) [function.main]: failed to open stream: No such file or directory inWarning: main() [function.include]: Failed opening 'EDIRECTORY_ROOT/layout/header.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') inFatal error: Call to undefined function: html_selectbox() in
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.
-
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')";
-
-
session_start(); session_destroy();
You must first start the session again before you destroy it.
-
Try PHP.
-
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.
-
Why do you need to save it in a php file? Sending the data to your e-mail is MUCH easier (I believe).
-
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.
-
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>"; } ?>
-
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.
-
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:
Warning: basename() expects parameter 1 to be string, array given in...
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?
-
Ok, stripslashes() worked! Thank you everyone for helping.
-
I think I have found the problem. When I put "$word" in the echo part, my common search term shows up like this:
Bungie Weekly What\\\'s Update
So it has to do with the comma's being replaced with "\". How would I fix that?
-
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.
[SOLVED] Registration/Adding members to database
in PHP Coding Help
Posted
You should put a { after the last line that you've posted. Did you do that?