Results 1 to 7 of 7

Thread: Fields!

  1. #1
    Join Date
    Dec 2004
    Posts
    258

    Fields!

    Hi folks! I have *.phtml file, that I use for sending order from server to e-mail.
    How to do, that in my html-form some fileds was obligatory for filling???

    Thanks!

  2. #2
    Join Date
    Mar 2004
    Posts
    1,468
    Are you wanting it to say "this field is required" right when they press submit, or after they submit, and it brings them to the page and says it?

    If you want to do it right then, you need javascript.
    http://support.internetconnection.ne...d_Fields.shtml

    If you phtml page is in PHP, then something like this...
    PHP Code:
    <?php

    if ( $fielda==""){
    print 
    "Please fill out Field A";
    // something so it doesnt finish the task
    }
    ?>
    Just something to get the general point across.

    Hope my little bit helps,
    Jason
    Haven't been on WHT for 6 years!

  3. #3
    Join Date
    Dec 2004
    Posts
    258
    Originally posted by jasong
    [B]Are you wanting it to say "this field is required" right when they press submit, or after they submit, and it brings them to the page and says it?

    If you want to do it right then, you need javascript.
    http://support.internetconnection.ne...d_Fields.shtml
    Thanks! It was I nedeed!

  4. #4
    Join Date
    Dec 2004
    Posts
    258
    Originally posted by jasong
    Are you wanting it to say "this field is required" right when they press submit, or after they submit, and it brings them to the page and says it?

    If you want to do it right then, you need javascript.
    http://support.internetconnection.ne...d_Fields.shtml
    How to do in tha Java script, that he read not "name", but "value". It's possible?

  5. #5
    Join Date
    Feb 2005
    Location
    Seattle, Washington
    Posts
    144
    DO NOT RELY ON JAVASCRIPT FOR FORM VALIDATION.

    Many people do not even have javascript enabled, and you could also just send the request via telnet, all javascript would be ignored. You cannot rely on javascript for security. Don't get me wrong, javascript validation is a handy tool, and can make for a better interface, but you can't depend on it for security. It is OK to add for the user interface, infact it is very nice if you do, but make sure you have server side validation.

    Validate everything in your PHP code.
    PHP Code:
    if (!isset($_POST['field_name'])) {
        die(
    'you must enter a value.');

    or something along those lines.
    Regards,
    Matthew Fonda
    PHP Developer

  6. #6
    Join Date
    Jul 2003
    Location
    Kuwait
    Posts
    5,099
    PHP Code:
    if (strlen(trim($_POST['fieldname'])) == 0) { /* error */ 
    That is what I would recommend.
    In order to understand recursion, one must first understand recursion.
    If you feel like it, you can read my blog
    Signal > Noise

  7. #7
    Join Date
    Dec 2004
    Posts
    258
    Originally posted by fyrestrtr
    PHP Code:
    if (strlen(trim($_POST['fieldname'])) == 0) { /* error */ 
    That is what I would recommend.
    Hi! Here script! Please tell me it's will work here?

    <?
    $fText="$fTitle\n\n";
    for ($i=1;$i<=$fCount;$i++) {$fText.=$fName[$i].": ".$fData[$i]."\n";}
    $fText.="\n\n";
    $fText.=date("l dS of F Y h:i A");
    if (mail($fMail,$fSubject,$fText)) {Header("Location: $fOk");}
    else {Header("Location: $fBad");}
    exit;
    ?>

Posting Permissions

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