Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jan 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problem with contacts form

    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
    Code:
    <div class="wrapper contPad">
          <h2>Contattami</h2>
          <form id="form1" action="mail.php" method="post">
              <div>
        	   <fieldset>
    			<label>NOME</label> 
    									
        			<input name="field_name" input type="text" class="input" value="Almeno 3 caratteri" > 
    
        			<br>
    										
    			<label>E-MAIL:</label> 
    										
                            <input name="field_email" input type="text" class="input" value="Indirizzo valido di posta elettronica"/>
        										
        			<br>
    										
    			<label>MESSAGGIO:</label>
    										
        			<textarea name="field_message" cols="40" rows="7"></textarea>
        										
        			<br><br>
        								
                            <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>
        	  </fieldset>
            </div>
        </form>
                              
    </div>
    PHP code
    PHP Code:
    <?php
    $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';
    </script>
    <?php
    }
    else { 
    ?>
    <script language="javascript" type="text/javascript">
    alert('Recapito fallito.Per favore riprovare ad eseguire la richiesta più tardi');
    window.location = 'contatti.html';
    </script>
    <?php
    }
    ?>
    Last edited by tifone7; 01-03-2013 at 04:04 PM.

  • #2
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    Your form has the id 'form1' but you are referring to

    document.getElementById('ContactForm')

    which does not exist.
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS

  • #3
    New to the CF scene
    Join Date
    Jan 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #4
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    Code:
    <input type="submit" id="bSubmit" name="bSubmit" value="Send">
    will submit the form when clicked.
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •