<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Messaggio popup da contact form]]></title><description><![CDATA[<p dir="auto">Ciao a tutti, ho un form in php e vorrei che all'invio del modulo invece che restituirmi un messaggio in un'altra pagina tramite il comando echo, lo script mi restituisse un avviso popup con un solo pulsante di OK.</p>
<p dir="auto">Come faccio? potete aiutarmi? Ecco il codice:</p>
<pre><code>[FONT=Courier New]&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;.   [/FONT]
 
[COLOR=#0000bb][FONT=Courier New]&lt;?php [/FONT][/COLOR]
 
[FONT=Courier New][COLOR=#ff8000]// campi obbligatori [/COLOR][/FONT]
[FONT=Courier New][COLOR=#007700]if (([/COLOR][COLOR=#0000bb]trim[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]$_POST[/COLOR][COLOR=#007700][[/COLOR][COLOR=#dd0000]'name'[/COLOR][COLOR=#007700]]) != [/COLOR][COLOR=#dd0000]""[/COLOR][COLOR=#007700]) &amp;&amp; ([/COLOR][COLOR=#0000bb]trim[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]$_POST[/COLOR][COLOR=#007700][[/COLOR][COLOR=#dd0000]'surname'[/COLOR][COLOR=#007700]]) != [/COLOR][COLOR=#dd0000]""[/COLOR][COLOR=#007700]) &amp;&amp; ([/COLOR][COLOR=#0000bb]trim[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]$_POST[/COLOR][COLOR=#007700][[/COLOR][COLOR=#dd0000]'email'[/COLOR][COLOR=#007700]]) != [/COLOR][COLOR=#dd0000]""[/COLOR][COLOR=#007700]) &amp;&amp; ([/COLOR][COLOR=#0000bb]trim[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]$_POST[/COLOR][COLOR=#007700][[/COLOR][COLOR=#dd0000]'tel'[/COLOR][COLOR=#007700]]) != [/COLOR][COLOR=#dd0000]""[/COLOR][COLOR=#007700]) &amp;&amp; ([/COLOR][COLOR=#0000bb]trim[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]$_POST[/COLOR][COLOR=#007700][[/COLOR][COLOR=#dd0000]'message'[/COLOR][COLOR=#007700]]) != [/COLOR][COLOR=#dd0000]""[/COLOR][/FONT][COLOR=#007700][FONT=Courier New])) { [/FONT][/COLOR]
 
[FONT=Courier New][COLOR=#ff8000]// destinatario dell'e-mail [/COLOR][/FONT]
[FONT=Courier New][COLOR=#0000bb]$to [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#dd0000]"      \n [COLOR=#000080]indirizzo email destinatario[/COLOR] "[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]; [/COLOR][/FONT]
 
[FONT=Courier New][COLOR=#0000bb]$headers [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#dd0000]"From: " [/COLOR][COLOR=#007700]. [/COLOR][COLOR=#0000bb]$_POST[/COLOR][COLOR=#007700][[/COLOR][COLOR=#dd0000]'email'[/COLOR][COLOR=#007700]] . [/COLOR][COLOR=#dd0000]"\n"[/COLOR][/FONT][COLOR=#007700][FONT=Courier New]; [/FONT][/COLOR]
 
[FONT=Courier New][COLOR=#ff8000]// oggetto dell' e-mail [/COLOR][/FONT]
[FONT=Courier New][COLOR=#0000bb]$subject [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#dd0000]"Contatto dal sito"[/COLOR][/FONT][COLOR=#007700][FONT=Courier New]; [/FONT][/COLOR]
 
[FONT=Courier New][COLOR=#ff8000]// corpo messaggio [/COLOR][/FONT]
[FONT=Courier New][COLOR=#0000bb]$body [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#dd0000]"Hai ricevuto un messaggio dal sito con le seguenti informazioni:\n\n"[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]; [/COLOR][/FONT]
 
[FONT=Courier New][COLOR=#0000bb]$body [/COLOR][COLOR=#007700].= [/COLOR][COLOR=#dd0000]"Nome: " [/COLOR][COLOR=#007700]. [/COLOR][COLOR=#0000bb]trim[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]stripslashes[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]$_POST[/COLOR][COLOR=#007700][[/COLOR][COLOR=#dd0000]"name"[/COLOR][COLOR=#007700]])) . [/COLOR][COLOR=#dd0000]"\n"[/COLOR][COLOR=#007700]; [/COLOR][/FONT][FONT=Courier New][COLOR=#ff8000]//nome del mittente [/COLOR][/FONT]
[FONT=Courier New][COLOR=#0000bb]$body [/COLOR][COLOR=#007700].= [/COLOR][COLOR=#dd0000]"Cognome: " [/COLOR][COLOR=#007700]. [/COLOR][COLOR=#0000bb]trim[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]stripslashes[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]$_POST[/COLOR][COLOR=#007700][[/COLOR][COLOR=#dd0000]"surname"[/COLOR][COLOR=#007700]])) . [/COLOR][COLOR=#dd0000]"\n"[/COLOR][COLOR=#007700]; [/COLOR][/FONT][FONT=Courier New][COLOR=#ff8000]//cognome del mittente [/COLOR][/FONT]
[FONT=Courier New][COLOR=#0000bb]$body [/COLOR][COLOR=#007700].= [/COLOR][COLOR=#dd0000]"E-mail: " [/COLOR][COLOR=#007700]. [/COLOR][COLOR=#0000bb]trim[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]stripslashes[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]$_POST[/COLOR][COLOR=#007700][[/COLOR][COLOR=#dd0000]"email"[/COLOR][COLOR=#007700]])) . [/COLOR][COLOR=#dd0000]"\n"[/COLOR][COLOR=#007700]; [/COLOR][/FONT][FONT=Courier New][COLOR=#ff8000]//indirizzo e-mail del mittente [/COLOR][/FONT]
[FONT=Courier New][COLOR=#0000bb]$body [/COLOR][COLOR=#007700].= [/COLOR][COLOR=#dd0000]"Telefono: " [/COLOR][COLOR=#007700]. [/COLOR][COLOR=#0000bb]trim[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]stripslashes[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]$_POST[/COLOR][COLOR=#007700][[/COLOR][COLOR=#dd0000]"tel"[/COLOR][COLOR=#007700]])) . [/COLOR][COLOR=#dd0000]"\n"[/COLOR][COLOR=#007700]; [/COLOR][/FONT][FONT=Courier New][COLOR=#ff8000]//numero del mittente [/COLOR][/FONT]
[FONT=Courier New][COLOR=#0000bb]$body [/COLOR][COLOR=#007700].= [/COLOR][COLOR=#dd0000]"Sito web: " [/COLOR][COLOR=#007700]. [/COLOR][COLOR=#0000bb]trim[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]stripslashes[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]$_POST[/COLOR][COLOR=#007700][[/COLOR][COLOR=#dd0000]"website"[/COLOR][COLOR=#007700]])) . [/COLOR][COLOR=#dd0000]"\n"[/COLOR][COLOR=#007700]; [/COLOR][/FONT][FONT=Courier New][COLOR=#ff8000]//sito del mittente [/COLOR][/FONT]
[FONT=Courier New][COLOR=#0000bb]$body [/COLOR][COLOR=#007700].= [/COLOR][COLOR=#dd0000]"Messaggio: " [/COLOR][COLOR=#007700]. [/COLOR][COLOR=#0000bb]trim[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]stripslashes[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]$_POST[/COLOR][COLOR=#007700][[/COLOR][COLOR=#dd0000]"message"[/COLOR][COLOR=#007700]])) . [/COLOR][COLOR=#dd0000]"\n"[/COLOR][COLOR=#007700]; [/COLOR][/FONT][FONT=Courier New][COLOR=#ff8000]//contenuto del messaggio [/COLOR][/FONT]
 
 
[FONT=Courier New][COLOR=#ff8000]// invio mail [/COLOR][/FONT]
[FONT=Courier New][COLOR=#0000bb]mail[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]$to[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]$subject[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]$body[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]$headers[/COLOR][COLOR=#007700]); [/COLOR][/FONT][FONT=Courier New][COLOR=#ff8000]// SE L'INOLTRO E' ANDATO A BUON FINE... [/COLOR][/FONT]
 
[FONT=Courier New][COLOR=#007700]echo [/COLOR][COLOR=#dd0000]"E-mail inviata correttamente. Grazie per avermi contattata!"[/COLOR][/FONT][COLOR=#007700][FONT=Courier New];  [/FONT][/COLOR]
 
[FONT=Courier New][COLOR=#007700]} else {[/COLOR][/FONT][FONT=Courier New][COLOR=#ff8000]// altrimenti [/COLOR][/FONT]
 
[FONT=Courier New][COLOR=#007700]echo [/COLOR][COLOR=#dd0000]"E' necessario compilare tutti i campi prima di inviare."[/COLOR][/FONT][COLOR=#007700][FONT=Courier New]; [/FONT][/COLOR]
 
[FONT=Courier New][COLOR=#007700]} [/COLOR][/FONT]
 
[COLOR=#0000bb][FONT=Courier New]?&gt; [/FONT][/COLOR]
</code></pre>
]]></description><link>https://dev.connect.gt/topic/145989/messaggio-popup-da-contact-form</link><generator>RSS for Node</generator><lastBuildDate>Fri, 27 Nov 2026 04:45:48 GMT</lastBuildDate><atom:link href="https://dev.connect.gt/topic/145989.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 20 Feb 2011 13:18:15 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Messaggio popup da contact form on Sun, 20 Feb 2011 19:41:34 GMT]]></title><description><![CDATA[<p dir="auto">Non mi sono spiegato bene.. a me serve utilizzare il seguente codice ma con la dovuta modifica per adattarlo alla mia esigenza.<br />
Ti incollo prima il codice html e poi il php:</p>
<pre><code class="language-html">&lt;form action="mail.php" method="post" id="modulo"&gt;
 
&lt;div class="form_row"&gt;
&lt;label&gt;Nome:&lt;/label&gt;
&lt;input name="name" type="text" id="name" class="contact_input"/&gt;
&lt;/div&gt;
 
&lt;div class="form_row"&gt;
&lt;label&gt;Cognome:&lt;/label&gt;
&lt;input name="surname" type="text" id="surname" class="contact_input"/&gt;
&lt;/div&gt;
 
&lt;div class="form_row"&gt;
&lt;label&gt;E-mail:&lt;/label&gt;
&lt;input name="email" type="text" id="email" class="contact_input"/&gt;
&lt;/div&gt;
 
&lt;div class="form_row"&gt;
&lt;label&gt;Telefono:&lt;/label&gt;
&lt;input name="tel" type="text" id="tel" class="contact_input"/&gt;
&lt;/div&gt;
 
&lt;div class="form_row"&gt;
&lt;label&gt;Messaggio:&lt;/label&gt;
&lt;textarea name="message" cols="30" rows="5" id="message" class="contact_textarea"&gt;&lt;/textarea&gt;
&lt;/div&gt;
 
&lt;div class="form_row"&gt;
&lt;input type="submit" name="submit" id="submit" class="contact_submit" value="Invia" /&gt;
&lt;/div&gt; 
 
&lt;/form&gt;
</code></pre>
<pre><code class="language-php">&lt;?php 
 
// campi obbligatori 
if ((trim($_POST['name']) != "") &amp;&amp; (trim($_POST['surname']) != "") &amp;&amp; (trim($_POST['email']) != "") &amp;&amp; (trim($_POST['tel']) != "") &amp;&amp; (trim($_POST['message']) != "")) { 
 
// destinatario dell'e-mail 
$to = "      \n indirizzo email destinatario "; 
 
$headers = "From: " . $_POST['email'] . "\n"; 
 
// oggetto dell' e-mail 
$subject = "Contatto dal sito"; 
 
// corpo messaggio 
$body = "Hai ricevuto un messaggio dal sito con le seguenti informazioni:\n\n"; 
 
$body .= "Nome: " . trim(stripslashes($_POST["name"])) . "\n"; //nome del mittente 
$body .= "Cognome: " . trim(stripslashes($_POST["surname"])) . "\n"; //cognome del mittente 
$body .= "E-mail: " . trim(stripslashes($_POST["email"])) . "\n"; //indirizzo e-mail del mittente 
$body .= "Telefono: " . trim(stripslashes($_POST["tel"])) . "\n"; //numero del mittente 
$body .= "Sito web: " . trim(stripslashes($_POST["website"])) . "\n"; //sito del mittente 
$body .= "Messaggio: " . trim(stripslashes($_POST["message"])) . "\n"; //contenuto del messaggio 
 
 
// invio mail 
mail($to, $subject, $body, $headers); // SE L'INOLTRO E' ANDATO A BUON FINE... 
 
echo "E-mail inviata correttamente. Grazie per avermi contattata!";  
 
} else {// altrimenti 
 
echo "E' necessario compilare tutti i campi prima di inviare."; 
 
} 
 
?&gt;
</code></pre>
]]></description><link>https://dev.connect.gt/post/976115</link><guid isPermaLink="true">https://dev.connect.gt/post/976115</guid><dc:creator><![CDATA[pe.ma]]></dc:creator><pubDate>Sun, 20 Feb 2011 19:41:34 GMT</pubDate></item><item><title><![CDATA[Reply to Messaggio popup da contact form on Sun, 20 Feb 2011 17:52:16 GMT]]></title><description><![CDATA[<p dir="auto">Prova a vedere se ti va bene questo codice.</p>
<p dir="auto">C'è un pò di tutto, un controllo Javascript prima dell'invio dati, e del php che ti dice se va tutto bene.</p>
<pre><code class="language-php">&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
    &lt;head&gt;
    &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
    &lt;title&gt;Test&lt;/title&gt;
    &lt;style type="text/css"&gt;
        html,body
        {
            margin:0px;
            padding:0px;
            background:#AAD4FF;            
        }        
        .sposta
        {
            margin:10px;
        }
        &lt;/style&gt;
        &lt;script type="text/javascript"&gt;
            function controlla()
            {
                var cognome=document.getElementById("cognome");
                var valoreCognome=cognome.value;
                if(valoreCognome=="")
                {
                    alert("Il cognome è obbligatorio, compilarlo prima di proseguire!");
                }
                else
                {
                    document.myform.submit();
                }
            }
        &lt;/script&gt;        
    &lt;/head&gt;
    &lt;body&gt;
        &lt;?php 
            $valoreNome=$_POST['nome'];
            $valoreCognome=$_POST['cognome'];
            if($valoreNome==""&amp;&amp;$valoreCognome=="")
            {
        ?&gt;
        &lt;form name="myform" id="myform" action="index.php" method="post"&gt;
            &lt;div&gt;&lt;input class="sposta" id="nome" name="nome" /&gt;&lt;span class="sposta"&gt;Nome&lt;/span&gt;&lt;/div&gt;
            &lt;div&gt;&lt;input class="sposta" id="cognome" name="cognome" /&gt;&lt;span class="sposta"&gt;Cognome *&lt;/span&gt;&lt;/div&gt;
            &lt;div&gt;&lt;input class="sposta" type="button" value="INVIO" onclick="controlla()"/&gt;&lt;/div&gt;            
        &lt;/form&gt;
        &lt;?php
            }
            else
            {
                echo "Form inviato con successo!";
            }
        ?&gt;    
    &lt;/body&gt;
&lt;/html&gt;
</code></pre>
]]></description><link>https://dev.connect.gt/post/976109</link><guid isPermaLink="true">https://dev.connect.gt/post/976109</guid><dc:creator><![CDATA[marcocarrieri]]></dc:creator><pubDate>Sun, 20 Feb 2011 17:52:16 GMT</pubDate></item><item><title><![CDATA[Reply to Messaggio popup da contact form on Sun, 20 Feb 2011 17:35:43 GMT]]></title><description><![CDATA[<p dir="auto">Non sono capace purtroppo, infatti ho inserito gli asterischi che indicano quale dei campi è obbligatorio.. mi accontento di un form semplice come quello che ho fatto ma invece di darmi il messaggio in una pagina bianca, vorrei che me lo desse in un alert box. tutto qui..</p>
]]></description><link>https://dev.connect.gt/post/976114</link><guid isPermaLink="true">https://dev.connect.gt/post/976114</guid><dc:creator><![CDATA[pe.ma]]></dc:creator><pubDate>Sun, 20 Feb 2011 17:35:43 GMT</pubDate></item><item><title><![CDATA[Reply to Messaggio popup da contact form on Sun, 20 Feb 2011 17:27:30 GMT]]></title><description><![CDATA[<p dir="auto">Il controllo degli errori io lo farei a priori, prima di inviare il form, perchè gia prima sai se il form è compilato correttamente.</p>
]]></description><link>https://dev.connect.gt/post/976106</link><guid isPermaLink="true">https://dev.connect.gt/post/976106</guid><dc:creator><![CDATA[marcocarrieri]]></dc:creator><pubDate>Sun, 20 Feb 2011 17:27:30 GMT</pubDate></item><item><title><![CDATA[Reply to Messaggio popup da contact form on Sun, 20 Feb 2011 17:16:36 GMT]]></title><description><![CDATA[<p dir="auto">No, un box di alert che mi scriva che il messaggio è stato inviato o che ci sono errori nella compilazione del form.</p>
]]></description><link>https://dev.connect.gt/post/976113</link><guid isPermaLink="true">https://dev.connect.gt/post/976113</guid><dc:creator><![CDATA[pe.ma]]></dc:creator><pubDate>Sun, 20 Feb 2011 17:16:36 GMT</pubDate></item><item><title><![CDATA[Reply to Messaggio popup da contact form on Sun, 20 Feb 2011 14:57:06 GMT]]></title><description><![CDATA[<p dir="auto">Quindi un box alert che effettivamete, mostrando un resoconto delle informazioni, ti dica se vuoi continuare a inviare le informazioni o no?</p>
]]></description><link>https://dev.connect.gt/post/976105</link><guid isPermaLink="true">https://dev.connect.gt/post/976105</guid><dc:creator><![CDATA[marcocarrieri]]></dc:creator><pubDate>Sun, 20 Feb 2011 14:57:06 GMT</pubDate></item><item><title><![CDATA[Reply to Messaggio popup da contact form on Sun, 20 Feb 2011 14:54:46 GMT]]></title><description><![CDATA[<p dir="auto">un box di alert non un popup....scusate..</p>
]]></description><link>https://dev.connect.gt/post/976112</link><guid isPermaLink="true">https://dev.connect.gt/post/976112</guid><dc:creator><![CDATA[pe.ma]]></dc:creator><pubDate>Sun, 20 Feb 2011 14:54:46 GMT</pubDate></item></channel></rss>