SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Sep 2001
    Location
    St. Louis, MO
    Posts
    212
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Beginning php mail problem

    Hi,

    Can anyone tell me why the message of the email sent shows up as $input_array[$i] instead of looping through it and printing its contents instead? I gotta be missing something real obvious.

    PHP Code:
    <html>
    <head></head>
    <body>
    <?php
    $recipients 
    = array('robstl70@home.com''crf36@home.com');
    $subject 'send multiple urls';
    $additional_headers "From: $email\n";
    $input_array = array('$url_one','$url_two','$url_three');

    if(
    $action == "sendmail")
    {
      
    $size count($recipients);
      for(
    $i 0$i $size$i++)
      {
        
    $url_count count($input_array);
        for(
    $i 0$i $url_count$i++)
        {
        
    $body_of_email '$input_array[$i]'
          if(
    ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)"$recipients[$i]))
          { 
            if(
    mail($recipients[$i], $subject$body_of_email$additional_headers))
            {
              print(
    "<br />Mail successfully sent to $recipients[$i]");
            }
            else
            {
              print(
    "<br />Something didn\'t work right, error on $recipients[$i]");
            }
          }
    //end validation if statement    
          
    else
          {
            print(
    "<br />It appears your email: $recipients[$i] is not in the correct format, please try again.");
          }
        }
    // end first for loop
      
    }// end second for loop
    }// end beginning if statement
    else
    {
    ?>
    <form METHOD=POST action="<? $PHP_SELF ?>">
    <input type="hidden" name="action" value="sendmail">
    Name: <input type="text" name="name" size="25" maxlength="40">
    <br>
    Your Email: <input type="text" name="email" size=40 maxlength="40">
    <br>
    URL One: <input type="text" name="url_one">
    <br>
    URL Two: <input type="text" name="url_two">
    <br>
    URL Three: <input type="text" name="url_three">
    <br>
    <input type="submit" value="Submit">
    </form>
    <?php
    }
    ?>
    </body>
    </html>
    Thanks,
    Rob

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Variables inside single quotes don't get parsed.

    Use
    PHP Code:
    $body_of_email "$input_array[$i]"
    or preferably

    PHP Code:
    $body_of_email $input_array[$i]; 

    http://www.php.net/manual/en/language.variables.php
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Addict
    Join Date
    Sep 2001
    Location
    St. Louis, MO
    Posts
    212
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Freddy...I knew it was something like that.

    I'm learning.

    Cheers,
    Rob


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
  •