1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Hey Guest Last month we upgraded BlackHatWorld.com to a new platform - . If you notice anything that requires attention please start a new thread here.
    Dismiss Notice

Form field reset need help

Discussion in 'PHP & Perl' started by thorjack1990, May 20, 2013.

  1. thorjack1990

    thorjack1990 BANNED BANNED

    Joined:
    Feb 15, 2013
    Messages:
    71
    Likes Received:
    9
    does any1 know how to reset a form field? lets just say email add is missing when you submit the form then a pop-up appear saying "email required" when clicking ok the form and captcha will automatically reset.,any help plz?
     
  2. Lyscer

    Lyscer Junior Member

    Joined:
    Jun 29, 2012
    Messages:
    109
    Likes Received:
    46
    Occupation:
    Software Engineer
    If you were to do this on the client side with javascript it would be pretty simple - however, client side scripts can be circumvented and manipulated, so server side is the best but that requires that the form is submitted and processed. If you want a quick and dirty client side script, I found this on google: stackoverflow.com/questions/3279628/checking-the-form-field-values-before-submitting-that-page that does a good job showing you how to validate a form. With this method you wouldn't need to clear the captcha form for them to resubmit.
     
  3. thorjack1990

    thorjack1990 BANNED BANNED

    Joined:
    Feb 15, 2013
    Messages:
    71
    Likes Received:
    9
    how do u make a form reset? after submitting the form then i go back.,the form still has data on it.,i need to know the code to reset it when going back to prevent spammer.
     
  4. Lyscer

    Lyscer Junior Member

    Joined:
    Jun 29, 2012
    Messages:
    109
    Likes Received:
    46
    Occupation:
    Software Engineer
    What do you mean by "then I go back" like you submit it and then hit the back button? If that is the case then you could look at the referrer url (the page that sent you to your form). and if the referrer is your submit page then clear all the values out. If you google "javascript check referring url" you can see what I am referencing. Once again though, if they have javascript turned off then this will be pointless. If you are using PHP then you can check the referring url in the $_SERVER variable and if the isset($_SERVER['HTTP_REFERER']) and it is equal to your submit page then I would just do a header redirect to the same page to reload it which would effectively clear out all of the values in a couple lines of code. Good luck.