Background sending of php mail

Discussion in 'PHP' started by Titanite, Feb 26, 2006.

  1. #1
    Hi guys,

    I'm new to all this so I really need some advice!!

    I am doing up a data entry page for events, by clicking on 'submit', the data will be uploaded into the mysql database. All this poses no problem, but I need to create a php mail (mail.php) that upon clicking on 'submit' (events.php), an email will be sent to a colleague to tell her to go to this admin page which I have done up for her to approve or disapprove the event submission.

    As far as I know, 'submit' is only for the event form and not for the mail.php. But it would be stupid to put two buttons on the events.php...

    What should I do??
     
    Titanite, Feb 26, 2006 IP
  2. Ilija Studen

    Ilija Studen Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You should move code for sending emails to be part of add event routine. Mail is sent on successfull insert... Simple as that.
     
    Ilija Studen, Feb 26, 2006 IP
  3. Titanite

    Titanite Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi! Thanks for your reply!! May I know what I should put? Let's say the mail function is in mail.php, how do I run the mail.php in this?

    if ($mailsent) {
    echo "The submission has been successful.";
    }
    else {
    echo "There was an error sending this data. Please retry";
    }
    ?>
     
    Titanite, Feb 26, 2006 IP
  4. noppid

    noppid gunnin' for the quota

    Messages:
    4,246
    Likes Received:
    232
    Best Answers:
    0
    Trophy Points:
    135
    #4
    noppid, Feb 26, 2006 IP
  5. Titanite

    Titanite Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hi I think I may not have made myself quite understandable:
    I have the following files:
    - event.php: the form
    - eventdata.php: the php file to insert info into the database
    - mail.php: contains mail() to send email reminder.

    Imagine an html form on event.php, and the submit button is only for submitting the info on the event, not for processing mail.php...

    <form method="POST" action="eventdata.php">
    blah blah blah event details....
    <input type=" submit " value=" Submit ">


    My only solution is to put "if event is sucessfully submitted, then the mail.php would be run", but WHERE and HOW do I do it in the following? Can someone help me with the code?

    if ($eventsent) {
    echo "The submission has been successful.";
    }
    else {
    echo "There was an error sending this data. Please retry";
    }
    ?>

    Help!!! :(
     
    Titanite, Feb 27, 2006 IP
  6. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #6
    if ($eventsent) {
    echo "The submission has been successful.";
    include("mail.php");
    }
    else {
    echo "There was an error sending this data. Please retry";
    }
    PHP:
     
    mad4, Feb 27, 2006 IP
  7. Titanite

    Titanite Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Thanks Mad4!! I'll go try it out!! :))) Will tell you about the results later!! :D
     
    Titanite, Feb 27, 2006 IP