Validation Script help

Discussion in 'PHP' started by Kyle King, Jun 11, 2013.

  1. #1
    I have written a validation script that has sessions in the header file to keep data in the fields if there is any incorrect info in the form. The issue that I am having is upon successful submission the form will first post a blank entry in the database, then one with all of the info, and then another blank one. I have looked through the code multiple times and am not sure what is causing the issue.

    It also appears that when validation fails, the form still submits a set of blank info into the database.

    http://pastebin.com/UKq7q1GM

    Could someone please point me in the right direction?
     
    Solved! View solution.
    Last edited: Jun 12, 2013
    Kyle King, Jun 11, 2013 IP
  2. sorindsd

    sorindsd Well-Known Member

    Messages:
    201
    Likes Received:
    3
    Best Answers:
    2
    Trophy Points:
    118
    #2
    The condition from line 6 is not good and the script is executed every time
     
    sorindsd, Jun 12, 2013 IP
  3. Kyle King

    Kyle King Member

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    31
    #3
    I see. Should I change it to $_POST or remove it all together? Or does it need an else added to it?


    I did find errors in the validation checking part, where $aFailureNotices = array has the output for errors, some in there aren't in the $aFilters = array area
     
    Last edited: Jun 12, 2013
    Kyle King, Jun 12, 2013 IP
  4. #4
    You can try: if(isset($_POST))
     
    sorindsd, Jun 12, 2013 IP
  5. Kyle King

    Kyle King Member

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    31
    #5
    I changed it to if (count($_POST) <= 0) and now it seems to be working perfectly. I don't think I would have figured it out if you didn't point it out to me! Thank you very much!
     
    Kyle King, Jun 12, 2013 IP