How to write a function in a script so it can be used in other scripts in the program

Discussion in 'PHP' started by amedno1, May 2, 2010.

  1. #1
    Hello,

    I have a script called register.php

    What I want is to validate the email a user inputs and I want the register.php script to call a function email_valid() in validate_email.php to do the validation.

    The reason is because another user the web admin can also create new user accounts and he needs to enter an email which is also the username so I want to use that same function above in web_admin.php script to validate the email he enters.

    Any ideas how I go about doing that?

    Thanks
     
    amedno1, May 2, 2010 IP
  2. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #2
    create a file called functions.php, put the email validation routine in it. Use PHP's include or require_once statement in both of the other files and it will be available.
     
    shallowink, May 2, 2010 IP
    amedno1 likes this.
  3. amedno1

    amedno1 Active Member

    Messages:
    427
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    58
    #3
    ok thanks a lot for the reply your help is much appreciated
     
    amedno1, May 2, 2010 IP