SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    VICTORY IS MINE! luchazard's Avatar
    Join Date
    May 2001
    Location
    USA
    Posts
    229
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    help!! I'm stuck on something...

    I have the following form:

    <form action="taf.php" method="post>
    <input type="text" name="from_email">
    <input type="text" name="email_1">
    <input type="text" name="email_2">
    <input type="text" name="email_3">
    <input type="submit" name="submit">
    </form>

    In the PHP script 'taf.php' I want to make sure that all the email addresses are valid. Please tell me if what I have put down is correct!!
    PHP Code:
    function check_email ($from_email$email_1$email_2$email_3) {

    return (
    ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.'@'.'[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.'.'[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$',$from_email$email_1$email_2$email_3));

    }

    if (
    $submit) {

    if (! 
    check_email ($from_email) || ! check_email ($email_1) || ! check_email ($email_2) || ! check_email ($email_3))

    echo(
    "One of the email addresses you provided was invalid!"); 
    Could I make things easy by instead of having... email_1, email_2, and email_3 just name them all to_email?? So then I would just have $from_email and $to_email

  2. #2
    Victory shall be mine tubedogg's Avatar
    Join Date
    Mar 2001
    Location
    Medina, OH
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well for starters by requiring the variables $from_email, $email_1, $email_2, and $email_3 to be there, you are then calling your function incorrectly. You'd call it like this:

    PHP Code:
    if (!check_email($from_email,$email_1,$email_2,$email_3)) {
      echo 
    "One of the...";

    You could put them in an array but beyond that if you named them the same thing you'd just overwrite the value with each successive form input box.
    Kevin


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
  •