View Full Version : Problem with contacts form

01-03-2013, 05:00 PM
Hi guys.
First of all it's been a long time since i follw you and your community.How many helps i f've found through these pages!!:)
So thank for any help you will able to give me in the future.I'm a newbie.Sorry for my english, i'm writing from Italy..:)
My problem is..I'm making a new site, full js based. In the contact form submit and clear buttons don't work. I'm pretty sure html code and php work, because they work well in onother site i made (html and css).
I think the problem is the instruction onClick="document.getElementById that doesn't work with js site..can you help me?

HTML code

<div class="wrapper contPad">
<form id="form1" action="mail.php" method="post">

<input name="field_name" input type="text" class="input" value="Almeno 3 caratteri" >



<input name="field_email" input type="text" class="input" value="Indirizzo valido di posta elettronica"/>



<textarea name="field_message" cols="40" rows="7"></textarea>


<div class="btns right"> <a href="#" class="button" onClick="document.getElementById('ContactForm').reset()">clear</a>
<a href="#" class="button" onClick="document.getElementById('ContactForm').submit()">Send</a></div>


PHP code

$field_name = $_POST['field_name'];
$field_email = $_POST['field_email'];
$field_message = $_POST['field_message'];

$mail_to = 'deep_purple@tin.it';
$subject = 'Richiesta di informazioni da parte di '.$field_name;

$body_message = 'Nominativo: '.$field_name."\n";
$body_message .= 'E-mail: '.$field_email."\n";
$body_message .= 'Messaggio: '.$field_message."\n";

$headers = 'From: '.$field_email."\r\n";
$headers .= 'Reply-To: '.$field_email."\r\n";

$mail_status = mail($mail_to, $subject, $body_message, $headers);

if ($mail_status) { ?>
<script language="javascript" type="text/javascript">
alert('Grazie per la richiesta inoltrata. Sarete contattati quanto prima.');
window.location = 'contatti.html';
else { ?>
<script language="javascript" type="text/javascript">
alert('Recapito fallito.Per favore riprovare ad eseguire la richiesta pił tardi');
window.location = 'contatti.html';

01-04-2013, 01:24 AM
Your form has the id 'form1' but you are referring to


which does not exist.

01-04-2013, 09:39 AM
Ok,thks Andrew.I've changed the error. However the problem remains.
If i keep the php file there's something in html code that i can change?.For exemple can i use input type="submit"? what do i have to change to make work the button "Send"?
Thank you

01-04-2013, 08:38 PM
<input type="submit" id="bSubmit" name="bSubmit" value="Send">

will submit the form when clicked.