简体   繁体   中英

Change web page to email and send

I have a problem atm and I have searched the internet thoroughly, but I couldn't find the solution.

I want to send a form via email. I want the entire page that is generated being send by email. atm I have this code:

<input name="email" type="button" onClick="javascript:location='mailto:test@hotmail.com?subject=Really Cool Website&body=test'"  value= "mail">

This allows me to send me an email to a preset email adress and with a subject. the body will say test. But I seem not to be able to send the entire page. There are more things missing atm, but my html/php is a bit rusty atm. It will be a delivery form for a restaurant. Link to restaurants site for reference It misses a lot of features atm, but i am working on that. Does anyone know how to be able to send the page via email.

thanks in advance! the entire code is written below.

Jasper

<html>
<body> 
<form>
<div>            
      <table width="900" border="0" cellspacing="0" cellpadding="0" class="content">
          <tr>
            <td width="140"><strong>Selecteer hoeveel porties:</strong><br><hr></td>
            <td width="572"><strong>Beschrijving</strong><br><br><hr></td>
            <td width="112"><strong>Prijs</strong><br><br><hr></td>
            <td width="76"><strong>Totaalprijs</strong><br><br><hr></td>
        </tr>
          <tr>
            <td><?php include('optie.php');?></td>
            <td><strong>3-gangen traiteurmenu</strong><br>
                (incl. brood en boter)<br>******<br>
                Creme van gerookte paling<br>******<br>
                Gestoofde hertensukade met aardappelgratin, rodekool en een stoofpeertje.<br>******<br>
                Kerstbal van witte en pure chocolade en een vanillesaus.<br><hr>
                </td>
            <td>&euro;16,50</td>
            <td>&euro;</td>
        </tr>
          <tr>
            <td><?php include('optie.php');?></td>
            <td><strong>Extra voorgerecht</strong><br>
                Gerookte eendenborstfilet met een rilette van eend en een mangochutney.<br></td>
            <td>&euro;5,--</td>
            <td>&euro;</td>
        </tr>
          <tr>
            <td><?php include('optie.php');?></td>
            <td><strong>Extra tussengerecht</strong><br>
                Gamba's geserveerd in een saus van ....?<br><hr></td>
            <td>&euro;5,--</td>
            <td>&euro;</td>
        </tr>
          <tr>
            <td><strong>Diversen</strong></td>
            <td></td>
            <td></td>
            <td></td>

        </tr>
          <tr>
            <td><?php include('optie.php');?></td>
            <td>Graved laks met een mosterd-dillesaus</td>
            <td>&euro;....... per 100 gram</td>
            <td>&euro;</td>
        </tr>
        <tr>
            <td><?php include('optie.php');?></td>
            <td>Kreeftensoep</td>
            <td>&euro;8.95 per 0,5L</td>
            <td>&euro;</td>
        </tr>
        <tr>
            <td><?php include('optie.php');?></td>
            <td>Wildpeper</td>
            <td>&euro;2.35 per 100 gram</td>
            <td>&euro;</td>
        </tr>
        <tr>
            <td><?php include('optie.php');?></td>
            <td>Aardappelgratin</td>
            <td>&euro;2.95</td>
            <td>&euro;</td>
        </tr>
        <tr>
            <td><?php include('optie.php');?></td>
            <td>Rodekool</td>
            <td>&euro;3.95</td>
            <td>&euro;</td>
        </tr>
        <tr>
            <td><?php include('optie.php');?></td>
            <td>Botersaus</td>
            <td>&euro;4,50 per 250 ml.</td>
            <td>&euro;</td>
        </tr>
        <tr>
            <td><?php include('optie.php');?></td>
            <td>Rode portsaus</td>
            <td>&euro;3.95 per 250 ml.</td>
            <td>&euro;</td>
        </tr>
        <tr>
            <td><?php include('optie.php');?></td>
            <td>aangepaste wijnen per fles</td>
            <td>&euro;....... per fles</td>
            <td>&euro;</td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td><strong>Totaal prijs:</strong></td>
            <td><strong>&euro;</strong></td>
        </tr>


        <tr>
            <td><strong>Bestellen:</strong></td><td><br>
                U kunt uitsluitend bestellen door middel van ons bestelformulier.
                Uiterlijk voor maandag 17 december inleveren. </td>            
        </tr>
        <tr>
         <td><strong>Afhalen:</strong><br></td>
        </tr>
        <tr>
            <td></td><td> <input type="checkbox" name="option1" value="24 december 12.00-13.00 uur"> 24 december 12.00-13.00 uur</td>
        </tr>
        <tr>            
            <td></td><td> <input type="checkbox" name="option2" value="25 december 12.00-13.00 uur"> 25 december 12.00-13.00 uur</td>
        </tr>
        <tr>            
            <td></td><td> <input type="checkbox" name="option3" value="26 december 12.00-13.00 uur"> 26 december 12.00-13.00 uur<br><br></td>
        </tr>
        <tr>
        <td><strong> Betaling:</strong><br><br><br></td>
        <td>U kunt betalen met pin of contant.<br><br><br></td>
        </tr>
        <tr> 
        <td><strong>Printen</strong></td>
        <td><input type="button" onClick="window.print()" value="Print"/></td>
        <td></td>

        <td>
            <input name="email" type="button" onClick="javascript:location='mailto:test@hotmail.com?subject=Really Cool Website&body=test'"  value= "mail"></td>
  </table>
  </form>


