473,385 Members | 1,542 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Script send mail and save into mysql db

Hello,

I have a script php that I use on my website to permit visitors to send me some email with some data, this is the html table code:

Expand|Select|Wrap|Line Numbers
  1. <table width="730" border="0" cellpadding="0" cellspacing="0">
  2.           <tr>
  3.             <td><div align="center" class="textorange1"><strong>Richiesta Ricarica</strong></div></td>
  4.           </tr>
  5.           <tr>
  6.             <td>&nbsp;</td>
  7.           </tr>
  8.           <tr>
  9.             <td><div align="center" class="textblack1">Prima di compilare questo form bisogna effettuare le registrazioni come indicato nel regolamento, poi compilare tutti i campi o la richiesta di ricarica non verrą accettata.</div></td>
  10.           </tr>
  11.           <tr>
  12.             <td>&nbsp;</td>
  13.           </tr>
  14.           <tr>
  15.             <td><div align="center">
  16.               <div align="center">
  17.                 <form id="commentform" name="commentform" method="post" action="ricarica.php">
  18.                   <table width="500" border="0" cellspacing="0" cellpadding="0">
  19.                     <tr align="left" valign="middle">
  20.                       <td width="170" height="20" class="textblack1"><div align="left">Nome  *:</div></td>
  21.                       <td width="120"><div align="left">
  22.                         <input name="nome" type="text" class="inputdepartment" id="nome" size="20" />
  23.                       </div></td>
  24.                     </tr>
  25.                     <tr align="left" valign="middle">
  26.                       <td height="20" class="textblack1"><div align="left">Cognome *:</div></td>
  27.                       <td><div align="left">
  28.                         <input name="cognome" type="text" class="inputdepartment" id="cognome" size="20" />
  29.                       </div></td>
  30.                     </tr>
  31.                     <tr align="left" valign="middle">
  32.                       <td height="20" class="textblack1"><div align="left">Data di nascita *:</div></td>
  33.                       <td><div align="left">
  34.                         <input name="datadinascita" type="text" class="inputdepartment" id="datadinascita" value="gg/mm/aaaa" size="20" />
  35.                       </div></td>
  36.                     </tr>
  37.                     <tr align="left" valign="middle">
  38.                       <td height="20" class="textblack1"><div align="left">Sesso *:</div></td>
  39.                       <td><div align="left">
  40.                         <select name="sesso" id="sesso" class="inputdepartment">
  41.                           <option value="-------" selected="selected">-------</option>
  42.                           <option value="Maschio">Maschio</option>
  43.                           <option value="Femmina">Femmina</option>
  44.                         </select>
  45.                       </div></td>
  46.                     </tr>
  47.                     <tr align="left" valign="middle">
  48.                       <td height="20" class="textblack1"><div align="left">Indirizzo *:</div></td>
  49.                       <td><div align="left">
  50.                         <input name="indirizzo" type="text" class="inputdepartment" id="indirizzo" size="20" />
  51.                       </div></td>
  52.                     </tr>
  53.                     <tr align="left" valign="middle">
  54.                       <td height="20" class="textblack1"><div align="left">CAP *:</div></td>
  55.                       <td><div align="left">
  56.                         <input name="cap" type="text" class="inputdepartment" id="cap" size="20" />
  57.                       </div></td>
  58.                     </tr>
  59.                     <tr align="left" valign="middle">
  60.                       <td height="20" class="textblack1"><div align="left">Provincia  *:</div></td>
  61.                       <td><div align="left">
  62.                         <input name="provincia" type="text" class="inputdepartment" id="provincia" size="20" />
  63.                       </div></td>
  64.                     </tr>
  65.                     <tr align="left" valign="middle">
  66.                       <td height="20" class="textblack1"><div align="left">Comune *:</div></td>
  67.                       <td><div align="left">
  68.                         <input name="comune" type="text" class="inputdepartment" id="comune" size="20" />
  69.                       </div></td>
  70.                     </tr>
  71.  
  72.                     <tr align="left" valign="middle">
  73.                       <td height="20" class="textblack1"><div align="left">Numero cellulare/carta da ricaricare/email Paypal *:</div></td>
  74.                       <td><div align="left">
  75.                         <input name="ricarica" type="text" class="inputdepartment" id="ricarica" size="20" />
  76.                       </div></td>
  77.                     </tr>
  78.                     <tr align="left" valign="middle">
  79.                       <td height="20" class="textblack1"><div align="left">Il suo indirizzo e-mail *: </div></td>
  80.                       <td><div align="left">
  81.                         <input name="email" type="text" class="inputdepartment" id="email" size="20" />
  82.                       </div></td>
  83.                     </tr>
  84.                     <tr align="left" valign="middle">
  85.                       <td height="20" class="textblack1"><div align="left">Conferma indirizzo e-mail *: </div></td>
  86.                       <td><div align="left">
  87.                         <input name="email" type="text" class="inputdepartment" id="email" size="20" />
  88.                       </div></td>
  89.                     </tr>
  90.                     <tr align="left" valign="middle">
  91.                       <td height="20" class="textblack1"><div align="left">Orario registrazione *:</div></td>
  92.                       <td><div align="left">
  93.                         <input name="orario" type="text" class="inputdepartment" id="orario" value="XX:XX" size="20" />
  94.                       </div></td>
  95.                     </tr>
  96.  
  97.  
  98.                     <tr align="left" valign="middle">
  99.                       <td height="20" class="textblack1"><div align="left">Data registrazione *:</div></td>
  100.                       <td><div align="left">
  101.                         <input name="data" type="text" class="inputdepartment" id="data" value="gg/mm/aaaa" size="20" />
  102.                       </div></td>
  103.                     </tr>
  104.                     <tr align="left" valign="middle">
  105.                       <td height="20" class="textblack1"><div align="left">Operatore *:</div></td>
  106.                       <td><div align="left">
  107.                         <select name="operatore" id="operatore" class="inputdepartment">
  108.                           <option value="-------" selected="selected">-------</option>
  109.                           <option value="Tim">Tim</option>
  110.                           <option value="Vodafone">Vodafone</option>
  111.                           <option value="Wind">Wind</option>
  112.                           <option value="Tre">Tre</option>
  113.                           <option value="PosteMobile">PosteMobile</option>
  114.                           <option value="PostePay">PostePay</option>
  115.                           <option value="Paypal">Paypal</option>
  116.                           <option value="MediasetPremium">MediasetPremium</option>
  117.                         </select>
  118.                       </div></td>
  119.                     </tr>
  120.                     <tr align="left" valign="middle">
  121.                       <td height="20" class="textblack1"><div align="left">Come ci hai conosciuto *: </div></td>
  122.                       <td><div align="left">
  123.                         <select name="know" id="know" class="inputdepartment">
  124.                           <option value="-------" selected="selected">-------</option>
  125.                           <option value="Google">Google</option>
  126.                           <option value="Yahoo">Yahoo</option>
  127.                           <option value="Amici">Amici</option>
  128.                           <option value="Parenti">Parenti</option>
  129.                           <option value="Altro">Altro</option>
  130.                         </select>
  131.                       </div></td>
  132.                     </tr>
  133.  
  134.                     <tr align="left" valign="middle">
  135.                       <td class="textblack1"><div align="left">Media partners su cui ci si č iscritti:
  136.  *:</div></td>
  137.                       <td><div align="left">
  138.                         <textarea name="msg" cols="35" rows="10" class="inputtextarea" id="msg"></textarea>
  139.                       </div></td>
  140.                     </tr>
  141.                   </table>
  142.                   <table border="0" cellpadding="0" cellspacing="0" width="500">
  143.                     <tr align="center" valign="middle">
  144.                       <td height="30">
  145.                           <div align="center">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  146.                             <input onclick="return confirm('Siete sicuri di aver effettuato le registrazioni ai media partner come indicato nel regolamento? Se non l\'avete fatto la richiesta non sarą accettata.');" name="Submit" type="submit" class="inputbutton" value="Invia" />
  147.                             <input name="Submit2" type="reset" class="inputbutton" value="Reset" />
  148.                           </div></td>
  149.                     </tr>
  150.                     <tr align="left" valign="top">
  151.                       <td height="20"><div class="textblack1">
  152.                         <div align="left"><strong>* Richiesto</strong></div>
  153.                       </div></td>
  154.                     </tr>
  155.                   </table>
  156.                 </form>
  157.               </div>
  158.             </div></td>
  159.           </tr>
  160.           <tr>
  161.             <td>&nbsp;</td>
  162.           </tr>
  163.           <tr>
  164.             <td><div align="center">Inviando la richiesta si accettano il <a href="regolamento.html" target="_blank" class="textorange1"><strong>regolamento</strong></a> e le <a href="faq.html" target="_blank" class="textorange1"><strong>faq</strong></a>.</div></td>
  165.           </tr>
  166.         </table>


and this is the php code:

Expand|Select|Wrap|Line Numbers
  1. <html>
  2.  
  3. <head>
  4.  
  5. <title>Mail</title>
  6.  
  7. <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
  8.  
  9. <style type="text/css">
  10.  
  11. <!--
  12.  
  13.  
  14.  
  15. .mini {
  16.  
  17.     font-family: Tahona, Verdana;
  18.  
  19.     font-size: 11px;
  20.  
  21.         color: #333333;
  22.  
  23. }
  24.  
  25. body, td, th {
  26.  
  27.     font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif;
  28.  
  29.     font-size: 11px;
  30.  
  31.     color: #333333;
  32.  
  33. }
  34.  
  35. a:link {
  36.  
  37.     text-decoration: none;
  38.  
  39. }
  40.  
  41. a:visited {
  42.  
  43.     text-decoration: none;
  44.  
  45. }
  46.  
  47. a:hover {
  48.  
  49.     text-decoration: underline;
  50.  
  51. }
  52.  
  53. a:active {
  54.  
  55.     text-decoration: none;
  56.  
  57. }
  58.  
  59. body {
  60.  
  61.     margin:50px; background-color: #ffffff
  62.  
  63. }
  64.  
  65. .status {
  66.  
  67.     font-size: 11px;
  68.  
  69.     color: #FF7E00;
  70.  
  71. }
  72.  
  73. -->
  74.  
  75.  
  76.  
  77. </style>
  78.  
  79. <div class="message">
  80.  
  81. <?php
  82.  
  83.  
  84.  
  85. $receiverMail    = "info@ricarica-gratis.com";
  86.  
  87. $nome        = ltrim(rtrim(strip_tags(stripslashes($_POST['nome']))));
  88.  
  89. $cognome    = ltrim(rtrim(strip_tags(stripslashes($_POST['cognome']))));
  90.  
  91. $datadinascita    = ltrim(rtrim(strip_tags(stripslashes($_POST['datadinascita']))));
  92.  
  93. $sesso      = ltrim(rtrim(strip_tags(stripslashes($_POST['sesso']))));
  94.  
  95. $indirizzo    = ltrim(rtrim(strip_tags(stripslashes($_POST['indirizzo']))));
  96.  
  97. $cap        = ltrim(rtrim(strip_tags(stripslashes($_POST['cap']))));
  98.  
  99. $provincia    = ltrim(rtrim(strip_tags(stripslashes($_POST['provincia']))));
  100.  
  101. $comune     = ltrim(rtrim(strip_tags(stripslashes($_POST['comune']))));
  102.  
  103. $ricarica    = ltrim(rtrim(strip_tags(stripslashes($_POST['ricarica']))));
  104.  
  105. $email        = ltrim(rtrim(strip_tags(stripslashes($_POST['email']))));
  106.  
  107. $orario     = ltrim(rtrim(strip_tags(stripslashes($_POST['orario']))));
  108.  
  109. $data        = ltrim(rtrim(strip_tags(stripslashes($_POST['data']))));
  110.  
  111. $operatore    = ltrim(rtrim(strip_tags(stripslashes($_POST['operatore']))));
  112.  
  113. $know       = ltrim(rtrim(strip_tags(stripslashes($_POST['know']))));
  114.  
  115. $msg        = "Media partners su cui ci si č iscritti: \n--------------------------------------------\n".ltrim(rtrim(strip_tags($_POST['msg'])));
  116.  
  117.  
  118.  
  119. $ip        = getenv("REMOTE_ADDR");
  120.  
  121. $msgformat    = "Da: $nome $cognome - ($ip)\nData di nascita: $datadinascita\nSesso: $sesso\nIndirizzo: $indirizzo\nCAP: $cap\nProvincia: $provincia\nComune: $comune\nRicaricare: $ricarica\nEmail: $email\nOrario: $orario\nData di registrazione: $data\nOperatore: $operatore\nCome ci hai conosciuto: $know\n\n$msg";
  122.  
  123.  
  124.  
  125. // VALIDATION
  126.  
  127. if(empty($nome) || empty($cognome) || empty($datadinascita) || empty($sesso) || empty($indirizzo) || empty($cap) || empty($provincia) || empty($comune) || empty($ricarica) || empty($email) || empty($orario) || empty($data) || empty($operatore) || empty($know) || empty($msg)) {
  128.  
  129. echo "<center><b>La tua richiesta non e' stata inviata</b><p>Per favore compila tutti i campi</p><A href='javascript:history.back()' class='status'>[ Indietro ]</a><br><br></center>"; 
  130.  
  131. }
  132.  
  133. elseif(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
  134.  
  135. echo "<center><b>La tua richiesta non e' stata inviata</b><p>L'indirizzo email non e' valido</p><A href='javascript:history.back()' class='status'>[ Indietro ]</a><br><br></center>";
  136.  
  137. }
  138.  
  139. else {
  140.  
  141.     mail($receiverMail, $operatore, $msgformat, "From: $nome <$email>");
  142.  
  143.  
  144.  
  145.     echo "<center><strong>La tua richiesta e' stata inviata!</strong><p>Ti ricontatteremo non appena possibile</p><A href='index.html' class='status'>[ Indietro ]</a><br><br></center>";
  146.  
  147.  
  148.  
  149. }
  150.  
  151. ?>
  152.  
  153. </div>
  154.  
  155. </body>
  156.  
  157. </html>

what I need from that script php is that when it send to me the mail in the same time save all data on a db, how I can modify that script to do that?

Thank you for all reply.

Michael
Dec 22 '08 #1
1 3419
Markus
6,050 Expert 4TB
Using a database such as MySQL(i), you would create a table that has all the fields you want saving. Then you would use an SQL INSERT query to add new data to the table.

I suggest you get to grips with MySQL first.

Tutorial: MySQL Tutorial - Introduction
Dec 22 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Manuel Hegemann | last post by:
Hello, i want for a newsletter to send html valid newsletters. per adminscript i save the context which will be sent to a mysql-database and get this data for the mail later on. it's a pitty, but...
1
by: David | last post by:
Hello everyone I am completely clueless when it comes to the more technical side of web design so need some help on this as my web hosting company just keeps telling me it's beyind their scope....
30
by: zn | last post by:
If I place a form for product ordering on my website, what scripting technology or CGIs can I use to encrypt the e-mail sent to my e-mail account with the order information? Thanks.
8
by: Shabam | last post by:
I have a command script that backs up a user account. This involves moving files from different directories into an archive. Now, I need that script to back up all user accounts on the system,...
9
by: Jerim79 | last post by:
I am no PHP programmer. At my current job I made it known that I was no PHP programmer during the interview. Still they have given me a script to write with the understanding that it will take me a...
5
by: This | last post by:
I have a pretty basic emailing script that sends a relatively small number (150) of html emails. The emails are compiled, personalised from a mysql db subscribers list, and sent using mail() -...
2
chunk1978
by: chunk1978 | last post by:
i wrote a custom PHP script last year and everything worked perfectly... recently my webserver upgraded to PHP 5 and now my script doesn't work properly. what the script does is: users fill out...
82
by: happyse27 | last post by:
Hi All, I modified the user registration script, but not sure how to make it check for each variable in terms of preventing junk registration and invalid characters? Two codes below : a)...
3
by: luttkens | last post by:
I've got a script to access my database called mysql.class.php. So from every other script that is talking to the database, this file i included, like this for instance: <?php...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.