SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2005
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy isNan() not defined???

    Hi Everyone

    I am getting this error message when I run the code. Call to undefined function isNaN()
    PHP Code:
    // Get the clients personal information from the form
    $fname=$_POST['fname'];
    $lname=$_POST['lname'];
    $paddress=$_POST['paddress'];
    $city=$_POST['city'];
    $pcode=$_POST['pcode'];
    $email=$_POST['email'];
    $teleno=$_POST['teleno'];

    //Check the data is valid
    if(!validform($fname, $lname, $paddress, $city, $email))
        exit;

    // Set the mail variables
    $emailaddress = 'info@karamuquilting.co.nz';
    $fromaddress = 'website@karamuquilting.co.nz';
    $subject = 'Request for more Karamu quilting info';

    // Format the body of the email message
    $content = 'Name: '.$fname.' '.$lname."\n"
                     .'Address: '.$paddress."\n"
                     .'City: '.$city."\n"
                     .'Postal Code: '.$pcode."\n"
                     .'Telephone Number: '.$teleno;

    // Send the email
    mail($emailaddress, $subject, $content, $fromaddress);

    header("Location:  http://www.karamuquilting.co.nz/thankyou.php");

    // Function:       validform
    // Purpose:        To validate the form data
    // Parameters:     Form values submitted on previous page
    // Return value:   Boolean, true if data valid, false otherwise
    function validform($fname, $lname, $paddress, $city, $email)
    {
        if ($fname=="" ||!isNaN($fname))
        {
           echo "Please enter your first name";
                  return false;
        }
        elseif ($lname==""||!isNaN($lname))
        {
           echo "Please enter your last name";
           return false;
        }
        elseif ($paddress==""|| $city=="")
        {
           echo "Please enter your postal address, including suburb and city";
           return false;
        }
        elseif (!eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\_]+\.[a-zA-Z0-9\-\.]+$", $email))
        {
           echo "The email address you have entered in not valid";
           return false;

        }
        return true;
    }

    ?>

    <?php

    // Get the clients personal information from the form
    $fname=$_POST['fname'];
    $lname=$_POST['lname'];
    $paddress=$_POST['paddress'];
    $city=$_POST['city'];
    $pcode=$_POST['pcode'];
    $email=$_POST['email'];
    $teleno=$_POST['teleno'];

    //Check the data is valid
    if(!validform($fname$lname$paddress$city$email))
        exit;

    // Set the mail variables
    $emailaddress 'info@karamuquilting.co.nz';
    $fromaddress 'website@karamuquilting.co.nz';
    $subject 'Request for more Karamu quilting info';

    // Format the body of the email message
    $content 'Name: '.$fname.' '.$lname."\n"
                     
    .'Address: '.$paddress."\n"
                     
    .'City: '.$city."\n"
                     
    .'Postal Code: '.$pcode."\n"
                     
    .'Telephone Number: '.$teleno;

    // Send the email
    mail($emailaddress$subject$content$fromaddress);

    header("Location:  http://www.karamuquilting.co.nz/thankyou.php");

    // Function:       validform
    // Purpose:        To validate the form data
    // Parameters:     Form values submitted on previous page
    // Return value:   Boolean, true if data valid, false otherwise
    function validform($fname$lname$paddress$city$email)
    {
        if (
    $fname=="" ||!isNaN($fname))
        {
           echo 
    "Please enter your first name";
                  return 
    false;
        }
        elseif (
    $lname==""||!isNaN($lname))
        {
           echo 
    "Please enter your last name";
           return 
    false;
        }
        elseif (
    $paddress==""|| $city=="")
        {
           echo 
    "Please enter your postal address, including suburb and city";
           return 
    false;
        }
        elseif (!
    eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\_]+\.[a-zA-Z0-9\-\.]+$"$email))
        {
           echo 
    "The email address you have entered in not valid";
           return 
    false;

        }
        return 
    true;
    }

    ?>
    Last edited by stymiee; Sep 29, 2006 at 18:34.

  2. #2
    SitePoint Enthusiast
    Join Date
    Jan 2006
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's because there is no such thing as an isNan function in your code yet you are trying to call it.

    if ($fname=="" ||!isNaN($fname))
    ...
    elseif ($lname==""||!isNaN($lname))
    ...

  3. #3
    SitePoint Zealot whytewolf's Avatar
    Join Date
    Mar 2006
    Location
    montana
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is_nan is the PHP version of such a function

  4. #4
    SitePoint Wizard lorenw's Avatar
    Join Date
    Feb 2005
    Location
    was rainy Oregon now sunny Florida
    Posts
    1,104
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    whytewolf is correct, change is_NaN to is_nan and it should get rid of your error.


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
  •