treehouse : what would you like to learn today?
Web Design Web Development iOS Development

How to make send and recieve a formatted Table Form via email ?

  • I need to send a formatted table once the send has completed it and recieve via mail in the same format.

    Please help.

    Thanks
  • I need to send a formatted table once the sender has completed it, and recieve it via mail with the same format.
  • Are you asking for the html code? Because will need a server side script to send the mail and it must be formatted according to RFC standards for maximum compatibility with email agents.

    what do you have so far?
  • Thank you for your answer. Up to now I have managed to make the form and the PHP script to be sent and print formated in the receiver email.

    It seems to work but when I point to this page in the server, it sends an empty form first, after I fill it send the correct one.

    What is wrong (maybe all is because I am new to this). I have edited the tables just to show the head and the first line but I can't sent it to you using the WriteComment because keeps showing a small red lable ValidateLenght.

    How can I send you the code?



    Best regards from Spain
  • Part 1:














    #container {
    background-image: url(imagenes/);
    background-repeat: no-repeat;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    }
    td img {display: block;
    }
    .Estilo13 {
    color: #FF0000;
    font-weight: bolder;
    }
    .Estilo16 {
    color: #000000;
    font-size: 16;
    font-weight: bold;
    }
    .Estilo17 {
    color: #000000;
    }
    .Estilo14 {
    font-size: 9px;
    }
    .Estilo18 {
    color: #FFFFFF;
    }
    .Estilo19 {
    color: #0066FF;
    font-style: italic;
    }
    .style1 {
    font-size: 16;
    }
    .style2 {
    font-size: 12px;
    }
    .style14 {
    color: #0000FF;
    }
    .style13 {
    color: #FF0000;
    }
    .Tamaño16 {
    font-size: 16px;
    }
    .style12 {
    font-size: 24px;
    color: #0000FF;
    }
    .style4 {
    color: #000066;
    }





  • Part 2:





    Rellenar sus pedidos y el stock que todavía hay VOLVER A PÁGINA SERVICIOS FECHA STOCK: DÍA: MES: AÑO: FECHA PEDIDO: DÍA: MES: AÑO:
  • No success, I don't know how to send you the code. Advise me.

    Regards
  • You wrap your code in the following tags

    <pre><code>
  • <html>

    <head>

    <meta name="AUTHOR" CONTENT="Esteban" />
    <meta http-equiv="CHARSET" CONTENT="ISO-8859-1" />
    <meta http-equiv="CONTENT-LANGUAGE" CONTENT="ES" />
    <meta name="ROBOTS" CONTENT="All" />
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <link href="ESTILOS/ESTILO.css" rel="stylesheet" type="text/css" />

    <style type="text/css">

    #container {
    background-image: url(imagenes/);
    background-repeat: no-repeat;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    }
    td img {display: block;
    }
    .Estilo13 {
    color: #FF0000;
    font-weight: bolder;
    }
    .Estilo16 {
    color: #000000;
    font-size: 16;
    font-weight: bold;
    }
    .Estilo17 {
    color: #000000;
    }
    .Estilo14 {
    font-size: 9px;
    }
    .Estilo18 {
    color: #FFFFFF;
    }
    .Estilo19 {
    color: #0066FF;
    font-style: italic;
    }
    .style1 {
    font-size: 16;
    }
    .style2 {
    font-size: 12px;
    }
    .style14 {
    color: #0000FF;
    }
    .style13 {
    color: #FF0000;
    }
    .Tamaño16 {
    font-size: 16px;
    }
    .style12 {
    font-size: 24px;
    color: #0000FF;
    }
    .style4 {
    color: #000066;
    }

    </style>

    </head>
  • </head>

    <body onload="MM_preloadImages('imagenes/Localizaci&oacute;n_f2.gif')">
    <div id="container">
    <table width="850" border="1" background="images/Fondouniversidad.jpg">
    <tr>
    <td>
    <p align="center" class="Estilo13 style2">Rellenar sus pedidos y el stock que todav&iacute;a hay</p>
    <p align="center" class="Estilo13 style2"><a href="Servicios.html">VOLVER A PÁGINA SERVICIOS</a></p>
    <p align="center" class="style1"></p>

    <form action="paso02.php" method="post">
    <div align="center">
    <table width="600" border="1" align="center">
    <tr class="Estilo14">
    <td width="53"><strong>FECHA STOCK:</strong></td>
    <td width="53">DÍA:</td>
    <td width="53"><input name="dia" type="text" id="dia" onblur="MM_validateForm('dia','','RinRange1:31');return document.MM_returnValue" size="5" /></td>
    <td width="53">MES:</td>
    <td width="30"><input name="mes" type="text" id="mes" onblur="MM_validateForm('mes','','RinRange1:12');return document.MM_returnValue" size="5" /></td>
    <td width="34">AÑO:</td>
    <td width="40"><input name="ano" type="text" id="ano" onblur="MM_validateForm('ano','','RinRange2011:2020');return document.MM_returnValue" size="5" /></td>
    <td width="40"></td>

    <td width="53"><strong>FECHA PEDIDO:</strong></td>
    <td width="53">DÍA:</td>
    <td width="53"><input name="dia1" type="text" id="dia1" onblur="MM_validateForm('dia1','','RinRange1:31');return document.MM_returnValue" size="5" /></td>
    <td width="53">MES:</td>
    <td width="30"><input name="mes1" type="text" id="mes1" onblur="MM_validateForm('mes1','','RinRange1:12');return document.MM_returnValue" size="5" /></td>
    <td width="34">AÑO:</td>
    <td width="40" border="0"><input name="ano1" type="text" id="ano1" onblur="MM_validateForm('ano1','','RinRange2011:2020');return document.MM_returnValue" size="5" /></td>
    </tr>
    </table>

    <P align="centre"><strong>DESAYUNOS</strong></P>

    <table width="850" border="1" align="center">
    <tr>
    <td width="55" height="26"><div align="center" class="style2"><strong>Formato</strong></div></td>
    <td width="271"><div align="center" class="style2"><strong>Artículo</strong></div></td>
    <td width="330"><div align="center" class="style2"><strong>Observaciones</strong></div></td>
    <td width="50"><div align="center" class="style2"><strong>Uds. Stock</strong></div></td>
    <td width="52"><div align="center" class="style2"><strong>Uds. Solicit.</strong></div></td>
    <td width="52"><div align="center" class="style2"><strong>Uds. Pedidas</strong></div></td>
    </tr>

    <tr>
    <td><input name="1a" type="text" id="1a" size="4" maxlength="4" value="0"/></td>
    <td height="26"><div align="left" class="style2"><strong>ACEITE DE OLIVA</strong></div></td>
    <td><input name="1c" type="text" id="1c" size="55" maxlength="40" value="0"/></td>
    <td><input name="1d" type="text" id="1d" size="4" maxlength="4" value="0"/></td>
    <td><input name="1e" type="text" id="1e" size="4" maxlength="4" value="0"/></td>
    <td><input name="1f" type="text" id="1f" size="4" maxlength="4" value="0"/></td>
    </tr>

    </table>

    </div>

    <div align="center">
    <?php
    $to = 'me@gmail.com';
    $subject = 'PEDIDOS';
    $msg = "
    <html>
    <head>

  • <title>PEDIDOS DESDE LA RESIDENCIA</title>
    </head>

    <body>

    <div align=\"center\">
    <table width=\"600\" border=\"1\" align=\"center\">
    <tr class=\"Estilo14\">
    <td width=\"53\" align=\"center\"><strong>FECHA STOCK:</strong></td>
    <td width=\"53\" align=\"center\">DÍA:</td>
    <td width=\"53\" align=\"center\">" . strip_tags($_POST['dia']) . "</td>
    <td width=\"53\" align=\"center\">MES:</td>
    <td width=\"30\" align=\"center\">" . strip_tags($_POST['mes']) . "</td>
    <td width=\"34\" align=\"center\">AÑO:</td>
    <td width=\"40\" align=\"center\">" . strip_tags($_POST['ano']) . "</td>
    <td width=\"40\" align=\"center\" border=\"0\"></td>

    <td width=\"53\" align=\"center\"><strong>FECHA PEDIDO:</strong></td>
    <td width=\"53\" align=\"center\">DÍA:</td>
    <td width=\"53\" align=\"center\">" . strip_tags($_POST['dia1']) . "</td>
    <td width=\"53\" align=\"center\">MES:</td>
    <td width=\"30\" align=\"center\">" . strip_tags($_POST['mes1']) . "</td>
    <td width=\"34\" align=\"center\">AÑO:</td>
    <td width=\"40\" align=\"center\">" . strip_tags($_POST['ano1']) . "</td>
    </tr>
    </table>
    <P align=\"centre\"><strong>DESAYUNOS</strong></P>
    <table width=\"850\" border=\"1\" align=\"center\">
    <tr>
    <td width=\"55\" height=\"26\"><div align=\"center\" class=\"style2\"><strong>Formato</strong></div></td>
    <td width=\"253\"><div align=\"center\" class=\"style2\"><strong>Artículo</strong></div></td>
    <td width=\"362\"><div align=\"center\" class=\"style2\"><strong>Observaciones</strong></div></td>
    <td width=\"51\"><div align=\"center\" class=\"style2\"><strong>Uds. Stock</strong></div></td>
    <td width=\"51\"><div align=\"center\" class=\"style2\"><strong>Uds. Solicit.</strong></div></td>
    <td width=\"52\"><div align=\"center\" class=\"style2\"><strong>Uds. Pedidas</strong></div></td>
    </tr>

    <tr>
    <td width=\"55\" height=\"26\"><div align=\"center\" class=\"style2\"><strong>" . strip_tags($_POST['1a']) . "</div></td>
    <td width=\"253\"><div align=\"left\" class=\"style2\"><strong>ACEITE DE OLIVA</div></td>
    <td width=\"362\"><div align=\"left\" class=\"style2\"><strong>" . strip_tags($_POST['1c']) . "</div></td>
    <td width=\"51\"><div align=\"center\" class=\"style2\"><strong>" . strip_tags($_POST['1d']) . "</div></td>
    <td width=\"51\"><div align=\"center\" class=\"style2\"><strong>" . strip_tags($_POST['1e']) . "</div></td>
    <td width=\"52\"><div align=\"center\" class=\"style2\"><strong>" . strip_tags($_POST['1f']) . "</div></td>
    </tr>



    </table>


    </div>
    </body>
    </html>";

    $headers = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

    mail($to, $subject, $msg, $headers);

    echo "<p style='font-size:24px;color:#FF0000;'>Gracias por rellenar su pedido. Su información se ha enviado correctamente.</p>";
    ?>
    <table width="50" border="0" align="center">
    <tr>
    <td width="50">
    <span class="Estilo14"><input name="submit" type="submit" onclick="MM_validateForm('dia','','R','mes','','R','ano','','R');return document.MM_returnValue" value="Enviar" /></span>
    </td>
    </tr>
    </table>
    </div>
    </form>
    </td>
    </tr>
    </table>

    <div id="footer">
    <p><strong>TEL: MOVIL: FAX: email: me@asycon.com</strong></p>
    </div>
    </div>

    <script type="text/javascript">
    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl.&quot; : "http://www.&quot;);
    document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
    </script>

    <script type="text/javascript">
    try {
    var pageTracker = _gat._getTracker("UA-9523385-1");
    pageTracker._trackPageview();
    } catch(err) {}
    </script>
    </body>
    </html>
  • Ok, thanks for the help.

    Stjepo
  • if you want to fill out the table and then send the table...(can you have input tags in html email?)...you can write your php with a few ifs.

    if (table filled) {
    sendmail(to, subj, table, headers)
    } else {
    echo table
    }

    that is the idea not the real code.
  • Thanks Schmotty