PHP - Adding Google Recaptcha 3 To Working Php Form
I am a php newbie and with help from someone on this forum managed to get my php form working. I am now trying to add recaptcha 3 but can't get it to work. I have added my code to this post and would appreciate some pointers. <?php /* This is the Header PHP file */ ?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="description" content=""> <meta name="author" content="My Name"> <title>My Title</title> <!--Bootstrap Core CSS--> <link href="assets/css/bootstrap.min.css" rel="stylesheet"> <!--Font Awresome Icons--> <link href="https://fonts.googleapis.com/css?family=Open+Sans:400,600&display=swap" rel="stylesheet"> <!--Google Fonts--> <link href="assets/css/fontawesome/css/all.min.css" rel="stylesheet"> <!--Adobe Typekit Fonts--> <link href="https://use.typekit.net/jtf1geg.css" rel="stylesheet"> <!--Custom CSS--> <link href="assets/css/custom.css" rel="stylesheet"> <!--Favicon--> <link rel="icon" type="image/png" sizes="32x32" href="assets/img/MyFavicon32WhiteAlt.png"> <!--Google reCaptcha--> <script src="https://www.google.com/recaptcha/api.js"></script> <script> function onSubmit(token) { document.getElementById("contact-form").submit(); } </script> </head> <body> <!--HEADER--> <header class="site-header"> <!--Navbar--> <nav class="navbar"> <!-- Navbar brand --> <div class="navbar-brand"> <img src="assets/img/myLogo.png" id="wd-logo" alt="My Logo"> </div> <!-- Linking Menu Text to Collapse Button --> <div class="menu-button"> <button class="navbar-toggler button" type="button" data-toggle="collapse" data-target="#navbarSupportedContent20" aria-controls="navbarSupportedContent20" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-text">Menu</span> </button> <!-- Collapse Button --> <button class="navbar-toggler button animated-icon" type="button" data-toggle="collapse" data-target="#navbarSupportedContent20" aria-controls="navbarSupportedContent20" aria-expanded="false" aria-label="Toggle navigation"> <span></span> <span></span> <span></span> </button> <!-- Collapse Button End --> </div> <!-- Linking Menu Text to Collapse Button End --> <!-- Collapsible content --> <div class="collapse navbar-collapse" id="navbarSupportedContent20"> <!-- Links --> <ul class="navbar-nav"> <li class="nav-item"> <a class="nav-link" href="index.php">Home</a> </li> <li class="nav-item"> <a class="nav-link" href="contact.php">About</a> </li> <li class="nav-item"> <a class="nav-link" href="contact.php">Services</a> </li> <li class="nav-item"> <a class="nav-link" href="contact.php">Our Work</a> </li> <li class="nav-item active"> <a class="nav-link" href="contact.php">Contact<span class="sr-only">(current)</span></a> </li> </ul> <!-- Links End --> </div> <!-- Collapsible Content End --> </nav> <!--Navbar End--> </header> <!--Header End--> <hr> <!--Content--> <section class="main"> <?php // This is the contact form // Message Vars $msg = ''; $msgClass = ''; // Check to see if the form has been submitted if(filter_has_var(INPUT_POST, 'submit')) { // Input Data Variables $firstname = htmlspecialchars($_POST['firstname']); $lastname = htmlspecialchars($_POST['lastname']); $phonenumber = htmlspecialchars($_POST['phonenumber']); $email = htmlspecialchars($_POST['email']); $dropdown = htmlspecialchars($_POST['selectdropdown']); $message = htmlspecialchars($_POST['message']); $checkbox = htmlspecialchars($_POST['checkbox'] ?? 0); // Check required fields if(!empty($firstname) && !empty($lastname) && !empty($phonenumber) && !empty($email) && !empty($dropdown) && !empty($message) && !empty($checkbox)) { // If passed, check email address if(filter_var($email, FILTER_VALIDATE_EMAIL) === false) { // If failed, Email address is not valid $msg = 'Please use a valid email address'; $msgClass = 'alert-danger'; } else { // Recipient email address and information to be sent to them $toEmail = 'hello@example.co.uk'; $subject = 'Contact Request from Website'; $body = '<h2>Contact Request</h2> <h4>Name</h4><p>'.$firstname. ' '.$lastname.'</p> <h4>Phone Number</h4><p>'.$phonenumber.'</p> <h4>Email Address</h4><p>'.$email.'</p> <h4>Subject</h4><p>'.$dropdown.'</p> <h4>Message</h4><p>'.$message.'</p>'; // Email Headers $headers = "MIME-VERSION: 1.0" ."\r\n"; $headers .="Content-Type:text/html;charset=UTF-8" ."\r\n"; // Additional Headers $headers .= "From: " .$firstname. "".$lastname." <".$email.">" ."\r\n"; $recaptcha_url = "https://www.google.com/recaptcha/api/siteverify"; $recaptcha_secret ="secrettoken"; $recaptcha_response = $_POST['g-recaptcha-response']; $recaptcha = file_get_contents($recaptcha_url . '?secret=' . $recaptcha_secret . '&response=' . $recaptcha_response); $recaptcha = json_decode($recaptcha, true); if($recaptcha['success'] == 1 AND $recaptcha['score'] >= 0.5 AND $recaptcha['action'] == "submit") { if(mail($toEmail, $subject, $body, $headers)) { // Message Sent $msg = 'Verfication successful, your message has been sent'; $msgClass = 'alert-success'; } else { // Message failed $msg = 'Your message has NOT been sent'; $msgClass = 'alert-danger'; } } } } else { // Failed $msg = 'Please fill in all fields'; $msgClass = 'alert-danger'; } } ?> <div class="container clearfix content-container"> <h1 class="section-title">Contact Us</h1> <p>If you have any questions about the services we provide or would like to chat about a new website project, please get in touch using any of the options below. We would love to hear from you!</p> <!--Contact Page Row--> <div class="row"> <div class="col-lg-6 contact-details"> <div class="row"> <div class="col-lg-12"> <img src="assets/img/contact-us.jpg" class="img-responsive d-block contact-image" alt="Contact Us Image"> </div> </div> <div class="row"> <div class="col-lg-12 contact-name"> <span class="d-inline-block contact-inline-block"><i class="fas fa-user fa-2x"> </i></span> <span class="d-inline-block"><p class="contact-details">me</p></span> </div> </div> <div class="row"> <div class="col-lg-12 contact-phone"> <span class="d-inline-block contact-inline-block"><a href="tel:01234 567890"><i class="fas fa-mobile-alt fa-2x"></i></a></span> <span class="d-inline-block"><a href="tel:01234 567890"><p class="contact-details">01234 567890</a></p></span> </div> </div> <div class="row"> <div class="col-lg-12 contact-email"> <span class="d-inline-block contact-inline-block"><a href="mailhandler.php"><i class="fas fa-envelope-square fa-2x"></i></a></span> <span class="d-inline-block"><a href="mailhandler.php"><p class="contact-details">hello@wexample.co.uk</a></p></span> </div> </div> <div class="row"> <div class="col-lg-12 contact-fb"> <span class="d-inline-block contact-inline-block"><a href="https://www.facebook.com/example/" target="_blank"><i class="fab fa-facebook-square fa-2x"></a></i></span> <span class="d-inline-block"><a href="https://www.facebook.com/example/" target="_blank"><p class="contact-details">@example</a></p></span> </div> </div> </div> <!--Contact Form--> <div class="col-lg-6 contact-form d-block"> <?php if($msg != ''): ?> <div class="alert <?php echo $msgClass; ?>"><?php echo $msg; ?></div> <?php endif;?> <form method="post" action="contact.php" role="form" id="contact-form"> <div class=" row form-group"> <div class="col-lg-6"> <label for="firstnameid">First name<span class="asterisk"> *</span></label> <input type="text" name="firstname" class="form-control mb-3" id="firstnameid"> </div> <div class="col-lg-6"> <label for="lastnameid">Last name<span class="asterisk"> *</span></label> <input type="text" name="lastname" class="form-control mb-3" id="lastnameid"> </div> </div> <div class="row form-group"> <div class="col-lg-6"> <label for="phonenumber">Phone number<span class="asterisk"> *</span></label> <input type="tel" name="phonenumber" class="form-control mb-3" id="phonenumberid"> </div> <div class="col-lg-6"> <label for="emailid">Email address<span class="asterisk"> *</span></label> <input type="email" name="email" class="form-control mb-3" id="emailid"> </div> </div> <div class="row form-group"> <div class="col-lg-12"> <label for="subjectid">How can we help<span class="asterisk"> *</span></label> <select class="form-control mb-3" name="selectdropdown" id="subjectid"> <option value="">Please choose an option</option> <option value="I would like to discuss a project">I would like to discuss a project</option> <option value="Existing Web 2 Digital client enquiry">Existing client enquiry</option> <option value="General enquiry">General enquiry</option> </select> </div> </div> <div class="row form-group"> <div class="col-lg-12"> <label for="messageid">Tell us a little bit more<span class="asterisk"> *</span></label> <textarea name="message" class="form-control mb-3" id="messageid" rows="6"></textarea> </div> </div> <div class="row form-group"> <div class="col-lg-12"> <p><span class="asterisk"> *</span> indicates required field</p> </div> </div> <div class="row form-group"> <div class="col-lg-12 form-check"> <input type="checkbox" name="checkbox" class="form-check-input" id="formcheckid"> <label for="formcheckid" class=form-check-label mb-3>By checking this tickbox you have confirmed that we can collect the information in this form for the purposes outlined in our <a href="privacypolicy.php">privacy policy.</a></label> </div> </div> <div class="row form-group"> <div class="col-lg-12"> <button type="submit" name="submit" class="btn btn-primary mt-4 g-recaptcha" data-sitekey="sitetoken" data-callback='onSubmit' data-action='submit'>Send Message </button> </div> </div> </form> </div> <!--Contact Form End--> </div> <!--Contact Page Row End--> </div> <!--Container end--> <?php echo file_get_contents('footer.php'); ?>
Similar TutorialsHello How can i add google recaptcha to this code https://github.com/Tutorialwork/Tutorials/blob/master/PHP Rechtesystem/addnews.php
I am still fairly new to using phpmailer and it works but I have been asked to google recaptcha v2 checkbox into their contact form but unsure how to do that within the phpmailer code, below is what I currently have <?php // PHPMailer classes into the global namespace use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; // Base files require 'PHPMailer/src/Exception.php'; require 'PHPMailer/src/PHPMailer.php'; require 'PHPMailer/src/SMTP.php'; // create object of PHPMailer class with boolean parameter which sets/unsets exception. $mail = new PHPMailer(true); try { //$mail->isSMTP(); // using SMTP protocol $mail->Host = 'hostname'; // SMTP host as gmail $mail->SMTPAuth = true; // enable smtp authentication $mail->Username = 'emailaddress'; // sender gmail host $mail->Password = 'emailpassword'; // sender gmail host password $mail->SMTPSecure = 'ssl'; // for encrypted connection $mail->Port = 587; // port for SMTP $mail->setFrom('emailaddress', "Business Name"); // sender's email and name $mail->addAddress('emailaddress', "Business Name"); // receiver's email and name $mail->Subject = 'New Website Enquiry'; $mail->Body = "A new website enquiry has been made. The enquiry information is below" . "\r\n\r\n" . "Name: " . $_POST["name"] . "\r\n" . "Email: " . $_POST["email"] . "\r\n" . "Subject: " . $_POST["subjectline"] . "\r\n" . "Message: " . $_POST["message"]; $mail->send(); header('Location:enquiry-confirmation.php'); } catch (Exception $e) { // handle error. echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo; } ?>
I have been running Google ReCaptcha v2 on 4 different sites for a very long time without any problem. They were all working fine. Not sure when as I was just recently made aware it, but none of them work anymore ??? Did google change something or is it because I updated php?? The problem is in the response - no matter what I try, I cannot verify that I am human. This is the response code:
[\code] For some reason I am no longer getting a successful response. Any help would be greatly appreciated Thanx
I'm implementing google's reCAPTCHA V2. It works almost perfectly except for the following error located in the recaptchalib.php:
Notice: Use of undefined constant success - assumed 'success' in (script location)
https://github.com/g...ecaptchalib.php
Anyone got an idea how to fix this?
Edited by tork, 28 November 2014 - 04:24 PM. Why am I getting that error on Google reCAPTCHA V2 response? Hello, it's my first time posting here and I'm not good with such stuff as the one I'm posting right now I have been trying to solve this issue for 2 days by now so I could use some help lol This error "Please solve the captcha." is showing even if the captcha is verified so it's showing in the both cases (verified/unverified). Thanks in advance.
<?php require_once 'db/setting.php'; require_once 'db/odbc.php'; session_start(); error_reporting(0); if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') { $protocol = 'https://'; } else { $protocol = 'http://'; } $currentDomain = $protocol.$_SERVER[HTTP_HOST]; $API["secret_key"] = "xx"; $API["api_key"] = "xx"; $API["callback"] = $currentDomain."/vote-reward-tok.php?return={RETURNEDCODE}"; $API["API_Domain"] = "http://api.top-kal.com"; $secretKey = 'xxx'; $captcha = $_POST['g-recaptcha-response']; $ip = $_SERVER['REMOTE_ADDR']; $responseData=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secretKey."&responseData=".$captcha."&remoteip=".$ip); $responseKeys = json_decode($responseData,true); $config["db_username"] = "sa"; $config["db_password"] = "********"; $config["db_database_account"] = "kal_auth"; $config["db_database_player"] = "kal_db"; $config["db_server"] = "NAME\SQLEXPRESS"; $config["db_driver"] = "SQL Server"; $config["Reward_Name"] = "Vote Coin"; $config["MinLvl_Require"] = 30; $config["Reward_Index"] = 447; $config["Reward_Amount"] = 10; $config["Reward_Bound"] = false;
function insertRewards($account_unique_id){ global $config; $connect = odbc_connect('Driver={'.$config["db_driver"].'};Server='.$config["db_server"].';Database='.$config["db_database_player"].';', $config['db_username'] ,$config['db_password']); if(!$connect) return false; $query = odbc_exec($connect,"SELECT Top 1 [IID] FROM [Item] Where [IID] < 1 order by IID Desc"); if(!$query) return false; $data = odbc_fetch_array($query); if($data && !empty($data) && isset($data["IID"])) odbc_exec($connect,"INSERT INTO [Item] ([PID],[IID],[Index],[Prefix],[Info],[Num])VALUES ($account_unique_id,".($data["IID"]+1).",".$config["Reward_Index"].",0,".(16+($config["Reward_Bound"] ? 128 : 0)).",".$config["Reward_Amount"].")"); } function checkCharacters($accountUID){ global $config; $connect = odbc_connect('Driver={'.$config["db_driver"].'};Server='.$config["db_server"].';Database='.$config["db_database_player"].';', $config['db_username'] ,$config['db_password']); if(!$connect) return array("error" => "failed to connect to database players."); $query = odbc_exec($connect,"SELECT [Level] FROM [Player] WHERE [UID] = $accountUID ORDER BY [Level] DESC"); if(!$query) return array("error" => "failed to find characters in this account id."); while($r = odbc_fetch_array($query)){ if($r["Level"] >= $config["MinLvl_Require"]) return array("success" => $accountUID); } return array("error" => "You should have one character at least higher than level : ".$config["MinLvl_Require"]." to vote."); } function checkAccount($accountID){ global $config; $connect = odbc_connect('Driver={'.$config["db_driver"].'};Server='.$config["db_server"].';Database='.$config["db_database_account"].';', $config['db_username'] ,$config['db_password']); if(!$connect) return array("error" => "failed to connect to database accounts."); $query = odbc_exec($connect,"SELECT TOP 1 [UID] FROM [Login] WHERE [ID] = '$accountID'"); if(!$query) return array("error" => "this account id not exists."); $data = odbc_fetch_array($query); if(!$data || empty($data) || !isset($data["UID"])) return array("error" => "this account id not exists."); if($config["MinLvl_Require"] > 0) return checkCharacters($data["UID"]); return array("success" => $data["UID"]); } >> Submitting Function $response = array("error" => false , "success" => false , 'redirect' => false); function post_content($query){ $query_array = array();foreach( $query as $key => $key_value )$query_array[] = urlencode( $key ) . '=' . urlencode( $key_value );return implode( '&', $query_array ); } global $API; $opts = array('http' => array('method' => 'POST',"header" => "Content-type: application/x-www-form-urlencoded\r\nAuthorization:".base64_encode($API["api_key"].":".$API["secret_key"])."\r\n", "content" => post_content($content)));return stream_context_create($opts); } function submit(){ global $API; if(empty($captcha) || $captcha == '' || !isset($captcha)) return array( "error" => "Please solve the captcha."); if (empty($_POST['account']) || !ctype_alnum($_POST['account'])) return array( "error" => "Invalid account id."); $checkAccount = checkAccount($_POST['account']); if (isset($checkAccount["error"])) return array("error" => $checkAccount["error"]); if (isset($checkAccount["success"])){ $account_unique_id = (isset($_SESSION['kal_id'])) ? $_SESSION['kal_id'] : $checkAccount["success"]; $result = json_decode(file_get_contents($API["API_Domain"] . '/api/generate/vote-rewards-token', false, postParams(array('callback' => $API["callback"],'account_unique_id' => $account_unique_id ))) , true); { echo '<br><center><h3>Please wait...</h3></center>'; } if (!empty($result)){ if (isset($result["response"])){ if (isset($result["response"]["error"])) return array("error" => $result["response"]["error"]); elseif (isset($result["response"]["success"])) return array("redirect" => '<script type="text/javascript">setTimeout(function () { window.location.href = "'.$result["response"]["success"].'";}, 500)</script>'); } } } } if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['account'])){ $response = submit(); if (isset($response['redirect']) && $response['redirect']){ echo $response['redirect']; die; } }elseif (isset($_GET['return'])){ $result = json_decode(file_get_contents($API["API_Domain"] . '/api/verify/vote-rewards-token', false, postParams(array('returned_code' => $_GET['return']))) , true); if (!empty($result)){ if (isset($result["response"])){ if (isset($result["response"]["error"])) $response['error'] = $result["response"]["error"]; elseif (isset($result["response"]["success"])){ insertRewards($result["response"]["account_unique_id"]); $response['success'] = '<b>Thank you, Your vote has been recorded and the server rank will be updated soon.<b><br />You will receive your rewards in storage of your account.<p>Your next vote in : <b>' . $result["response"]["NextVote"] . '</b></p>'; } } } } ?>
<head> <title>Vote Rewards - <?php echo $config['serverName']; ?></title> <link rel="shortcut icon" href=images/favicon.png"> <link rel="stylesheet" href="css/vote.css"> <link rel="stylesheet" href="css/fontawesome.css"> <link rel="stylesheet" href="css/fontawesomeall.css"> <script src='https://www.google.com/recaptcha/api.js'></script> </head> <body> <form class="vote-form" method="post"> <noscript><div class="isa_error">Javascript is not enabled in your browser! Please enable it or change your browser.</div></noscript> <?php if(isset($response['error']) && $response['error']){ ?><div class="isa_error"> <?php echo $response['error'] ;?> </div> <?php } ?> <?php if(isset($response['success']) && $response['success']){ ?><div class="isa_success"> <?php echo $response['success'] ;?> </div> <?php }else{ ?> <label> <span>Account ID :</span> <input type="text" name="account" maxlength="20" <?php echo (isset($_SESSION['kal_username'])) ? 'readonly value="'.$_SESSION['kal_username'].'"' : ""; ?>" /> </label> <div class="g-recaptcha" style="margin:0 auto;" data-sitekey="xxx" data-theme="dark"></div> <label class="label_btn"> <input type="submit" class="button" value="Vote" /> </label> <?php } ?> </form> <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script> </body> </html> Edited October 13, 2019 by requinix we don't do markdown. please use the Code <> button for code I have been getting a lot of bots spamming this script, and need to add captcha to it. I am new to php and was wondering if someone would help me with this issue. Below is the script, and I really would appreciate the help. Code: [Select] <?php include "admin/conf.php"; $setting1="SELECT * FROM ".$prefix."settings"; $setting2=mysql_query($setting1) or die("Sorry, Could not select sites table"); $setting=mysql_fetch_array($setting2); include "lang/$setting[lang]/main.php"; print "<title>$lang_reg1</title>"; print "<link rel='stylesheet' href='skin/$setting[style]/style.css' type='text/css'>"; print "<body bgcolor='#FFFFFF'>"; print "<table cellpadding='0' cellspacing='0' align='center' class='outtable'><tr><td>"; /*----------------- Bread ------------------*/ print "<br /><table><tr><td width='100%'><a href='index.php'>$setting[title]</a> > $lang_reg4</td></tr></table><br />"; /*----------------- Bread End ------------------*/ print "<table cellpadding='0' cellspacing='0' align='center' width='100%'><tr><td valign='middle'><img src='skin/$setting[style]/images/pen.gif' style='vertical-align: middle;'></td> <td valign='middle'>$lang_reg1</td></tr></table>"; print "<table cellspacing='0' cellpadding='0' width='100%' align='center'><tr> <td><img src='skin/$setting[style]/images/cat_left_shadow.gif' style='vertical-align: middle;'></td> <td><img src='skin/$setting[style]/images/cat_left.gif' style='vertical-align: middle;'></td> <td class='tilecat' width='100%'><img src='skin/$setting[style]/images/tile_back.gif' style='vertical-align: middle;'></td> <td><img src='skin/$setting[style]/images/cat_right.gif' style='vertical-align: middle;'></td><td><img src='skin/$setting[style]/images/cat_right_shadow.gif' style='vertical-align: middle;'></td> </tr></table>"; print "<table cellspacing='0' cellpadding='0' width='100%' align='center'><tr> <td class='shadowL'><img src='skin/$setting[style]/images/left_shadow.gif' style='vertical-align: middle;'></td> <td width='100%'>"; print "<form name='topsite' action='source/reguser.php' method='post' onSubmit='return check_it();'>"; print "<table cellspacing='0' cellpadding='2' align='center' class='maintable'>"; print "<tr><td colspan='2' class='titlemedium' style='padding: 3px;' align='center'>$lang_reg4</td></tr>"; print "<tr><td class='tileshadow' colspan='2' align='center'><img src='skin/$setting[style]/images/spacer.gif' width='1' height='3' alt='' /></td></tr>"; print "<tr class='row5'><td nowrap valign='top'>$lang_reg5</td>"; print "<td><input type='text' name='topsiteuser' size='60'></td></tr>"; print "<tr class='row5'><td valign='top'>$lang_reg6</td>"; print "<td><input type='password' name='password' size='60'></td></tr>"; print "<tr class='row5'><td valign='top'>$lang_reg7</td>"; print "<td><input type='text' name='email' size='60'></td></tr>"; print "<tr class='row5'><td valign='top'>$lang_reg8</td>"; print "<td><input type='text' name='title' size='60'></td></tr>"; print "<tr class='row5'><td valign='top'>$lang_reg9</td>"; print "<td><input type='text' name='url' size='60' value=''></td></tr>"; print "<tr class='row5'><td valign='top'>$lang_reg10</td>"; print "<td><input type='text' name='button' size='60' value=''> <a href=\"javascript:void(window.open('http://www.imageshack.us/iframe.php?txtcolor=111111&type=blank&size=30','','height=100,width=275,left=0,top=0,toolbar=0,scrollbars=0'))\" target=\"_self\"><font face=\"Arial\" size=\"1\">UPLOAD HERE</font></a></td></tr>"; $selects="SELECT * FROM ".$prefix."categories where 1"; $selects2=mysql_query($selects) or die("Sorry, Could not select"); $selects3=mysql_fetch_array($selects2); if($selects3[ID]<1) {print"";}else { print "<tr class='row5'><td valign='top'>$lang_reg11</td>"; $selectcategory="SELECT * FROM ".$prefix."categories"; $selectcategory2=mysql_query($selectcategory) or die("Sorry, Could not select category"); print "<td><select name='catname'>"; $selectcategory="SELECT * FROM ".$prefix."categories"; $selectcategory2=mysql_query($selectcategory) or die("Sorry, Could not select category"); while($selectcategory3=mysql_fetch_array($selectcategory2)) {print "<option>$selectcategory3[catname]</option>";} print "</select></td></tr>";} print "<tr class='row5'><td width='40%' valign='top'>$lang_reg13<br>$lang_reg12</td>"; print "<td width='60%' ><textarea name='description' rows='5' cols='50'></textarea></td></tr>"; print "</table><br /><br />"; print "</td> <td class='shadowR'><img src='skin/$setting[style]/images/right_shadow.gif' style='vertical-align: middle;'></td> </tr></table>"; print"<table cellspacing='0' cellpadding='0' width='100%' align='center'><tr> <td><img src='skin/$setting[style]/images/mainfoot_left_shadow.gif' style='vertical-align: middle;'></td> <td><img src='skin/$setting[style]/images/mainfoot_left.gif' style='vertical-align: middle;'></td> <td class='footer' width='100%'><img src='skin/$setting[style]/images/mainfoot.gif' style='vertical-align: middle;'></td> <td><img src='skin/$setting[style]/images/mainfoot_right.gif' style='vertical-align: middle;'></td><td><img src='skin/$setting[style]/images/mainfoot_right_shadow.gif' style='vertical-align: middle;'></td> </tr></table><br />"; print "<table cellspacing='0' cellpadding='0' width='100%' align='center'><tr> <td><img src='skin/$setting[style]/images/cat_left_shadow.gif' style='vertical-align: middle;'></td> <td><img src='skin/$setting[style]/images/cat_left.gif' style='vertical-align: middle;'></td> <td class='tilecat' width='100%'><img src='skin/$setting[style]/images/tile_back.gif' style='vertical-align: middle;'></td> <td><img src='skin/$setting[style]/images/cat_right.gif' style='vertical-align: middle;'></td><td><img src='skin/$setting[style]/images/cat_right_shadow.gif' style='vertical-align: middle;'></td> </tr></table>"; print "<table cellspacing='0' cellpadding='0' width='100%' align='center'><tr> <td class='shadowL'><img src='skin/$setting[style]/images/left_shadow.gif' style='vertical-align: middle;'></td> <td width='100%'>"; print "<table cellspacing='0' cellpadding='2' align='center' class='maintable'>"; print "<tr><td class='titlemedium' style='padding: 3px;' align='center'>$lang_rul</td></tr>"; print "<tr><td class='tileshadow' align='center'><img src='skin/$setting[style]/images/spacer.gif' width='1' height='3' alt='' /></td></tr>"; print "<tr class='row5'><td nowrap valign='top' align='center'><textarea cols='60' rows='10'>$setting[rules]</textarea></td></tr>"; Print"<tr><td class='subs' colspan='2' align='center'><input type='submit' name='submit' value='$lang_agree'></td></tr></table></form>"; print "</td> <td class='shadowR'><img src='skin/$setting[style]/images/right_shadow.gif' style='vertical-align: middle;'></td> </tr></table>"; print"<table cellspacing='0' cellpadding='0' width='100%' align='center'><tr> <td><img src='skin/$setting[style]/images/mainfoot_left_shadow.gif' style='vertical-align: middle;'></td> <td><img src='skin/$setting[style]/images/mainfoot_left.gif' style='vertical-align: middle;'></td> <td class='footer' width='100%'><img src='skin/$setting[style]/images/mainfoot.gif' style='vertical-align: middle;'></td> <td><img src='skin/$setting[style]/images/mainfoot_right.gif' style='vertical-align: middle;'></td><td><img src='skin/$setting[style]/images/mainfoot_right_shadow.gif' style='vertical-align: middle;'></td> </tr></table><br />"; print "<table width='100%' border='0' cellspacing='0' cellpadding='0'> <tr><td colspan='$cols' nowrap style='padding: 3px;' id='runtime' ><div><span><center>$setting[magic]</center></span></div></td></tr></table>"; print "</td></tr></table>"; ?> I implemented google's reCAPTCHA V2 on http:// on the remote apache shared server and it worked 100%. I then changed the protocol to my shared server SSL using the same PHP script as the non-SSL script. The older version of reCaptcha had an SSL 'false' to 'true' SSL parameter, whereas I can't find one for V2. I had to use htaccess to redirect the example.com to the shared SSL server https://serverid.net/example/ which works perfectly without recCAPTCHA. I incorporated reCAPTCHA V2 and the error message where the reCAPTCHA image should be shows "ERROR: Invalid domain for site key". Hi guys, I'm having problems integrating Recaptcha into an existing form. I want it all to process on the same page. I took a look on Google and found a pre-existing script which does what I want but I'm still having trouble integrating it with what I already have, form fields and the recaptcha validate seperately. Here's my script so far: before the <html> tag: Code: [Select] <?php session_start(); ?> <?php // DEMO to use reCAPTCHA library on a form // // courtesy Spectrum Nashville // http://www.spectrum-nashville.com // // provide the Public Key and Private Key for your account he define( API_PUBLIC_KEY, '6LeNt84SAAAAAAH0Et-eJpNeuYO-kRXgrpcXML36' ); define( API_PRIVATE_KEY, '6LeNt84SAAAAAMlGWZUEHqFHncRyvaYbI5YdE8BY' ); // // once the keys have been provided above, this demo should work without any further changes to the code below // // include the recaptcha library file here // require_once('recaptchalib.php'); // // the $validated variable will switch to true in the code below if a valid CAPTCHA is submitted (see code below). // do not change this. // $validated = false; ?> <?php //If the form is submitted if(isset($_POST['submit'])) { //Check to make sure that the name field is not empty if(trim($_POST['name']) == '') { $hasError = true; } else { $name = trim($_POST['name']); } //Check to make sure sure that a valid email address is submitted if(trim($_POST['email']) == '') { $hasError = true; } else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))) { $hasError = true; } else { $email = trim($_POST['email']); } //Check to make sure comments were entered if(trim($_POST['comment']) == '') { $hasError = true; } else { if(function_exists('stripslashes')) { $comment = stripslashes(trim($_POST['comment'])); } else { $comment = trim($_POST['comment']); } } //If there is no error, send the email if(!isset($hasError)) { $emailTo = 'eevansrange@gmail.com'; //Put your own email address here $subject = "Feedback from TEST FORM"; $body = "Name: $name \n\nEmail: $email \n\nSubject: $subject \n\nComments:\n $comment"; // $body = "Enquiry type: $enquiry \n\nName: $name \n\nEmail: $email \n\nSubject: $subject \n\nComments:\n $comments"; $headers = 'From: My Site <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email; mail($emailTo, $subject, $body, $headers); $emailSent = true; } } ?> Within body tag: Code: [Select] <!-- RECAPTCHA START --> <script> // example of using JavaScript variable to provide "theme" control // of the reCAPTCHA element. This entire <script> block is optional. var RecaptchaOptions = { theme : 'blackglass', tabindex : 2 }; </script> <!-- RECAPTCHA END --> <section id="form"> <h2 class="blue">CONTACT ME</h2> <div id="form-holder"> <p class="form-instructions">Need some work doing? Have a comment? Post them below and I'll get back to you asap!</p> <?php if(isset($hasError)) { //If errors are found ?> <p class="errors">Please check you've filled out the fields correctly.</p> <?php } ?> <?php if(isset($emailSent) && $emailSent == true) { //If email is sent ?> <p class="success">Thank you <strong><?php echo $name;?></strong>, your email has been sent.</p> <?php } ?> <?php // see the form below and look for the hidden input named 'validate' to see how this works. This is a nice flag to // indicate to us that the validation should be attempted. The first time a user browses to this page, there will be // no 'validate' variable in the $_POST[] array, so no validation is attempted and no error message will be generated. // // do not change any of this code. // if( $_POST['validate'] === 'yes' ) { $response = recaptcha_check_answer( API_PRIVATE_KEY, $_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field'] ); if( ! $response->is_valid ) { // // captcha failed -- display the error message // // change this to whatever message you want to display. you could even perform other form validations // and display messages about other required fields, etc., here if you want. // use the CSS in the <head> section above to determine how your error message "box" will appear. // echo '<div id="recaptcha_error_box">The reCAPTCHA failed with this message: '.$response->error.'<br />Please try again.</div>'; // by default now, let the flow-of-control fall back into the <form> below so the user can try again } else { // set $validated to true so we know later in our document not to show the form again // don't change this. $validated = true; // // YOUR CODE HERE.... // // at this point, th form was submitted with valid reCAPTCHA, so go do whatever you wanted to do. // for the demo, we'll just echo back the values from the form. // // you could also send an email message, add or update database records, etc. // ?> <?php } /* end if( ! is_valid ) */ } /* end if($_POST['validate']==='yes') */ ?> <?php if( ! $validated ) { ?> <form class="cmxform" id="commentForm" method="post" border="0" action="<?php echo $_SERVER['PHP_SELF']; ?>#form"><!-- added #form so on submit the page anchors to the form div rather than taking you back to the top of the page --> <?php require_once('recaptchalib.php'); $publickey = "6LeNt84SAAAAAAH0Et-eJpNeuYO-kRXgrpcXML36"; // you got this from the signup page echo recaptcha_get_html($publickey); ?> <!--<input type="submit" />--> <br /> <label class="required" for="name" title="Enter your name"><span>Name</span><input type="text" id="name" name="name" size="50" class="required" value="<?php echo stripslashes(htmlentities($_POST['your_name'])); ?>" /></label> <label class="required" for="email" title="Enter your email"><span>Email</span><input type="text" id="email" name="email" size="50" class="required" value="<?php echo stripslashes(htmlentities($_POST['your_email'])); ?>" /></label> <label class="required" for="comment" title="Enter your comments" size="50" value="<?php echo stripslashes(htmlentities($_POST['comment'])); ?>"> <span>Comments</span><textarea name="comment" rows="5" cols="50" class="required"></textarea> </label> <!-- CAPTCHA START --> <?php echo recaptcha_get_html(API_PUBLIC_KEY); ?> <!-- CAPTCHA END --> <input type="hidden" name="validate" value="yes" /> <!--<input type="submit" value="Try It" />--> <label for="submit" class="nocontent"><input class="submit" type="submit" name="submit" value="Try It" title="Send form" />Items marked <img src="images/required-2.png" width="12" height="12" alt="required field" /> are required fields</label> <!-- need to include the name tag =submit above for the form to process and send the email --> <!-- class="nocontent" - commmented out of above label --> </form> <?php } /* end if( ! $validated ) */ ?> </div> </section> <!-- client-side validation --> <script type="text/javascript"> jQuery(function(){ // Grab each form element jQuery("label[title]").each(function(){ jQuery(this).append("<div class=\"infopop\">"); titletext = jQuery(this).attr("title"); jQuery(this).removeAttr("title"); jQuery(".infopop",this).css({opacity:0}).html(titletext); jQuery("input",this).focus(function(){ // Mouseover doFocus(this); }).blur(function(){ // MouseOut doBlur(this); }); /* ADDED TO show errors for textarea */ jQuery("textarea",this).focus(function(){ // Mouseover doFocus(this); }).blur(function(){ // MouseOut doBlur(this); }); }); }); function doFocus(obj) { jQuery(obj).addClass("active").parents("label").addClass("active").find(".infopop").animate({opacity:1,left:492},500); } function doBlur(obj) { if (validate(obj)) { isGood(obj); } } function reportErr(obj, message) { jQuery(obj).addClass("error").parents("label").removeClass("isgood").addClass("required").addClass("error").find(".infopop").html(message).addClass("errorpop").animate({opacity:1,left:492},500); } function isGood(obj) { jQuery(obj).removeClass("error").removeClass("active").parents("label").addClass("isgood").removeClass("error").removeClass("active").find(".infopop").removeClass("errorpop").animate({opacity:0,left:513},500); } function validate(obj) { mask = jQuery.extend({textfieldmask: /^[a-z\.\s-]{5,}$/i,emailmask: /^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/i,commentsboxmask: /^[a-z\.\s-]{5,}$/i}); errmsg = jQuery.extend({textfielderr:"5 or more letters",emailerr:"Invalid address",matcherr: "Must match",commenterr: "5 or more letters"}); var masktouse = null; var mustmatch = null; switch(obj.name) { case "name": masktouse="textfieldmask"; errtouse="textfielderr"; break; case "email": masktouse="emailmask"; errtouse="emailerr"; break; case "comment": masktouse="commentsboxmask"; errtouse="commenterr"; break; } // Check that the element is a required field before validating against it. if(jQuery(obj).parents("label").hasClass("required") && masktouse) { // Set up a quick way of accessing the object we're validating pointer = jQuery(obj); // Test the value of the field against the Regular Expression if (mask[masktouse].test(pointer.val())) { // The field validated successfully! // Check to see if the field needs to match another field in the form if (mustmatch) { // It does need to match, so grab the object it needs to match matchobj = jQuery("#"+mustmatch); if (matchobj.val()!='' && matchobj.val()!=pointer.val()) { // The fields don't match, so report an error on both of them reportErr(obj,errmsg["matcherr"]); reportErr(matchobj,errmsg["matcherr"]); } else { // Either the fields match, or the other field hasn't been completed yet // If the other field has been completed, call the isGood function to clear any error message showing if (matchobj.val()!='') { isGood(matchobj);} return true; } } else { // No match is required, so return true - validation passed! return true; } } else { // The field failed to validate against the Regular Expression reportErr(obj,errmsg[errtouse]); return false; } } else { // This isn't a required field, so we won't validate it against anything return true; } } </script> Any help would be much appreciated MK Hi All, Prob very simple but here goes. I've a form on a page, which needs a recaptcha field, due to design constraints however, it won't fit. I therefore need it so you fill in the form, click submit, a new window appears with the recaptcha field and a confirmation button. Once you click confirm, the form is processed and the email sent. What's the best way to do this please? The form script has the PHP to handle the emailing side. HI guys, On my site users are enabled to see the location of other users they are trying to find, but i want to add a link to that all users profiles on the window of their marker. Below is the code for the map. The link would be coded something like Code: [Select] <a href="userprofile.php?id=<?php echo $row['id'];?>"> im not sure if this is or the correct approach . I would thnk that it would have to be added to the create marker function... but i can get it to work Any help would be appreciated. Code: [Select] <script type="text/javascript"> //<![CDATA[ var iconBlue = new GIcon(); iconBlue.image = 'http://labs.google.com/ridefinder/images/mm_20_blue.png'; iconBlue.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'; iconBlue.iconSize = new GSize(12, 20); iconBlue.shadowSize = new GSize(22, 20); iconBlue.iconAnchor = new GPoint(6, 20); iconBlue.infoWindowAnchor = new GPoint(5, 1); var iconRed = new GIcon(); iconRed.image = 'http://labs.google.com/ridefinder/images/mm_20_red.png'; iconRed.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png'; iconRed.iconSize = new GSize(12, 20); iconRed.shadowSize = new GSize(22, 20); iconRed.iconAnchor = new GPoint(6, 20); iconRed.infoWindowAnchor = new GPoint(5, 1); var customIcons = []; customIcons["restaurant"] = iconBlue; customIcons["bar"] = iconRed; function load() { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("map")); map.addControl(new GSmallMapControl()); map.addControl(new GMapTypeControl()); map.setCenter(new GLatLng(51.89787, -8.47109), 13); GDownloadUrl("geo.php", function(data) { var xml = GXml.parse(data); var markers = xml.documentElement.getElementsByTagName("marker"); for (var i = 0; i < markers.length; i++) { var name = markers[i].getAttribute("name"); var address = markers[i].getAttribute("address"); var type = markers[i].getAttribute("type"); var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng"))); var marker = createMarker(point, name, address, type); map.addOverlay(marker); } }); } } function createMarker(point, name, address, type) { var marker = new GMarker(point, customIcons[type]); var html = "<b>" + name + "</b><br/>" + address; GEvent.addListener(marker, 'click', function() { marker.openInfoWindowHtml(html); }); return marker; } //]]> HI, I have been using toolbarqueries.google.com in a php script to retrieve the PR for domains and update them in a database. Recently it has stopped working and all domains show a PR 0. Any help would be appreciated. Thanks, Gibs Hallo allenmaal,
Weet iemand de moeilijkheidsgraad van deze captcha code. Note! Ik heb een reden waarom ik geen reCaptcha v3 wil gebruiken..
Can someone help me please?.... I'm using this Code: [Select] <form name="form1" method="post" action="create-b.php" enctype="application/x-www-form-urlencoded" style="margin:0px"> <input name="name" value="Anonymous" type="text" MAXLENGTH="15" style="position:absolute;width:650px;left:67px;top:142px;z-index:4"> <input name="subject" value="(No subject)" MAXLENGTH="15" type="text" style="position:absolute;width:650px;left:67px;top:166px;z-index:5"> <textarea name="body" MAXLENGTH="255" type="text" style="position:absolute;left:67px;top:191px;width:650px;height:98px;z-index:6"></textarea> <div id="captcha" style="position:absolute; overflow:hidden; left:10px; top:296px; z-index:8"> <input name="submit" type="submit" value="Create thread" style="position:absolute;left:614px;top:291px;z-index:7"> <?php require_once('captc/recaptchalib.php'); $publickey = "**************************************"; echo recaptcha_get_html($publickey); ?> </form>On the HTML side and this require_once('captc/recaptchalib.php'); $privatekey = "************************"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { // What happens when the CAPTCHA was entered incorrectly die ("<font color='red'><font size='12'><strong><center>The verification code you entered appears to be incorrect!"); } else { CONTENT CONTENT CONTENT CONTENT CONTENT ETC But it always returns "The verification code you entered appears to be incorrect!" Any idea what I'm doing wrong?... I have a webpage which has the following: WEBPAGE <form method="post" action="http://www.xxxx.nz/Scripts/xxxxemail.php" enctype="multipart/form-data"> <div> <input type="hidden" name="redirect" value="http://xxxxxxx.net.nz/xxxxyou.php" /></div> <form> <table border="1"> <tr><td>Company Name (required)</td><td><input type="text" name="Business" /></td></tr> <tr><td>Email Address (required)</td><td><input type="text" name="Email" /></td></tr> <tr><td>Wish To Sign Up For ?</td><td><select size="1" name="xxxxxxx"> <option value="No">No</option> <option value="Yes">Yes</option> xxxxxx xxxxxx xxxxxx <input type="submit" value="Submit for Quote" /></td></tr> xxxxemail.php <?php require '/home/xxxxxz/Includes/connect.php'; /* Assign all variables passed from the form */ $business = mysql_real_escape_string($_POST['Business']); xxxxxx xxxxxx /* Sending email with information to us */ $to = "kerryxxxxx"; $subject = "xxxxx"; $random_hash = md5(date('r', time())); $headers = 'From: xxxxxxx'; $headers .= "\r\nContent-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\""; ob_start(); ?> --PHP-alt-<?php echo $random_hash; ?> Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: 7bit <!-- Email Content --> <? include '/home/xxxxxx/Includes/laqcquote.inc'; ?> <!-- End of Email Content --> --PHP-alt-<?php echo $random_hash; ?>-- <?php $html = ob_get_contents(); ob_end_clean(); $body = $html; mail($to, $subject, $body, $headers); /* Once Complete return to............*/ header("Location: https://xxxxxxxxxxxxxxxxxxx/qxxxxxyou.php"); ?> if I want to add the recaptcha and have it verify what do i need to do? I have code via recaptcha and it says used a verify.php. If I do that i do not have the web page going through to where I can get the data via email and it does not give me an error message. Can anyone help? This is all new to me and I am struggling to see where I put the recaptcha and to make it work if right and not work if wrong soory guys .. actually i am trying to add pagination in script.. but its not pagging.
but when i tried without isset($_get the code worked fine and then i tried to doing with isset($_get for a perticular cat
but its not working. can someone see my code and tell me whats worng i have done.
<!DOCTYPE HTML> <html> <head> </head> <body> <?php // include database connection include 'libs/db_connect.php'; // page is the current page, if there's nothing set, default is page 1 $page = isset($_GET['page']) ? $_GET['page'] : 1; // set records or rows of data per page $recordsPerPage = 1; // calculate for the query LIMIT clause $fromRecordNum = ($recordsPerPage * $page) - $recordsPerPage; // select all data $query = "SELECT * FROM posts ORDER BY post_id desc LIMIT {$fromRecordNum}, {$recordsPerPage}"; /* page and its LIMIT clause looks like: 1 = 0, 5 2 = 5,10 3 = 10,15 4 = 15, 20 5 = 20, 25 */ $stmt = $con->prepare( $query ); $stmt->execute(); //this is how to get number of rows returned $num = $stmt->rowCount(); //check if more than 0 record found if($num>0){ $cat=1; if(isset($_GET['cat'])){ $cat_id = $_GET['cat']; $get_posts = "select * from posts where category_id = '$cat_id'"; $run_posts = mysql_query($get_posts); while($row_posts = mysql_fetch_array($run_posts)){ $post_id = $row_posts['post_id']; $post_title = $row_posts['post_title']; $post_date = $row_posts['post_date']; $post_author = $row_posts['post_author']; $post_image = $row_posts['image']; $post_content = substr($row_posts['post_content'],0,80); echo " <div class='post_area'> <h4> <a href = 'details.php?post=$post_id'>$post_title</a> </h4> <div class='date'><div id='com'> Date</div>$post_date</div><span style='font-size:12px'><i style='color:grey;font-size:10px'>Posted By</i> </b>$post_author</span> <content><img src = '123dondadatest/news_images/$post_image' width = '100' height='100'/> <div>$post_content <br/><a id='rmlink' href = 'details.php?post=$post_id'> Read More...</a></div><br /><br/><br/><br/> </div> "; } } // *************** <PAGING_SECTION> *************** echo "<div id='paging'>"; // ***** for 'first' and 'previous' pages if($page>1){ // ********** show the first page echo "<a href='" . $_SERVER['PHP_SELF'] . "' title='Go to the first page.' class='customBtn'>"; echo "<span style='margin:0 .5em;'> << </span>"; echo "</a>"; // ********** show the previous page $prev_page = $page - 1; echo "<a href='" . $_SERVER['PHP_SELF'] . "?page={$prev_page}' title='Previous page is {$prev_page}.' class='customBtn'>"; echo "<span style='margin:0 .5em;'> < </span>"; echo "</a>"; } // ********** show the number paging // find out total pages $query = "SELECT COUNT(*) as total_rows FROM posts"; $stmt = $con->prepare( $query ); $stmt->execute(); $row = $stmt->fetch(PDO::FETCH_ASSOC); $total_rows = $row['total_rows']; $total_pages = ceil($total_rows / $recordsPerPage); // range of num links to show $range = 2; // display links to 'range of pages' around 'current page' $initial_num = $page - $range; $condition_limit_num = ($page + $range) + 1; for ($x=$initial_num; $x<$condition_limit_num; $x++) { // be sure '$x is greater than 0' AND 'less than or equal to the $total_pages' if (($x > 0) && ($x <= $total_pages)) { // current page if ($x == $page) { echo "<span class='customBtn' style='background:red;'>$x</span>"; } // not current page else { echo " <a href='{$_SERVER['PHP_SELF']}?page=$x' class='customBtn'>$x</a> "; } } } // ***** for 'next' and 'last' pages if($page<$total_pages){ // ********** show the next page $next_page = $page + 1; echo "<a href='" . $_SERVER['PHP_SELF'] . "?page={$next_page}' title='Next page is {$next_page}.' class='customBtn'>"; echo "<span style='margin:0 .5em;'> > </span>"; echo "</a>"; // ********** show the last page echo "<a href='" . $_SERVER['PHP_SELF'] . "?page={$total_pages}' title='Last page is {$total_pages}.' class='customBtn'>"; echo "<span style='margin:0 .5em;'> >> </span>"; echo "</a>"; } echo "</div>"; // ***** allow user to enter page number echo "<form action='" . $_SERVER['PHP_SELF'] . "' method='GET'>"; echo "Go to page: "; echo "<input type='text' name='page' size='1' />"; echo "<input type='submit' value='Go' class='customBtn' />"; echo "</form>"; // *************** </PAGING_SECTION> *************** } // tell the user if no records were found else{ echo "<div class='noneFound'>No records found.</div>"; } ?> </body> </html> I've tried two separate captcha options, Securimage and reCaptcha, which is the one I currently have on my page. I got the same error with each code: Quote Warning: Cannot modify header information - headers already sent by (output started at /home/jwrbloom/public_html/metroindybasketball.com/form/dbenter.php:20) in /home/jwrbloom/public_html/metroindybasketball.com/form/dbenter.php on line 101 It's a conflict with the code that moves my User to the 'next step'. Here is the code: (scroll down toward the bottom, just before the email fields) <?php require_once('/home/jwrbloom/public_html/metroindybasketball.com/recaptcha/recaptchalib.php'); $privatekey = "6LetxbwSAAAAAMP2q1q5F5S_tiEcu1sH1_dM3DTl "; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { // What happens when the CAPTCHA was entered incorrectly die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." . "(reCAPTCHA said: " . $resp->error . ")"); } else { // Your code here to handle a successful verification } ?> <?php /* connect to database */ if(!$con = mysql_connect("localhost","######","######")) { die("Could not connect to database: ".mysql_error()); } mysql_select_db("######_wpMIB", $con); $nameFirst = $_POST['nameFirst']; $nameLast = $_POST['nameLast']; $email = $_POST['email']; $addressHome = $_POST['addressHome']; $cityHome = $_POST['cityHome']; $stateHome = $_POST['stateHome']; $zipHome = $_POST['zipHome']; $phoneHome = $_POST['phoneHome']; $phoneMobile = $_POST['phoneMobile']; $school = $_POST['school']; $grade = $_POST['grade']; $coachSchool = $_POST['coachSchool']; $feet = $_POST['feet']; $inches = $_POST['inches']; /* search for existing row */ $sql = "SELECT id FROM fallLeague10 WHERE nameFirst='".mysql_real_escape_string($nameFirst)."' AND nameLast='".mysql_real_escape_string($nameLast)."' AND school='".mysql_real_escape_string($school)."'"; if(!$result = mysql_query($sql)) { die(mysql_error()."<br />Query: ".$sql); } if(mysql_num_rows($result)) { $row = mysql_fetch_assoc($result); /* update existing row */ $sql = "UPDATE fallLeague10 SET confirm='y', email='".mysql_real_escape_string($email)."', addressHome='".mysql_real_escape_string($addressHome)."', cityHome='".mysql_real_escape_string($cityHome)."', stateHome='".mysql_real_escape_string($stateHome)."', zipHome='".mysql_real_escape_string($zipHome)."', phoneHome='".mysql_real_escape_string($phoneHome)."', phoneMobile='".mysql_real_escape_string($phoneMobile)."', coachSchool='".mysql_real_escape_string($coachSchool)."', feet='".mysql_real_escape_string($feet)."', inches='".mysql_real_escape_string($inches)."' WHERE id='".$row['id']."'"; if(!$result = mysql_query($sql)) { die(mysql_error()."<br />Query: ".$sql); } } else { /* insert new row */ $sql = "INSERT INTO fallLeague10 SET confirm='y', nameFirst='".mysql_real_escape_string($nameFirst)."', nameLast='".mysql_real_escape_string($nameLast)."', email='".mysql_real_escape_string($email)."', addressHome='".mysql_real_escape_string($addressHome)."', cityHome='".mysql_real_escape_string($cityHome)."', stateHome='".mysql_real_escape_string($stateHome)."', zipHome='".mysql_real_escape_string($zipHome)."', phoneHome='".mysql_real_escape_string($phoneHome)."', phoneMobile='".mysql_real_escape_string($phoneMobile)."', school='".mysql_real_escape_string($school)."', grade='".mysql_real_escape_string($grade)."', coachSchool='".mysql_real_escape_string($coachSchool)."', feet='".mysql_real_escape_string($feet)."', inches='".mysql_real_escape_string($inches)."'"; if(!$result = mysql_query($sql)) { die(mysql_error()."<br />Query: ".$sql); } } /* redirect user HERE IS WHERE I AM HAVING MY ERROR */ header("Location:/fall-league/payment"); //exit(); ?> <?php // The message $message = $_POST['nameFirst'] . " " . $_POST['nameLast'] ." has entered the fall league.\n"; $message .= $_POST['feet'] . "'" . $_POST['inches'] ."\", " . $_POST['grade'] . "; " . $_POST['school'] ."\n"; $message .= $_POST['email']; // In case any of our lines are larger than 70 characters, we should use wordwrap() $message = wordwrap($message, 70); $headers = 'From: ' . $_POST['nameFirst'] . " " . $_POST['nameLast'] . " " . $_POST['email']; // Send mail('basketball@metroindybasketball.com', '2010 Fall League Registration', $message, $headers); ?> I cannot redirect to other page even I enter correct information and recaptcha in activation form. Anyone who can check what going wrong in my activation script?
Here is my php activation check script:
<?php Hi there guys, what would be the best way to print information from PHP contact form to google spreadsheet, i've tried to follow this tutorial: http://www.farinspace.com/saving-form-data-to-google-spreadsheets/ And i fail in every way. I have few fields only, let's say Full name, Email, Address, Checkbox and Select (dropdown) option, i would like to know how can i store inputs to the google spreadsheet, not single one, but all of them... Help is much appreciated! The upload script I'm using performs successfully in Google, but not in IE or FF. |