Hi folks,
I've written the following script but it goes into an endless loop and sends 100s of emails to the given address, can anybody tell me what's wrong with it?
Here's the code:
<?php
$to = "destination@address.com";
$subject = "subject line";
$body = "<font size=\"2\" face=\"tahoma\">" . $sender_enquiry . "<br><br>" . $sender_name . "<br>" . $sender_company . "<br><br>" . $sender_address ."<br>" . $sender_telephone . "</font>";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: $sender_name <$sender_email>\r\n";
mail($to,$subject,$body,$headers);
header("Location: " . $main_url . "?p=contact&action=thankyou");
?>
mail problem
Moderator: General Moderators
-
662Corporation
- Forum Newbie
- Posts: 5
- Joined: Thu Nov 21, 2002 5:20 am
- Location: Glasgow, UK
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Is this:
refreshing the same page? If so is there a test being run which ensures that the mail is not sent again if $_GET['action'] is equal to 'thankyou'?
Mac
Code: Select all
header("Location: " . $main_url . "?p=contact&action=thankyou");Mac
-
662Corporation
- Forum Newbie
- Posts: 5
- Joined: Thu Nov 21, 2002 5:20 am
- Location: Glasgow, UK
it's not meant to refresh the same page, the file is called contact.php which at no point comes up in the user's address bar
as far as the user can see the whole site is run off the index file using variables in the url eg. http://domain.com/index.php?p=services or http://domain.com/?p=contact
the header function above should send the user back to the index file along with the variables p=contact&action=thankyou
the mail function is contained in contact.php which is the action of the form on the contact page, i just basically want them redirected to a thank you page once they've submitted the form
i haven't bothered with any server side validation as it's all done with js before the form is submitted
as far as the user can see the whole site is run off the index file using variables in the url eg. http://domain.com/index.php?p=services or http://domain.com/?p=contact
the header function above should send the user back to the index file along with the variables p=contact&action=thankyou
the mail function is contained in contact.php which is the action of the form on the contact page, i just basically want them redirected to a thank you page once they've submitted the form
i haven't bothered with any server side validation as it's all done with js before the form is submitted
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
-
662Corporation
- Forum Newbie
- Posts: 5
- Joined: Thu Nov 21, 2002 5:20 am
- Location: Glasgow, UK
basically what happens (or should be happening anyway) is this:
1. user hits contact link and they're sent to http://domain.com/?p=contact
the form being submitted is included in the index page
2. they fill in the form with js validating it along the way and submit it
3. the form is sent to http://domain.com/contact.php which should simply just send the email and redirect to the given url
the only other code is the actual form which is using the POST method because the email message could get pretty long and i couldn't put that in the url
the .inc file which contains the form has an arguement in it asking whether action is true or not and just printing different bits of text to the page depending on the result but i can't see why that would be causing the loop
1. user hits contact link and they're sent to http://domain.com/?p=contact
the form being submitted is included in the index page
2. they fill in the form with js validating it along the way and submit it
3. the form is sent to http://domain.com/contact.php which should simply just send the email and redirect to the given url
the only other code is the actual form which is using the POST method because the email message could get pretty long and i couldn't put that in the url
the .inc file which contains the form has an arguement in it asking whether action is true or not and just printing different bits of text to the page depending on the result but i can't see why that would be causing the loop