Basically what I am doing is automating a process that involves a CAPTCHA code. So I wanted to make my php script to stop for input because it requires a CAPTCHA code 10% of the time.
I want to make the script stop and allow me like 10 secs to type or allow me to press a button to continue loading the scripts.
Basically what I want it some way to type in the captcha code that appears. If I have the script stop and then I start it over when it requires a captcha code the code would be different. By the time I typed in the right code the page would need reloaded and the code would be invalid.
I also thought about somehow having it sleep for 10 secs while it flushed the output and then I could type in the code quick but then how would I grab the textbox input while the page is still loading since nothing would be submitted I cant use GET or POST to access it. It could be accessed via javascript but theres no way to grab that again on the fly that I know of.
Basically what I want it some way to type in the captcha code that appears. If I have the script stop and then I start it over when it requires a captcha code the code would be different. By the time I typed in the right code the page would need reloaded and the code would be invalid.
You have a fundamental misunderstanding of how and when php executes. First, the client browser requests a page from the server. If the page that is requested has a .php extension, then the server sends the page to the php engine which executes all the php code and removes all the php code from the page. Then the server sends the page to the browser. Therefore, there is no php code on a page that is displayed in a browser, and so there is no way to pause any php code from executing.
I have made it now so that the script sleeps for 60 secs when a captcha code is needed and the output is flushed so I can type it in. Problem I have is that the captcha code is different every time the script is loaded. So once it figures out it needs a captcha code it sleeps and waits for my input.
Now the problem occurs when the script is automatically going to continue in 60 seconds so how do I reference the value in that text field that I just created 60 seconds ago.
What if I do some sort of frameset where the top frame updates the database with the capatcha code I send to it.
Basically it the script would sleep allowing me time to type the code and id submit the code via javascript to change the other frame location which then in turn update the database.
So once the script resumes from its sleep it would read that code from the database and use it to as the captcha code?
Seems like a lot of work to do a little task but I think it might work what do you think? Id rather just bypass the whole thing but I am not sure how to do that.
How about: the 10% of the time it is required, the php code displays a page with the captcha, and a form for the user to fill in, and a submit button, and then the user hits submit; and the other 90% of the time the php code does something else?
making a php script sleep while you wait for them to submit a form is a bad idea. although you could make it work by opening a new window, or using ajax, its just not the best way of acheiving your goal. although by using ajax, you probably dont even need a captcha anymore. although possible, i doubt any of the capcha cracking scripts try to evaluate javascript code. so by using javascript in the first place, your pretty much filtering out the robots anyway. and now, your website requires javascript to use.
how about this.
output the page as normal, but set a session variable to reflect the time the captcha was output. you would set this variable in the script which generates the image, not the script which outputs the html.
then when the user submits the form back to php, your code checks to see if the current time() is within X seconds of the last captcha being output. if its not, then deny them and send out a new captcha for them to try again.
however i question doing any of this at all.
your going to need to give them enough time for the people who have a slow internet connection, and allow for slow networks during peak times.
by doing this, your likely giving a script plenty of time to try and decode your captcha if it has a good fast connection to your server.
so you could decrease the time, but now your going to piss your users off because thier connection is too slow to use your website. is that what you really want? is it a good tradeoff? just make sure you weigh the pros and cons of doing this.
The captcha is not mine its on another website, I am automating a process that only involves me no one else will be using the script.
The problem I am having is that during automation I cannot continue it due to a captcha code needs entered. So unless I have a way for my script to pause and read what I entered or just bypass the captcha completly I cannot fully automate the process.
So my script runs and runs until it detects a captcha code then it shows me the image and a text field. So I now have 60 secs to type it in which is when the script will run agian. I need to somehow read from that text field once the script resumes again.