PDA

View Full Version : Background sending of php mail



titanite
02-26-2006, 12:32 PM
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??

Pixelcode
02-26-2006, 02:27 PM
If you merge both pages so that after the information is entered into the database the email is send afterwards:

Pseudo code:
IF SUBMIT CLICKED
ENTER EVENT INTO MYSQL DATABASE
SEND EMAIL
:)

titanite
02-27-2006, 06:59 AM
If you merge both pages so that after the information is entered into the database the email is send afterwards:

Pseudo code:
IF SUBMIT CLICKED
ENTER EVENT INTO MYSQL DATABASE
SEND EMAIL
:)

Hi! Thanks for your reply!! May I know what I should put?
- 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">
</form>

My only solution is to put if event is sucessfully submitted, then the mail.php would be run, bow 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";
}
?>

Pixelcode
02-27-2006, 04:04 PM
event.php


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

eventdata.php



if($_POST['Submit']){ //if submit is clicked
//check data
if ($eventsent) {
//enter data into mysql
include_once("mail.php"); //run mail.php
echo "The submission has been successful.";
}else {
echo "There was an error sending this data. <a href=\"#\" onclick=\"javascipt:history.go(-1)\">Please retry.</a>";
}
}



:)