<a href="mailto:coloriteman@gmail.com"></a>
    </div>


</div>
</body>
</html>

Question is tagged with PHP - but there's PHP code and nothing relevant to PHP in the question.

onClick="javascript:location='mailto:test@hotmail.com?subject=Really Cool Website&body=test'"

Why use a javascript call to invoke a redirect when you could have just used an a href='mailto:...'?

The most likely reason it's not working is that you've not encoded the value for 'body' correctly. If it's coming from PHP, then it should be URLencoded . If it's from Javacript, then use encodeURIComponent . You should be applying the other paramters too - it's pretty much by chance that the browser is able to handle the spaces in the subject.

Not all MUAs are created equal - and there sometimes are constraints on the amount of data you can pass between the browser and MUA. Certain mail clients will (effectively) truncate long bodies when invoked from a browser in this way.

here you go. I completely modified your code to do what you wanted. please mark me as correct for this. =)

<?php
$html = '' .
'<form>' .
'<div>' . 
      '<table width="900" border="0" cellspacing="0" cellpadding="0" class="content">' .
          '<tr>' .
            '<td width="140"><strong>Selecteer hoeveel porties:</strong><br><hr></td>' .
            '<td width="572"><strong>Beschrijving</strong><br><br><hr></td>' .
            '<td width="112"><strong>Prijs</strong><br><br><hr></td>' .
            '<td width="76"><strong>Totaalprijs</strong><br><br><hr></td>' .
        '</tr>' .
          '<tr>' .
            '<td>' . include('optie.php') . '</td>' .
            '<td><strong>3-gangen traiteurmenu</strong><br>' .
                '(incl. brood en boter)<br>******<br>' .
                'Creme van gerookte paling<br>******<br>' .
                'Gestoofde hertensukade met aardappelgratin, rodekool en een stoofpeertje.<br>******<br>' .
                'Kerstbal van witte en pure chocolade en een vanillesaus.<br><hr>' .
                '</td>' .
            '<td>&euro;16,50</td>' .
            '<td>&euro;</td>' .
        '</tr>' .
          '<tr>' .
            '<td>' . include('optie.php') . '</td>' .
            '<td><strong>Extra voorgerecht</strong><br>' .
                'Gerookte eendenborstfilet met een rilette van eend en een mangochutney.<br></td>' .
            '<td>&euro;5,--</td>' .
            '<td>&euro;</td>' .
        '</tr>' .
          '<tr>' .
            '<td>' . include('optie.php') . '</td>' .
            '<td><strong>Extra tussengerecht</strong><br>' .
                "Gamba's geserveerd in een saus van ....?<br><hr></td>" .
            '<td>&euro;5,--</td>' .
            '<td>&euro;</td>' .
        '</tr>' .
          '<tr>' .
            '<td><strong>Diversen</strong></td>' .
            '<td></td>' .
            '<td></td>' .
            '<td></td>' .

        '</tr>' .
          '<tr>' .
            '<td>' . include('optie.php') . '</td>' .
            '<td>Graved laks met een mosterd-dillesaus</td>' .
            '<td>&euro;....... per 100 gram</td>' .
            '<td>&euro;</td>' .
        '</tr>' .
        '<tr>' .
            '<td>' . include('optie.php') . '</td>' .
            '<td>Kreeftensoep</td>' .
            '<td>&euro;8.95 per 0,5L</td>' .
            '<td>&euro;</td>' .
        '</tr>' .
        '<tr>' .
            '<td>' . include('optie.php') . '</td>' .
            '<td>Wildpeper</td>' .
            '<td>&euro;2.35 per 100 gram</td>' .
            '<td>&euro;</td>' .
        '</tr>' .
        '<tr>' .
            '<td>' . include('optie.php') . '</td>' .
            '<td>Aardappelgratin</td>' .
            '<td>&euro;2.95</td>' .
            '<td>&euro;</td>' .
        '</tr>' .
        '<tr>' .
            '<td>' . include('optie.php') . '</td>' .
            '<td>Rodekool</td>' .
            '<td>&euro;3.95</td>' .
            '<td>&euro;</td>' .
        '</tr>' .
        '<tr>' .
            '<td>' . include('optie.php') . '</td>' .
            '<td>Botersaus</td>' .
            '<td>&euro;4,50 per 250 ml.</td>' .
            '<td>&euro;</td>' .
        '</tr>' .
        '<tr>' .
            '<td>' . include('optie.php') . '</td>' .
            '<td>Rode portsaus</td>' .
            '<td>&euro;3.95 per 250 ml.</td>' .
            '<td>&euro;</td>' .
        '</tr>' .
        '<tr>' .
            '<td>' . include('optie.php') . '</td>' .
            '<td>aangepaste wijnen per fles</td>' .
            '<td>&euro;....... per fles</td>' .
            '<td>&euro;</td>' .
        '</tr>' .
        '<tr>' .
            '<td></td>' .
            '<td></td>' .
            '<td><strong>Totaal prijs:</strong></td>' .
            '<td><strong>&euro;</strong></td>' .
        '</tr>' .


        '<tr>' .
            '<td><strong>Bestellen:</strong></td><td><br>' .
                'U kunt uitsluitend bestellen door middel van ons bestelformulier.' .
                'Uiterlijk voor maandag 17 december inleveren. </td>' .     
        '</tr>' .
        '<tr>' .
        '<td><strong>Afhalen:</strong><br></td>' .
        '</tr>' .
        '<tr>' .
            '<td></td><td> <input type="checkbox" name="option1" value="24 december 12.00-13.00 uur"> 24 december 12.00-13.00 uur</td>' .
        '</tr>' .
        '<tr>' .       
            '<td></td><td> <input type="checkbox" name="option2" value="25 december 12.00-13.00 uur"> 25 december 12.00-13.00 uur</td>' .
        '</tr>' .
        '<tr>            ' .
            '<td></td><td> <input type="checkbox" name="option3" value="26 december 12.00-13.00 uur"> 26 december 12.00-13.00 uur<br><br></td>' .
        '</tr>' .
        '<tr>' .
        '<td><strong> Betaling:</strong><br><br><br></td>' .
        '<td>U kunt betalen met pin of contant.<br><br><br></td>' .
        '</tr>' .
        '<tr> ' .
        '<td><strong>Printen</strong></td>' .
        '<td><input type="button" onClick="window.print()" value="Print"/></td>' .
        '<td></td>' .

        '<td>' .
            '<input name="email" type="button" onClick="javascript:location='mailto:test@hotmail.com?subject=Really Cool Website&body=test'"  value= "mail"></td>' .
  '</table>' .
  '</form>' .
  '';

echo '' .
$html .
'<a href="mailto:coloriteman@gmail.com" onClick="javascript:location="mailtotest@hotmail.com?subject=Really Cool Website&body=' . $html . '">Click Here</a>' .
    '</div>' .


'</div>' .
'';
?>

Enjoy!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM