Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

validate php form on submit

cmps_getchcmps_getch Posts: 102Member
how do i go about validating that every field has something intered in it and if not rite when they hit the submit button it will pop up telling them what they need to enter?

Comments

  • Eraser9486Eraser9486 Posts: 32Member
    If you want to do it without refreshing the page, using popups - you probably want to do it in javascript, instead of php as php is a server-side language.

    : how do i go about validating that every field has something intered in it and if not rite when they hit the submit button it will pop up telling them what they need to enter?
    :

  • minhnguyena7minhnguyena7 Posts: 145Member
    : If you want to do it without refreshing the page, using popups - you probably want to do it in javascript, instead of php as php is a server-side language.
    :
    Nope, if you do it it javascript, your script is not secured. data may be messed if somebody means it.
    To do it in PHP, you should echo PHP variables rite on input feilds. While the form is not submited, they are null.
    once the form is submited, if there is one which is not valid, set it to empty or null. Then the output would still be empty. Now you can output the error ms to your users.
    Good luck
  • cmps_getchcmps_getch Posts: 102Member

    could u give me an example of this?


    : Nope, if you do it it javascript, your script is not secured. data may be messed if somebody means it.
    : To do it in PHP, you should echo PHP variables rite on input feilds. While the form is not submited, they are null.
    : once the form is submited, if there is one which is not valid, set it to empty or null. Then the output would still be empty. Now you can output the error ms to your users.
    : Good luck
    :

  • minhnguyena7minhnguyena7 Posts: 145Member
    [b][red]This message was edited by minhnguyena7 at 2006-9-22 8:21:52[/red][/b][hr]
    [code]

    Name :
    ">

    Address:
    ">

    City:
    ">


    <? // form validation here
    // create alert ms

    if (this_is_not_name($_GET['name']))
    {
    $name = ""; /// if name is not valid, set it to null
    $ERROR_MS = $ERROR_MS ."NAME IS NOT VALID ....
    ";
    $valid_form = false;
    }
    ?>
    <? if ($valid_form){ ?>

    window.alert("<? echo $ERROR_MS; ?> ");

    <? } ?>

    [/code]
Sign In or Register to comment.