PHP dentro JS

19 Ott 2012
4
0
0
Salve, ho appena scaricato un template ma nel modulo della forma contatti son rimasto bloccato...
in questo codice qua
Codice:
    $(document).ready(function() {
       
       //if submit button is clicked
       $('#submit').click(function () {      
          
          //Get the data from all the fields
          var name = $('input[name=name]');
          var email = $('input[name=email]');
          var website = $('input[name=website]');
          var comment = $('textarea[name=comment]');

          //Simple validation to make sure user entered something
          //If error found, add hightlight class to the text field
          if (name.val()=='') {
             name.addClass('hightlight');
             return false;
          } else name.removeClass('hightlight');
          
          if (email.val()=='') {
             email.addClass('hightlight');
             return false;
          } else email.removeClass('hightlight');
          
          if (comment.val()=='') {
             comment.addClass('hightlight');
             return false;
          } else comment.removeClass('hightlight');
          
          //organize the data properly
          var data = 'name=' + name.val() + '&email=' + email.val() + '&website=' +
          website.val() + '&comment='  + encodeURIComponent(comment.val());
          
          //disabled all the text fields
          $('.text').attr('disabled','true');
          
          //show the loading sign
          $('.loading').show();
          
          //start the ajax
          $.ajax({
             //this is the php file that processes the data and send mail
             url: "process.php",   
             
             //GET method is used
             type: "GET",

             //pass the data         
             data: data,      
             
             //Do not cache the page
             cache: false,
             
             //success
             success: function (html) {            
                //if process.php returned 1/true (send mail success)
                if (html==1) {               
                   //hide the form
                   $('.form').fadeOut('slow');               
                   
                   //show the success message
                   $('.done').fadeIn('slow');
                   
                //if process.php returned 0/false (send mail failed)
                } else alert('Sorry, unexpected error. Please try again later.');            
             }      
          });
          
          //cancel the submit button default behaviours
          return false;
       });   
    });

dove devo inserire l'email del destinatario?
grazie mille e scusate ma non ne riesco a venir fuori
 
è li dentro

Devi postare il contenuto di process.php, è lì che viene inviata l'e-mail e molto probabilmente è lì che dev'essere specificato l'indirizzo del destinatario.

il fatto è che all'interno del file di cui ho scritto prima c'è lì dentro questo pezzo

Codice:
 //start the ajax
          $.ajax({
             //this is the php file that processes the data and send mail
             url: "process.php",   
             
             //GET method is used
             type: "GET",

             //pass the data         
             data: data,      
             
             //Do not cache the page
             cache: false,
             
             //success
             success: function (html) {            
                //if process.php returned 1/true (send mail success)
                if (html==1) {               
                   //hide the form
                   $('.form').fadeOut('slow');               
                   
                   //show the success message
                   $('.done').fadeIn('slow');
                   
                //if process.php returned 0/false (send mail failed)
                } else alert('Sorry, unexpected error. Please try again later.');            
             }      
          });
          
          //cancel the submit button default behaviours
          return false;
       });   
    });

quindi è quello il process.php? perchè io non ho altri file T__T
 
Non hai altri file?
Di solito quando scarichi un template è un archivio che ha almeno 2-3 file..un html, un css per gli stili etc (cambia da template a template).
Sicuro che spacchettando non ne hai preso solo uno e gli altri li hai ignorati?
 
si ma...

Non hai altri file?
Di solito quando scarichi un template è un archivio che ha almeno 2-3 file..un html, un css per gli stili etc (cambia da template a template).
Sicuro che spacchettando non ne hai preso solo uno e gli altri li hai ignorati?

si ce li ho..ho 3 css, 3 java per le gallery, 1 index.html e questa contact-form.js che ho postato sopra...non capisco dove debba inserire sto benedetto indirizzo di posta, questo è il form nella pagina index.html

Codice:
		<form method="post" action="process.php">
						<p>Nome</p>
						<input type="text" name="name" class="text" />
						
						<p>Email</p>
						<input type="text" name="email" class="text" id="email" />

						<p>Messaggio</p>
						<textarea name="comment" class="text"></textarea>

						<input type="submit" id="submit" value="send" class="submit-button" />
					</form>
ed il process.php non ce l'ho, o se ce l'ho è quello che ho messo sopra nel post che è all'interno del file .js

sono in crisi, c'è in caso un alternativa?
un codice "base" che posso prendere da qualche parte ?
grazie
 
Eppure il file process.php dovrebbe stare nella stessa cartella dove c'è la pagina contact-form.js.
Puoi scaricare di nuovo il template?
 

Discussioni simili