Hello guys, I'm trying to make a simple php form working but for any reason it doesn't work. I'm going to write there the form code, I hope you can help me out. <form id="contact-form" action="contactmail.php" method="post" class="main-contacts" name="SampleForm"> <fieldset> <input type="hidden" name="owner_email" id="owner_email" value="info@mydomain.com" /> <input type="hidden" name="serverProcessorType" id="serverProcessorType" value="asp" /> <input type="hidden" name="smtpMailServer" id="smtpMailServer" value="localhost" /> <input type="hidden" name="stripHTML" id="stripHTML" value="true" /> <div class="rowElem"> <input type="text" name="name" id="name" value="Name:" onFocus="if(this.value=='Name:'){this.value=''}" onBlur="if(this.value==''){this.value='Name:'}" /> <label class="error" for="name" id="name_error">*Campo obbligatorio.</label> <label class="error" for="name" id="name_error2">*Nome non valido.</label> </div> <div class="rowElem"> <input type="text" name="email" id="email" value="E-mail:" onFocus="if(this.value=='E-mail:'){this.value=''}" onBlur="if(this.value==''){this.value='E-mail:'}" /> <label class="error" for="email" id="email_error">*Campo obbligatorio.</label> <label class="error" for="email" id="email_error2">*Indirizzo email non valido.</label> </div> <div class="rowElem"> <input type="text" name="Phone" id="phone" value="Phone:" onFocus="if(this.value=='Phone:'){this.value=''}" onBlur="if(this.value==''){this.value='Phone:'}" /> <label class="error" for="phone" id="phone_error">*Questo campo è obbligatorio.</label> <label class="error" for="phone" id="phone_error2">*Numero di telefono non valido.</label> </div> <div class="textarea-box"> <textarea onFocus="if(this.value=='Message:'){this.value=''}" onBlur="if(this.value==''){this.value='Message:'}" name="message" id="message">Message:</textarea><br> <label class="error" for="message" id="message_error">*Questo campo è obbligatorio.</label> <label class="error" for="message" id="message_error2">*Il messaggio inserito è troppo corto.</label> </div> <div class="alignright buttons"> <a href="#" id="clear" class="button1 link-1"><span><span>CANCELLA</span></span></a><a href="#" id="submit" class="button2 link-1" ><span><span>INVIA rICHIESTA</span></span></a> </div> </fieldset> </form> OK, and this is the php page code: <?php var_dump($_POST); $Nombre = $_POST['name']; $Teléfono = $_POST['phone']; $email = $_POST['email']; $Mensaje = $_POST['message']; if (!empty($_POST['name'])) $Nombre = $_POST['name']; else $Nombre = "-"; if (!empty($_POST['phone'])) $Teléfono = $_POST['phone']; else $Teléfono = "-"; if (!empty($_POST['email'])) $email = $_POST['email']; else $email = "-"; if (!empty($_POST['message'])) $Mensaje = $_POST['message']; else $Mensaje = "-"; $mensaje = "Este mensaje fue enviado por: " . $Nombre . " \r\n"; $mensaje .= "Su e-mail es: " . $email . " \r\n"; $mensaje .= "Su telefono es: " . $Teléfono . " \r\n"; $mensaje .= "Mensaje: " . $Mensaje . " \r\n"; $mensaje .= "Enviado el " . date("d/m/y \a \l\a\s H:i:s "); $mail = "info@mydomain.com"; $mailSubject = "Contacto desde pagina web"; mail($mail, $mailSubject, utf8_decode($mensaje)); ?> Thank you everybody in advance.
"it doesn't work" doesn't tell us much. What is it doing? What isn't it doing. You're going to have to do a little debugging so that we can figure out what's happening. If it's just not sending email, are you sure that your host is set up to send email? That's not always the case.
Hi, thank you for your reply. Well, the problem is just the form does not send the email to the email address I wrote. When I fill in the form, it says "thank you for your message. we will right back." About the host, I'm using hostgator as hosting and all the website is up and running correctly. Have I to do something in particular in order to set up the host for the form? In your opinion the problem is this: <input type="hidden" name="smtpMailServer" id="smtpMailServer" value="localhost" /> should I write the ip address of the server instead of localhost? Thank you.
While I am by no means an ASP expert, I do not see how your code could be related to it in any way. mail($mail, $mailSubject, utf8_decode($mensaje)) or die("mail() failed!"); PHP: What does it say if you alter your code as shown above ?
Do the var dumps show you what you expect? I don't like that you have $mensaje and $Mensaje - never tried it but its a risky practice that few would recommend. If you var dump $mensaje do you get a nicely formatted message? to test that mail is working put a simple mail command at the top. time() can be the subject and '' can be the body.
Hi, I quite fixed it. Instead of localhost I put the server IP address and then instead of <input type="hidden" name="serverProcessorType" id="serverProcessorType" value="asp" /> I put <input type="hidden" name="serverProcessorType" id="serverProcessorType" value="PHP" /> thank you all for your replies.
Really I don't use them? anyway, all other things are the same as written in the first post and earlier it didn't work, now it works