Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jun 2013
    Location
    North Wales
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Captcha security not working

    Hi all have been wrestling with this for a few days now, and I have run out of ideas I cannot seem to get the Captcha to work .

    Code:
    <?php 
    session_start();
    if( isset($_POST['submit']))
    {
       if( $_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSION['security_code'] ) )
    {
    		// Insert you code for processing the form here, e.g emailing the submission, entering it into a database. 
    		echo 'Thank you. Your message said "'.$_POST['message'].'"';
    		unset($_SESSION['security_code']);
    }
    else
    {
    	// Insert your code for showing an error message here
    		echo 'Sorry, you have provided an invalid security code';
    }
    } else
    ob_start();
    $fromemail="No-Reply <sales@kensington-sashwindows.co.uk>"; // change here if you want
    $toemail="sales@kensington-sashwindows.co.uk";   // change here if you want
    $sub="Online Feedback";          // change here if you want
    $success_page_name="success.html";
    ////// do not change in following
    if($_SERVER['REQUEST_METHOD']=="POST")
    {
    $fieldnm_1=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_1']));  
    $fieldnm_2=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_2']));  
    $fieldnm_3=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_3']));  
    $fieldnm_4=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_4']));  
    $fieldnm_5=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_5']));  
    $fieldnm_6=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_6']));  
    $fieldnm_7=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_7']));  
    $fieldnm_8=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_8']));  
    $fieldnm_9=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_9']));  
    $fieldnm_10=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_10']));  
    
    
    $contentmsg=stripslashes("<br><b><font style=color:#CC3300>$sub</font></b><br>
    <table width=708 border=0 cellpadding=2 cellspacing=1 bgcolor=#CCCCCC>
    <tr>
          <td width=165 align=right valign=top bgcolor=#FFFFFF><B>First Name *:</b> </td>
          <td width=565 align=left valign=top bgcolor=#FFFFFF>$fieldnm_1</td>
    </tr>
    <tr>
          <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Last name *:</b> </td>
          <td width=565 align=left valign=top bgcolor=#FFFFFF>$fieldnm_2</td>
    </tr>
    <tr>
          <td width=165 align=right valign=top bgcolor=#FFFFFF><B>House name or number *:</b> </td>
          <td width=565 align=left valign=top bgcolor=#FFFFFF>$fieldnm_3</td>
    </tr>
    <tr>
          <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Address:</b> </td>
          <td width=565 align=left valign=top bgcolor=#FFFFFF>$fieldnm_4</td>
    </tr>
    <tr>
          <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Address:</b> </td>
          <td width=565 align=left valign=top bgcolor=#FFFFFF>$fieldnm_5</td>
    </tr>
    <tr>
          <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Address:</b> </td>
          <td width=565 align=left valign=top bgcolor=#FFFFFF>$fieldnm_6</td>
    </tr>
    <tr>
          <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Post code *:</b> </td>
          <td width=565 align=left valign=top bgcolor=#FFFFFF>$fieldnm_7</td>
    </tr>
    <tr>
          <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Phone Number *:</b> </td>
          <td width=565 align=left valign=top bgcolor=#FFFFFF>$fieldnm_8</td>
    </tr>
    <tr>
          <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Email *:</b> </td>
          <td width=565 align=left valign=top bgcolor=#FFFFFF>$fieldnm_9</td>
    </tr>
    <tr>
          <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Comments :</b> </td>
          <td width=565 align=left valign=top bgcolor=#FFFFFF>$fieldnm_10</td>
    </tr>
    </table>
    ");
    
    ////
    $headers  = "MIME-Version: 1.0
    ";
    $headers .= "Content-type: text/html; charset=iso-8859-1
    ";
    				
    $from=$fromemail;
    				
    $headers .= "From: ".$from." 
    ";
    				
    @mail($toemail,$sub,$contentmsg,$headers);
    				
    header("Location:$success_page_name");
    }
    ?>

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,332
    Thanks
    60
    Thanked 526 Times in 513 Posts
    Blog Entries
    4
    You've not described the symtoms very well really. Are you getting the incorrect message all the time or does the code simply not appear to do anything? Maybe you get a blank white page?

    Please see my signature for a very important tip too. It's in the big php box and it has a link under that to show you what the bug does in IE.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #3
    New to the CF scene
    Join Date
    Jun 2013
    Location
    North Wales
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    The recaptcha challenge

    The recaptcha challenge dose not work at all. I have tried various combinations of putting the form in the code and the best one was below
    that half worked in so much that you only got the error message and no form I have no coding experience what so ever only know basic html.

    Code:
    <?php 
    session_start();
    if( isset($_POST['submit']))
    {
       if( $_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSION['security_code'] ) )
    {
    		$fromemail="No-Reply <sales@kensington-sashwindows.co.uk>"; // change here if you want
    $toemail="sales@kensington-sashwindows.co.uk";   // change here if you want
    $sub="Online Feedback";          // change here if you want
    $success_page_name="success.html";
    		echo 'Thank you. Your message said "'.$_POST['message'].'"';
    		unset($_SESSION['security_code']);
    }
    else
    {
    	// Insert your code for showing an error message here
    		echo 'Sorry, you have provided an invalid security code';
    }
    } else
    ob_start();
    ////// do not change in following
    if($_SERVER['REQUEST_METHOD']=="POST")
    {
    $fieldnm_1=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_1']));  
    $fieldnm_2=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_2']));  
    $fieldnm_3=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_3']));  
    $fieldnm_4=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_4']));  
    $fieldnm_5=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_5']));  
    $fieldnm_6=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_6']));  
    $fieldnm_7=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_7']));  
    $fieldnm_8=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_8']));  
    $fieldnm_9=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_9']));  
    $fieldnm_10=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_10']));  
    
    
    $contentmsg=stripslashes("<br><b><font style=color:#CC3300>$sub</font></b><br>
    <table width=708 border=0 cellpadding=2 cellspacing=1 bgcolor=#CCCCCC>
    <tr>
          <td width=165 align=right valign=top bgcolor=#FFFFFF><B>First Name *:</b> </td>
          <td width=565 align=left valign=top bgcolor=#FFFFFF>$fieldnm_1</td>
    </tr>
    <tr>
          <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Last name *:</b> </td>
          <td width=565 align=left valign=top bgcolor=#FFFFFF>$fieldnm_2</td>
    </tr>
    <tr>
          <td width=165 align=right valign=top bgcolor=#FFFFFF><B>House name or number *:</b> </td>
          <td width=565 align=left valign=top bgcolor=#FFFFFF>$fieldnm_3</td>
    </tr>
    <tr>
          <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Address:</b> </td>
          <td width=565 align=left valign=top bgcolor=#FFFFFF>$fieldnm_4</td>
    </tr>
    <tr>
          <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Address:</b> </td>
          <td width=565 align=left valign=top bgcolor=#FFFFFF>$fieldnm_5</td>
    </tr>
    <tr>
          <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Address:</b> </td>
          <td width=565 align=left valign=top bgcolor=#FFFFFF>$fieldnm_6</td>
    </tr>
    <tr>
          <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Post code *:</b> </td>
          <td width=565 align=left valign=top bgcolor=#FFFFFF>$fieldnm_7</td>
    </tr>
    <tr>
          <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Phone Number *:</b> </td>
          <td width=565 align=left valign=top bgcolor=#FFFFFF>$fieldnm_8</td>
    </tr>
    <tr>
          <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Email *:</b> </td>
          <td width=565 align=left valign=top bgcolor=#FFFFFF>$fieldnm_9</td>
    </tr>
    <tr>
          <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Comments :</b> </td>
          <td width=565 align=left valign=top bgcolor=#FFFFFF>$fieldnm_10</td>
    </tr>
    </table>
    ");
    
    ////
    $headers  = "MIME-Version: 1.0
    ";
    $headers .= "Content-type: text/html; charset=iso-8859-1
    ";
    				
    $from=$fromemail;
    				
    $headers .= "From: ".$from." 
    ";
    				
    @mail($toemail,$sub,$contentmsg,$headers);
    				
    header("Location:$success_page_name");
    }
    ?>

  • #4
    Senior Coder
    Join Date
    Sep 2010
    Posts
    2,001
    Thanks
    15
    Thanked 235 Times in 235 Posts
    I went to the site, you should put a link so we can see what is happening. I don't see any code for processing the inputs, when I submit the info it sends me off to blank page, the form opens in a separate window, but when submitted it opens in a larger window. There are some errors in your HTML, look at the source in Firefox and you will see tham. We need to see more of your php. And it looks and works a lot better if the form opens as a modal window centered in the home page The same for the success info.
    Welcome to http://www.myphotowizard.net

    where you can edit images, make a photo calendar, add text to images, and do much more.


    When you know what you're doing it's called Engineering, when you don't know, it's called Research and Development. And you can always charge more for Research and Development.

  • #5
    New to the CF scene
    Join Date
    Jun 2013
    Location
    North Wales
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Created a test site

    Hi all I've created a test site. for the Captcha/ form

    http://kensingtonsashes.com/Testfold...ct%20form.html
    Below is my form
    Code:
    <form name="form" method="POST" action="_sendmail.php" onSubmit="return CheckAll(this);">
    <table align="center" border="0" cellspacing="1" cellpadding="2">
    <tr>
    <td  align="left" valign="top">First Name * </td>
    <td  align="left" valign="top"><input name="fieldnm_1" type="text" size="33" /></td>
    </tr>
    <tr>
    <td  align="left" valign="top">Last name * </td>
    <td  align="left" valign="top"><input name="fieldnm_2" type="text" size="33" /></td>
    </tr>
    <tr>
    <td width="200" align="left" valign="top">House name or number * </td>
    <td  align="left" valign="top"><input name="fieldnm_3" type="text" size="33" /></td>
    </tr>
    <tr>
    <td  align="left" valign="top">Address</td>
    <td  align="left" valign="top"><input name="fieldnm_4" type="text" size="33" /></td>
    </tr>
    <tr>
    <td  align="left" valign="top">Address</td>
    <td  align="left" valign="top"><input name="fieldnm_5" type="text" size="33" /></td>
    </tr>
    <tr>
    <td  align="left" valign="top">Address</td>
    <td  align="left" valign="top"><input name="fieldnm_6" type="text" size="33" /></td>
    </tr>
    <tr>
    <td  align="left" valign="top">Post code * </td>
    <td  align="left" valign="top"><input name="fieldnm_7" type="text" size="33" /></td>
    </tr>
    <tr>
    <td  align="left" valign="top">Phone Number * </td>
    <td  align="left" valign="top"><input name="fieldnm_8" type="text" size="33" /></td>
    </tr>
    <tr>
    <td  align="left" valign="top">Email * </td>
    <td  align="left" valign="top"><input name="fieldnm_9" type="text" size="33" /></td>
    </tr>
    <tr>
    <td  align="left" valign="top">Interested in</td>
    <td  align="left" valign="top">
    <textarea name="fieldnm_10" cols="25" rows="10"></textarea>	  
    </td>
    </tr>
    <tr>
    <td  align="left" valign="top">Security Code</td>
    <td><img src="CaptchaSecurityImages.php"alt="" /></td>
    <tr>
    <td  align="left" valign="top">&nbsp;</td>
    <td><input id="security_code" name="security_code" type="text" /></td></tr>
    </tr>
    <td>&nbsp;</td>
    <td><input type="submit" name="Submit" value="Submit">
    <input type="reset" name="Submit2" value="Reset"></td>
    </tr>
    </table>
    </form>
    Below is the php for the form

    Code:
    <?php ob_start();
    $fromemail="No-Reply <test@hotmail.com>"; // change here if you want
    $toemail="test@hotmail.com";   // change here if you want
    $sub="Online Feedback";          // change here if you want
    $success_page_name="success.html";
    ////// do not change in following
    if($_SERVER['REQUEST_METHOD']=="POST")
    {
    $fieldnm_1=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_1']));  
    $fieldnm_2=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_2']));  
    $fieldnm_3=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_3']));  
    $fieldnm_4=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_4']));  
    $fieldnm_5=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_5']));  
    $fieldnm_6=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_6']));  
    $fieldnm_7=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_7']));  
    $fieldnm_8=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_8']));  
    $fieldnm_9=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_9']));  
    $fieldnm_10=str_replace ( array("\n"), array("<br>"),trim($_REQUEST['fieldnm_10']));  
    
    $contentmsg=stripslashes("<br><b><font style=color:#CC3300>$sub</font></b><br>
    <table width=708 border=0 cellpadding=2 cellspacing=1 bgcolor=#CCCCCC>
    <tr>
    <td width=165 align=right valign=top bgcolor=#FFFFFF><B>First Name *:</b> </td>
    <td width=565 align=left valign=top bgcolor=#FFFFFF>$fieldnm_1</td>
    </tr>
    <tr>
    <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Last name *:</b> </td>
    <td width=565 align=left valign=top bgcolor=#FFFFFF>$fieldnm_2</td>
    </tr>
    <tr>
    <td width=165 align=right valign=top bgcolor=#FFFFFF><B>House name or number *:</b> </td>
    <td width=565 align=left valign=top bgcolor=#FFFFFF>$fieldnm_3</td>
    </tr>
    <tr>
    <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Address:</b> </td>
    <td width=565 align=left valign=top bgcolor=#FFFFFF>$fieldnm_4</td>
    </tr>
    <tr>
    <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Address:</b> </td>
    <td width=565 align=left valign=top bgcolor=#FFFFFF>$fieldnm_5</td>
    </tr>
    <tr>
    <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Address:</b> </td>
    <td width=565 align=left valign=top bgcolor=#FFFFFF>$fieldnm_6</td>
    </tr>
    <tr>
    <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Post code *:</b> </td>
    <td width=565 align=left valign=top bgcolor=#FFFFFF>$fieldnm_7</td>
    </tr>
    <tr>
    <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Phone Number *:</b> </td>
    <td width=565 align=left valign=top bgcolor=#FFFFFF>$fieldnm_8</td>
    </tr>
    <tr>
    <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Email *:</b> </td>
    <td width=565 align=left valign=top bgcolor=#FFFFFF>$fieldnm_9</td>
    </tr>
    <tr>
    <td width=165 align=right valign=top bgcolor=#FFFFFF><B>Comments :</b> </td>
    <td width=565 align=left valign=top bgcolor=#FFFFFF>$fieldnm_10</td>
    </tr>
    </table>
    ");
    ////
    $headers  = "MIME-Version: 1.0
    ";
    $headers .= "Content-type: text/html; charset=iso-8859-1
    ";
    $from=$fromemail;
    $headers .= "From: ".$from." 
    ";
    @mail($toemail,$sub,$contentmsg,$headers);
    header("Location:$success_page_name");
    }
    ?>
    below is the Captcha php I want to integrate with my form

    Code:
    <?php 
    session_start();
    
    if( isset($_POST['submit']))
    {
       if( $_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSION['security_code'] ) )
    {
    		// Insert you code for processing the form here, e.g emailing the submission, entering it into a database. 
    		echo 'Thank you. Your message said "'.$_POST['message'].'"';
    		unset($_SESSION['security_code']);
    }
    else
    {
    	// Insert your code for showing an error message here
    		echo 'Sorry, you have provided an invalid security code';
    }
    } else {
    ?>
    
    	<form action="form.php" method="post">
    		<label for="name">Name: </label><input type="text" name="name" id="name" /><br />
    		<label for="email">Email: </label><input type="text" name="email" id="email" /><br />
    		<label for="message">Message: </label><textarea rows="5" cols="30" name="message" id="message"></textarea><br />
    		<img src="CaptchaSecurityImages.php?width=100&height=40&characters=5" /><br />
    		<label for="security_code">Security Code: </label><input id="security_code" name="security_code" type="text" /><br />
    		<input type="submit" name="submit" value="Submit" />
    	</form>
    
    <?php
    	}
    ?>
    Any help greatly appreciated as I've been try all week to get this to work


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •