AP_King7 Posted August 20, 2014 Share Posted August 20, 2014 (edited) I have a full working order form in PHP. I process it and display it with a process page called "process.php." Whenever this information is displayed on the web page "process.php" I also want it to send me an e-mail with all of the information that it just processed. i.e. Checked checkboxes, text entered, etc. Whenever I try to send the contents of "process.php" to an email $message = include 'process.php'; the process page just goes through an infinite loop displaying itself over and over again instead of sending itself in an email. Edited August 20, 2014 by AP_King7 Quote Link to comment https://forums.phpfreaks.com/topic/290556-e-mail-php-process/ Share on other sites More sharing options...
cyberRobot Posted August 20, 2014 Share Posted August 20, 2014 What does your code look like? And perhaps you already know this, but please surround the code with tags when posting to this forum. It will make your post easier to read. Quote Link to comment https://forums.phpfreaks.com/topic/290556-e-mail-php-process/#findComment-1488419 Share on other sites More sharing options...
AP_King7 Posted August 20, 2014 Author Share Posted August 20, 2014 (edited) Thank you. I was not aware, this is my first post. Here is a very small portion of one of the pages with forms and the process page the displays the values on /process.php. I want it to send everything that it displays to the email as well when the data is processed. <form action="process.php" method="post"> Number<input type="text" name="tPerson" value="0" maxlength="2" size="1"> <input type="hidden" name="Trad" value="Trad" /> <h4>Choose 2 </h4> <input type="checkbox" name="tMeat[]" value="Hamburgers" /> Hamburgers <?php echo($_POST['Trad']); ?> for <?php echo $_POST["tPerson"]; ?>.<h3> <h4>Selection:</h4> <p /> <?php $aMeat = $_POST['tMeat']; if(empty($aMeat)) { echo("You didn't select any meats."); } else { $N = count($aMeat); echo("You ordered $N meat(s): "); for($i=0; $i < $N; $i++) { echo($aMeat[$i] . " - "); } } ?> $email_to = "email@email.com"; $email_subject = "Order Confirmation"; $message = include 'process.php'; Edited August 20, 2014 by AP_King7 Quote Link to comment https://forums.phpfreaks.com/topic/290556-e-mail-php-process/#findComment-1488426 Share on other sites More sharing options...
BuildMyWeb Posted August 20, 2014 Share Posted August 20, 2014 youre going to have to be a little clearer with your code for us to help. i dont know what youre showing us here. it sounds like youre saying everything after the opening <?php tag is in your process.php file but if that is the case, why are you including it below? that would explain your loop. please label better somehow, like this: form.html file: <form action="process.php" method="post"> Number<input type="text" name="tPerson" value="0" maxlength="2" size="1"> ..... process.php file: <?php echo($_POST['Trad']); ..... you are also assigning the included file to a variable. this will only return the value of the included file. which im guessing is NULL if you did not return a value correctly. your variables at the bottom of the page are also outside of php tags. Quote Link to comment https://forums.phpfreaks.com/topic/290556-e-mail-php-process/#findComment-1488430 Share on other sites More sharing options...
AP_King7 Posted August 20, 2014 Author Share Posted August 20, 2014 I tried to split the code like that and it didn't work. It just didn't post my second piece of code. Like I said, this is obviously not anywhere near all of the code. My code is just for an example for you guys to go off of. I understand how to send an e-mail with text and have done it successfully in this code. I can also send a separate page to an e-mail. But when I try to send the page that the code is within it doesn't send an e-mail at all. It just displays it at the bottom of the page infinitely. For instance if I use $message = "Test" it sends fine. When I use $message = include 'process.php'; it doesn't send a message. It just displays it infinitely on the web page. I want to somehow capture the data that process.php is displaying and send it to an email when process.php is ran from the other pages. Quote Link to comment https://forums.phpfreaks.com/topic/290556-e-mail-php-process/#findComment-1488433 Share on other sites More sharing options...
AP_King7 Posted August 20, 2014 Author Share Posted August 20, 2014 If I need to tackle this a completely different way I definitely will, this is just the only way I have found to try to send a confirmation email with all of the data entered in the forms on the previous page. Quote Link to comment https://forums.phpfreaks.com/topic/290556-e-mail-php-process/#findComment-1488435 Share on other sites More sharing options...
cyberRobot Posted August 20, 2014 Share Posted August 20, 2014 I tried to split the code like that and it didn't work. It just didn't post my second piece of code. This forum seems to have an issue when posting multiple blocks. To get around this issue, I usually need to clicking the "More Reply Options" button instead of Post. At times I also need to click the "Preview Post" button after clicking "More Reply Options" for the extra code blocks to appear. As for your code, is your script including itself? $message = include 'process.php'; Quote Link to comment https://forums.phpfreaks.com/topic/290556-e-mail-php-process/#findComment-1488436 Share on other sites More sharing options...
AP_King7 Posted August 20, 2014 Author Share Posted August 20, 2014 It did but I have separated the pages and made a confirm button at the bottom of "process.php" that will run "process2.php" which will e-mail the information from "process.php." However when I use $message = include 'process.php'; it doesn't put the web page in the e-mail. It just displays "process.php" on top of the "process2.php" page. Quote Link to comment https://forums.phpfreaks.com/topic/290556-e-mail-php-process/#findComment-1488439 Share on other sites More sharing options...
AP_King7 Posted August 20, 2014 Author Share Posted August 20, 2014 It's displaying the web page on top of itself and e-mailing me the number "1" for some reason. Quote Link to comment https://forums.phpfreaks.com/topic/290556-e-mail-php-process/#findComment-1488441 Share on other sites More sharing options...
BuildMyWeb Posted August 20, 2014 Share Posted August 20, 2014 i believe its emailing you the number 1 because its returning a boolean value. again, if you set your $message var to the included file, and you want a message to be emailed instead of that true/boolean value, RETURN the message from process.php that being said, this sounds like a circumlocutional way to achieve your ends.. do you need to set the included file to a variable? cant you just include the file and assign $message within it? Quote Link to comment https://forums.phpfreaks.com/topic/290556-e-mail-php-process/#findComment-1488459 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.