473,386 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to exit to a web page upon successful 'Recaptcha' input

Hello - Thanks for any help you can provide. Below is code I am using for "recaptcha" form validation. It works well EXCEPT that (instead of echoing 'You got it!') as shown below when the accurate words are entered, I want to exit to another web page. What is the php code that would replace echo "You got it!"; and instead exit to another web page? Thanks very much. linda jimerson[php]<form action="" method="post" >
<?php
require_once('recaptchalib.php');
$publickey = "6Le-0AEAAAAAAGV3Ln-w867BhcXcme3hvBBpyQy7";
$privatekey = "6Le-0AEAAAAAAEYvsU9tKhDCaLC3wKhqaCDSvjQ_";
$resp = null;
$error = null;
if ($_POST["submit"]) {
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if ($resp->is_valid) {
echo "You got it! ";
} else {
$error = $resp->error;
}
}
echo recaptcha_get_html($publickey, $error);
?&g t;

<br/>
<input type="submit" name="submit" value="submit" />
</form>[/php]
May 9 '08 #1
10 2101
TheServant
1,168 Expert 1GB
[php]echo ("<meta http-equiv=\"refresh\" content=\"2;url=http://yourwebsite.com\">");[/PHP]

Notice the \'s there so that it doesn't see them as the closing of the echo. That statement will mean that the page will wait for 2 seconds (you can change this to 0) before it is redirected to yourwebsite.com.

Also, use code tags as I have!

AND what's your form action?
May 9 '08 #2
Markus
6,050 Expert 4TB
check out the header() functions.

[php]
header("Location: success_page.php");
[/php]
May 9 '08 #3
[php]echo ("<meta http-equiv=\"refresh\" content=\"2;url=http://yourwebsite.com\">");[/PHP]

Notice the \'s there so that it doesn't see them as the closing of the echo. That statement will mean that the page will wait for 2 seconds (you can change this to 0) before it is redirected to yourwebsite.com.

Also, use code tags as I have!

AND what's your form action?
THANK YOUR VERY MUCH. THIS WORKED. LINDA JIMERSON
May 10 '08 #4
hsriat
1,654 Expert 1GB
THANK YOUR VERY MUCH. THIS WORKED. LINDA JIMERSON
But still header("Location:target_page.php") is recommended.
May 11 '08 #5
TheServant
1,168 Expert 1GB
THANK YOUR VERY MUCH. THIS WORKED. LINDA JIMERSON
No Problem.

But still header("Location:target_page.php") is recommended.
I agree, but this has to come before any html. To do it this way, and I agree it is a better way, you need your script to return a variable so that when the header comes up you can test for that variable and then use the location function. But doing exactly what the OP asked for, replacing the echo contents, meta's are easier.
May 11 '08 #6
Markus
6,050 Expert 4TB
No Problem.



I agree, but this has to come before any html. To do it this way, and I agree it is a better way, you need your script to return a variable so that when the header comes up you can test for that variable and then use the location function. But doing exactly what the OP asked for, replacing the echo contents, meta's are easier.
Not all browsers support them.
May 12 '08 #7
TheServant
1,168 Expert 1GB
Not all browsers support them.
Ahh touché! Listen to the pro's, I am but a humble hobbiest! However, I have not had a problem with meta yet.
May 13 '08 #8
dlite922
1,584 Expert 1GB
Ahh touché! Listen to the pro's, I am but a humble hobbiest! However, I have not had a problem with meta yet.
Believe us.

Correct me if I'm wrong, as I don't know, only you would. When you use meta instead of header, what happens when you click the back button? In IE, do you just end up back on the current page?

Expand|Select|Wrap|Line Numbers
  1. If($your_response)
  2. {
  3.     echo "That's a slight annoyance to users, but a  good way to keep them on the same page"; 
  4. }
  5. else
  6. {
  7.    echo "...hmmm...didn't know that.You learn something new everyday"; 
  8. }
May 13 '08 #9
hsriat
1,654 Expert 1GB
[php]die('Never used refresh meta, and never thought it this way.');[/php]
May 13 '08 #10
TheServant
1,168 Expert 1GB
[php]die('Never used refresh meta, and never thought it this way.');[/php]
I still don't know how you guys get by the fact that you can only use header() before any html has been sent. There can be no delay (that I know of) which is sometimes required. I use header() 99% of the time, but meta in those areas which I need either a delay and/or show some html first. Solutions?
May 13 '08 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Newbie | last post by:
OK, this may be impossible since I'm using 3rd party shopping cart ASP software, but I've been able to finagle a lot of other stuff I thought wouldn't work, so here we go: I'm using a form in...
2
by: Cady | last post by:
I'm trying to do an automatic signup for a newsletter hosted on a separate site. The original page is to sign up to receive a catalog by mail, with an option to signup for an e-newsletter. All...
6
by: Vicky | last post by:
Please tell me at vdkhakhkhar@gmail.com
1
by: Culley | last post by:
I've created a secure login site. Everything works fine except for one thing... the redirect. I want to redirect users to the correct page they are accessing (say they're just clicking a link...
2
by: noumanislam | last post by:
Hello! this is Nouman. I am working on a form which takes input in text boxes compare those inputted values to a database table... this goes very well.. the problem comes when i want to show the...
0
by: Bogdan | last post by:
LoginStatus can be configured with LogoutPageUrl but there is no way to configure it with 'LoginPageUrl', i.e. a page that will be displayed upon a successful login. I'd like users to be...
1
by: dineshkaku | last post by:
Does anyone know any codes for live validation of the recaptcha? My registration process is full of live validations and the register buttin does not get activated unless all fields are error free....
1
by: Subcomandante | last post by:
Hi, Did anyone try and succeeded to defeat reCAPTCHA script?
5
by: lemlimlee | last post by:
hello, this is the task i need to do: For this task, you are to develop a Java program that allows a user to search or sort an array of numbers using an algorithm that the user chooses. The...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.