Jump to content

Recommended Posts

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 by AP_King7
Link to comment
https://forums.phpfreaks.com/topic/290556-e-mail-php-process/
Share on other sites

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 by AP_King7
Link to comment
https://forums.phpfreaks.com/topic/290556-e-mail-php-process/#findComment-1488426
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/290556-e-mail-php-process/#findComment-1488430
Share on other sites

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.

 
 

 
 

Link to comment
https://forums.phpfreaks.com/topic/290556-e-mail-php-process/#findComment-1488433
Share on other sites

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';
Link to comment
https://forums.phpfreaks.com/topic/290556-e-mail-php-process/#findComment-1488436
Share on other sites

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.
Link to comment
https://forums.phpfreaks.com/topic/290556-e-mail-php-process/#findComment-1488439
Share on other sites

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?

Link to comment
https://forums.phpfreaks.com/topic/290556-e-mail-php-process/#findComment-1488459
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.