TutorMe Posted November 11, 2007 Share Posted November 11, 2007 I am trying to make my own captcha. I have the image creation part done, but I can't get the image into an php/html page. I have tried include('file'), but it throw image/png headers, and confuses the script (does that make sense?). Is there a way I can include the file that creates the image (image.php) as an image, along with the variables used to create it? ($string for example) Quote Link to comment Share on other sites More sharing options...
Daukan Posted November 11, 2007 Share Posted November 11, 2007 <img src="image.php" /> use an image tag Quote Link to comment Share on other sites More sharing options...
Daukan Posted November 11, 2007 Share Posted November 11, 2007 oh yeah the variables hmm You can put the variables in session var.. but you can't put them in a session from image.php if you use it an image tag. You need to put them into the session var then use the session vars in image.php. Quote Link to comment Share on other sites More sharing options...
TutorMe Posted November 11, 2007 Author Share Posted November 11, 2007 Thanks. That's weird though. Image tags were the first thing I tried, and they didn't work. I must have typed something wrong. I haven't really worked with sessions. I'll look up information on them, but do you think you could give an example of what i should use to set the variables, and to retrieve the variables? Quote Link to comment Share on other sites More sharing options...
Daukan Posted November 11, 2007 Share Posted November 11, 2007 <?php //on the page with the form //start session at top of script before any output even whitespace session_start(); $_SESSION['captcha_text'] = $captcha_text; $_SESSION['strlength'] = $strlength; ?> <form .... </form> <img scr="image.php" /> image.php code <?php session_start(); $strlength = $_SESSION['strlength']; $captcha_text= $_SESSION['captcha_text']; //snip ...... ?> Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted November 11, 2007 Share Posted November 11, 2007 you can set the session in the image creator that isn't a problem, just as long as you don't expect to validate on that page as a refresh/ajax of some sort will be needed to recovery said value. This is a common practice Parent page <?php session_start();?> <img src="image.php" /> image.php <?php $_SESSION['secret'] = rand_str(); // ... ?> that is legit to do, but that session's value will be a mystery until the user refreshes a page on your server and you can recover the session value. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.