SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2007
    Location
    San Jose
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Form processing using Swiftmailer - can't get success page to show

    Hello,

    I'm using Swiftmailer to execute a simple form. Right now the form works as I want to, however after submitting the form I get a warning message in a blank page instead of the success page.

    PHP Code:
    WarningCannot modify header information headers already sent by (output started at /home/jiam1234/public_html/extras/sendform.php:1in /home/jiam1234/public_html/extras/sendform.php on line 167 
    I have a form page and the following processing file:

    PHP Code:
    <?php
    $toemailprov 
    $_POST['toemailprov'];
    $nomprov $_POST['nomprov'];
    $email $_POST['email'];
    $diaev $_POST['diaev'];
    $mesev $_POST['mesev'];
    $anoev $_POST['anoev'];
    $horaini $_POST['horaini'];
    $horafin $_POST['horafin'];
    $adult $_POST['adult'];
    $kids $_POST['kids'];                    

    require_once 
    '../lib/swift_required.php';
    $transport Swift_SmtpTransport::newInstance('mail.domain.com'26)
      ->
    setUsername('quotes+domain.com')
      ->
    setPassword('*****')
      ;
    $mailer Swift_Mailer::newInstance($transport);
    $message Swift_Message::newInstance()
      ->
    setSubject('Request')
      ->
    setFrom(array('info@domain.com' => 'Domain.com'))
      ->
    setTo(array($toemailprov'joe@yahoo.com' => 'Joe'))
      ->
    setBody('Message text''text/plain')
      ->
    addPart('<p>message text</p>''text/html')
      ;                
    $result $mailer->send($message);
     
    if (
    $result)
        {
        
    header("Location: http://www.domain.com/thankyou.php"); //this is line 167
        
    exit;
        }
    ?>
    It is my understanding that I'm sending header information after sending data to the browser. I am not sure how to fix this. Am I missing something?

    Thanks in advance for any help.

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Are there any spaces before the <?php in the file? What about in the swift_required.php file? That would cause it.

  3. #3
    SitePoint Enthusiast
    Join Date
    Sep 2007
    Location
    San Jose
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dan,

    Thanks for your reply. I forgot to mention I had already checked for blank spaces before <?php.

    Hadn't checked the swift_required.php file, but it doesn't have any spaces before the <?php either.

    PHP Code:
    [HIGHLIGHT="PHP"]<?php
    /*
     Autoloader and dependency injection initialization for Swift Mailer.
     
     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation, either version 3 of the License, or
     (at your option) any later version.
     
     This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.

     You should have received a copy of the GNU General Public License
     along with this program.  If not, see <http://www.gnu.org/licenses/>.

     */
    //Indicate where Swift Mailer lib is found
    defined('SWIFT_LIB_DIRECTORY')
      or 
    define('SWIFT_LIB_DIRECTORY'dirname(__FILE__));
    //Path to classes inside lib
    define('SWIFT_CLASS_DIRECTORY'SWIFT_LIB_DIRECTORY '/classes');
    //Load Swift utility class
    require_once SWIFT_CLASS_DIRECTORY '/Swift.php';
    //Start the autoloader
    Swift::registerAutoload();
    //Load the init script to set up dependency injection
    require_once SWIFT_LIB_DIRECTORY '/swift_init.php';[/HIGHLIGHT]
    I haven't changed any of the original Swiftmailer files. Could there be something there I'm missing? (as I mentioned, the emails are being sent without any problem so I hadn't thought of this possibility)

  4. #4
    play of mind Ernie1's Avatar
    Join Date
    Sep 2005
    Posts
    1,252
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    enable error reporting:
    PHP Code:
    <?php
    ini_set
    ("display_errors"1);
    error_reporting(E_ALL);
    the error in the include file could be treated as output
    my mobile portal
    ghiris.ro

  5. #5
    SitePoint Enthusiast
    Join Date
    Sep 2007
    Location
    San Jose
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ernie1: Thanks for the advice. I enabled error reporting as instructed however got no error messages.


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
  •