SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Evangelist jazztie's Avatar
    Join Date
    Mar 2001
    Location
    the Netherlands
    Posts
    519
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    passing on an Array

    I have a problem with a mail-wizard.

    Say I have three pages in the wizard:
    1. select recipients from a list thru checkboxes
    These recipients are passed on as $recipients

    2. write the email (subject, message)
    This is passed on as $subject, $message and the $recipients as a hidden field in the form <input type=hidden name='recipients' value='$recipients'>

    3. the actual mailer-page.
    Which needs $subject, $message and $recipients

    On the last page I get strange errors because it can't read the $recipients anymore. All it writes is 'Array'. And that's it. How do I pass on my Array completely so it can be read thru out the mail-wizard?

    I can print $recipients in the second window (foreach statement), but I can't print it in the third window. I've also tried to pass it on as <input type=hidden name='recipients[]' value='$recipients'>

    Please advise,
    Jazz

  2. #2
    SitePoint Wizard gold trophysilver trophy
    Join Date
    Nov 2000
    Location
    Switzerland
    Posts
    2,479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    After $recipients has been posted, to break it up into a string of email addresses seperated by commas you could try;

    $recipients = explode(",", $recipients);

    Alternatively;

    foreach ( $repients as $recipient )
    {
    echo ( $recipient . "," );
    }

    To write each element of the array.

  3. #3
    SitePoint Evangelist jazztie's Avatar
    Join Date
    Mar 2001
    Location
    the Netherlands
    Posts
    519
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I know how to break it up...
    Like it read in the first message, I'm already using the for each statement. However, this gives the error.

    My question remains:
    in the second window the $recipients is still valid and can be used in a for each statement... however, when I post it to the third window: php won't let me use it.

    What can be done about this?

  4. #4
    SitePoint Evangelist jazztie's Avatar
    Join Date
    Mar 2001
    Location
    the Netherlands
    Posts
    519
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Please, what should I do?

    Is it impossible to pass an Array over multiple pages?
    An array stays an array, doesn't it?

    Please advise

  5. #5
    SitePoint Evangelist ucahg's Avatar
    Join Date
    Apr 2001
    Location
    Sarnia, Ontario, Canada
    Posts
    434
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You either need to use a foreach statement to give each recipient it's own hidden input, or on the second page you need to make the reciepients one variable seperated by commas, and on the third page, explode it back into an array (what Harry said).

  6. #6
    SitePoint Evangelist jazztie's Avatar
    Join Date
    Mar 2001
    Location
    the Netherlands
    Posts
    519
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks UCAHG and HarryF,

    that did seem to work...
    sorry for being an *ss to you Harry, it seems like you were right to begin with.

    Jazz


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
  •