Results 1 to 1 of 1

Thread: Function Parameters problems

  1. #1
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default Function Parameters problems

    I just wrote this validation script for my site using functions. I just learned how to use parameters which means I might have made some error that many first timers usually make when learning new stuff.

    Here is the code...
    PHP Code:
    function validateInput($content$inputlabelname$inputidname$max$min$style$type$extravalidation){
    if(
    strlen($content)<$max && strlen($content)>$min){
    echo 
    '<label>' $content '</label>';
    }
    else
    {
    echo 
    '<label>Retype your ' $inputlabelname ':</label>';
    echo 
    '<input type="' $type '" id="' $inputidname '" style="' $style '"/>';
    }
    }
    //End of function
    if(isset($_POST['firstname'])){
    $value htmlspecialchars($_POST['firstname']);
    validateInput($value,"First Name","firstname",30,2,"width: 75px\;","text",FALSE);
    }
    else
    {
    echo 
    'YOU FORGOT YOUR NAME!  2 points off...';

    Thanks!
    I forgot to set the name attribute in the input tags... Silly me!
    Last edited by Rockonmetal; 12-13-2008 at 02:32 AM.

Bookmarks

Posting Permissions

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