Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
  1. #1
    Senior Member
    Join Date
    Sep 2003
    Location
    Sydney
    Posts
    114
    Member #
    3051
    So I finally got my CAPTCHA to implement just nicely. What I'm wondering is...is there a way to produce an error message on the same page without wiping the fields that the user just filled in?

    I've tried:

    PHP Code:
    <?php
    $oldvalu 
    '';
        if(isset(
    $_POST['name'])) {
        
    $oldvalu == $_POST['name'];
        }
        echo
    "<input name=\"name\" type=\"text\" value=\"$oldvalu\" class=\"formstyles\" />";
    ?>
    and

    PHP Code:
    <input type='text' name='email' class="formstyles" value="{$_POST['email']}/> 
    Both to no avail...

  2.  

  3. #2
    ljm
    ljm is offline
    Senior Member ljm's Avatar
    Join Date
    Aug 2006
    Location
    Manchester, England
    Posts
    284
    Member #
    13684
    Liked
    1 times
    I am unsure as to whether your method will work efficiently, but try replacing [minicode]isset()[/minicode]with [minicode]empty()[/minicode].

    Simplified error reporting may also be of use. The code's a bit small to read, but it's a helpful read and it explains it a whole lot better than I could have done.

  4. #3
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    You're using == when you want =.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  5. #4
    Senior Member
    Join Date
    Sep 2003
    Location
    Sydney
    Posts
    114
    Member #
    3051
    Thanks for the reply...just tried that but still no luck :-\

    This is my error code:

    PHP Code:
    if (isset($_POST['submit'])) {
        if (
    $_SESSION['security_code'] != $_POST['security_code'] && !empty($_SESSION['security_code'])){
            
    header("Location: /pacesetter/index.php?id=quotes&subid=downunder&error=1");
            exit;
            }
        else {
            
    letsgo();
            }
    }
    else { 

  6. #5
    ljm
    ljm is offline
    Senior Member ljm's Avatar
    Join Date
    Aug 2006
    Location
    Manchester, England
    Posts
    284
    Member #
    13684
    Liked
    1 times
    Your code is saying only to produce the error message if the image's security code and the submitted one doesn't match, AND the security code field isn't empty. The latter isn't necessary because an empty field won't match the stored security code anyway. You've also only used one equals sign, which means only the length of the provided data is compared.

    PHP Code:
    if ($_SESSION['security_code'] !== $_POST['security_code']) {
     
    header('Location: url');
    }
    else {
     
    letsgo();

    I don't suggest combining a check for an empty field and a check for mismatching data. It would be better to validate the form and ensure all fields have been filed first, then do things like checking the image verification afterwards.

    The other problem I can see from that is that the script will redirect the moment an error is spotted. If you are using this method for each field, the user's not going to see everything that's wrong with his submission at once, he'll have to keep submitting until it's all correct.

  7. #6
    Senior Member
    Join Date
    Sep 2003
    Location
    Sydney
    Posts
    114
    Member #
    3051
    Duly noted and amended. Thanks mate.

    But as for my other issue...I'm stuck. I realise it's to do with the &error=1 URL, but I'm not sure of a way around it.

  8. #7
    ljm
    ljm is offline
    Senior Member ljm's Avatar
    Join Date
    Aug 2006
    Location
    Manchester, England
    Posts
    284
    Member #
    13684
    Liked
    1 times
    Is the script spitting out an error? If so, could you post that please? If not, could you post the part of the script that uses the error variable in the URL? I imagine the URL itself is not the problem, because it looks fine; it may be to do with how you're dealing with it in the script. For example, are you using $_GET? It won't work using $_POST.

    Without a bit more to work off, we'll just be stabbing in the dark.

  9. #8
    Senior Member
    Join Date
    Sep 2003
    Location
    Sydney
    Posts
    114
    Member #
    3051
    No worries mate.

    No error message, just takes me back to the form without the fields filled in. If I fill the fields in and press refresh, they remained filled...so I'm guessing that bit is working.

    This the code:

    PHP Code:
    elseif($_GET['id'] == 'quotes') {
           if(
    $_GET['subid'] == 'downunder') {
            if(
    $_GET['error'] == 1){
            echo 
    "<div class='wrongcode'>You entered an incorrect security code...</div>";
            }
        include(
    'quotes/downunder/index.php'); 
         } 

  10. #9
    ljm
    ljm is offline
    Senior Member ljm's Avatar
    Join Date
    Aug 2006
    Location
    Manchester, England
    Posts
    284
    Member #
    13684
    Liked
    1 times
    I'm not understanding what's supposed to happen there.

    If you submit an empty form, do all your errors show up, or does the page look like it's just refreshed itself?

  11. #10
    Senior Member
    Join Date
    Sep 2003
    Location
    Sydney
    Posts
    114
    Member #
    3051
    An empty form won't go anywhere. You get a javascript alert.

    It's more if you fill out every field and then get the security code wrong, I don't want users to have to fill in all those fields again. It's a bloody big form.

    What happens at the moment is they're redirected/the page refreshes with &error=1...


Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 07:38 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com