Page 1 of 1

Email Script

Posted: Thu Jan 19, 2006 3:31 pm
by xeonman13
Hello All,
Im new here. ANd Im very happy I found this forum.
Hopefully you can help me.

I have a script that sends an email, its a trouble ticket system and it sends me an email when a new ticket is created.

The problem im having is that constantly, i get blank emails from the script, which means someone is just running the .php page that sends the email without the form prior to it. or maybe a crawler or something?

Is there something I can put on the page that sends the email that will not allow it to process unless there is information? or at least to validate that the only way it will continue is if it was redirected from the form page?

Any ideas?

Here is the page that sends the email.

Code: Select all

<?php
$to = "emailaddress"\r\n";
$re = "Ticket Updated by Customer # $ticketid";

$From = "From: techsupport@techsupport.com\r\n";
$body = <<< emailbody

Dear Technician.

An update has been posted to a ticket, # $ticketid
The customer wrote
$comment

If this update requires a response from you, please go to the support site and reply.
----------------------------------------------------
Sincerely,
Tech Support




emailbody;
$success = mail($to,$re,$body,$From);
	
?>

Posted: Thu Jan 19, 2006 4:35 pm
by matthijs
And how does the code with the form look like? How and were does the data come from?

Normally receiving data goes like:

Code: Select all

<?php
if (isset($_POST['submit'])
{


// process data ....


}
else
{
?>
html for form
<?php
}
?>

Posted: Thu Jan 19, 2006 4:47 pm
by neophyte
Place a unique identifier (token) in a hidden field in the form. Place the same token in their browser. When the page loads do a comparison if the cookies are the same then show the form, if not send them to a different page. If they complete the form correctly, clear the one time cookie some time after the mail is sent? Sound good? The only thing better than that that I am aware of is a confirmation code that the end user enters.