2013-04-05 44 views
0

http://webexpedition18.com/download/signup_form_WebExpedition18/多级联络表 - PHP

家伙嗨,

以上的多级接触的形式为自己的项目的伟大工程。它看起来不错,并且做了诀窍,但当我试图通过电子邮件获取信息时,我很难过。

所以我有一个很好看的形式,但它不会发送任何信息,所以对我来说很没用。即使我只从教程网站上传未触及的演示文件,它仍然不起作用。

这里的HTML我有:

<div id="container"> 
<form action="contact.php" method="post"> 
    <div id="first_step"> 
     <div class="form"> 
      <label for="full-name">Full Name:</label> <input id="username" 
      name="full-name" style="margin-bottom:10px;" type="text" value= 
      ""> <label for="telephone">Telephone:</label> <input id= 
      "username" name="telephone" style="margin-bottom:10px;" type= 
      "text" value=""> <label for="email-address">Email 
      Address:</label> <input id="username" name="email-address" 
      style="margin-bottom:10px;" type="text" value=""> 
     </div> 

     <div class="clear"></div><input class="submit" id="submit_first" 
     name="submit_first" type="submit" value="Next"> 
    </div> 

    <div class="clear"></div> 

    <div id="second_step"> 
     <div class="form"> 
      <label for="company-name">Company Name (if you have 
      one):</label> <input id="username" name="company-name" style= 
      "margin-bottom:10px;" type="text" value=""> <label for= 
      "existing-website">Existing Website (if you have one):</label> 
      <input id="username" name="existing-website" style= 
      "margin-bottom:10px;" type="text" value=""> <label for= 
      "existing-domain">What domain would you like the new website to 
      be on?</label> <input id="username" name="existing-domain" 
      style="margin-bottom:10px;" type="text" value=""> 
     </div> 

     <div class="clear"></div><input class="submit" id="submit_second" 
     name="submit_second" type="submit" value="Next"> 
    </div> 

    <div class="clear"></div> 

    <div id="third_step"> 
     <div class="form"> 
      <label for="which-package">Which package would you 
      like?:</label> 

      <p><label><input id="RadioGroup1_0" name="RadioGroup1" type= 
      "radio" value="Standard"> Standard</label> <label><input id= 
      "RadioGroup1_1" name="RadioGroup1" type="radio" value= 
      "Business"> Business</label> <label><input id="RadioGroup1_2" 
      name="RadioGroup1" type="radio" value="Professional"> 
      Professional</label></p><label for="which-template">Which 
      template would you like?:</label> 

      <p><label><input id="RadioGroup2_0" name="RadioGroup2" type= 
      "radio" value="1"> 1</label> <label><input id= 
      "RadioGroup2_1" name="RadioGroup2" type="radio" value= 
      "2"> 2</label> <label><input id="RadioGroup2_2" 
      name="RadioGroup2" type="radio" value="3"> 
      3</label></p> 

      <div class="clear"></div> 
     </div> 

     <div class="clear"></div><input class="submit" id="submit_third" 
     name="submit_third" type="submit" value="Next"> 
    </div> 

    <div class="clear"></div> 

    <div id="fourth_step"> 
     <div class="form"> 
      <h2>All done ...</h2> 

      <p style="margin-top:30px;">Press 'Submit' and we'll send you 
      everything you need to get you up and running.</p> 
     </div> 

     <div class="clear"></div><input class="send submit" id= 
     "submit_fourth" name="submit_fourth" type="submit" value="Submit"> 
    </div> 
</form> 
</div> 
</div> 

提交按钮只是没有做任何事情。我在我的contact.php文件中尝试了许多不同的php表单处理程序代码,但我仍然得不到任何东西。

任何帮助是非常感谢的家伙。 6个小时后,我现在非常绝望。

谢谢。

附带演示的JS文件是:

$(function(){ 
//original field values 
var field_values = { 
     //id  : value 
     'username' : 'username', 
     'password' : 'password', 
     'cpassword' : 'password', 
     'firstname' : 'first name', 
     'lastname' : 'last name', 
     'email' : 'email address' 
}; 


//inputfocus 
$('input#username').inputfocus({ value: field_values['username'] }); 
$('input#password').inputfocus({ value: field_values['password'] }); 
$('input#cpassword').inputfocus({ value: field_values['cpassword'] }); 
$('input#lastname').inputfocus({ value: field_values['lastname'] }); 
$('input#firstname').inputfocus({ value: field_values['firstname'] }); 
$('input#email').inputfocus({ value: field_values['email'] }); 




//reset progress bar 
$('#progress').css('width','0'); 
$('#progress_text').html('0% Complete'); 

//first_step 
$('form').submit(function(){ return false; }); 
$('#submit_first').click(function(){ 
    //remove classes 
    $('#first_step input').removeClass('error').removeClass('valid'); 

    //ckeck if inputs aren't empty 
    var fields = $('#first_step input[type=text], #first_step input[type=password]'); 
    var error = 0; 
    fields.each(function(){ 
     var value = $(this).val(); 
     if(value.length<4 || value==field_values[$(this).attr('id')]) { 
      $(this).addClass('error'); 
      $(this).effect("shake", { times:3 }, 50); 

      error++; 
     } else { 
      $(this).addClass('valid'); 
     } 
    });   

    if(!error) { 
     if($('#password').val() != $('#cpassword').val()) { 
       $('#first_step input[type=password]').each(function(){ 
        $(this).removeClass('valid').addClass('error'); 
        $(this).effect("shake", { times:3 }, 50); 
       }); 

       return false; 
     } else { 
      //update progress bar 
      $('#progress_text').html('33% Complete'); 
      $('#progress').css('width','113px'); 

      //slide steps 
      $('#first_step').slideUp(); 
      $('#second_step').slideDown();  
     }    
    } else return false; 
}); 


$('#submit_second').click(function(){ 
    //remove classes 
    $('#second_step input').removeClass('error').removeClass('valid'); 

    var emailPattern = /^[a-zA-Z0-9._-][email protected][a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; 
    var fields = $('#second_step input[type=text]'); 
    var error = 0; 
    fields.each(function(){ 
     var value = $(this).val(); 
     if(value.length<1 || value==field_values[$(this).attr('id')] || ( $(this).attr('id')=='email' && !emailPattern.test(value))) { 
      $(this).addClass('error'); 
      $(this).effect("shake", { times:3 }, 50); 

      error++; 
     } else { 
      $(this).addClass('valid'); 
     } 
    }); 

    if(!error) { 
      //update progress bar 
      $('#progress_text').html('66% Complete'); 
      $('#progress').css('width','226px'); 

      //slide steps 
      $('#second_step').slideUp(); 
      $('#third_step').slideDown();  
    } else return false; 

}); 


$('#submit_third').click(function(){ 
    //update progress bar 
    $('#progress_text').html('100% Complete'); 
    $('#progress').css('width','339px'); 

    //prepare the fourth step 
    var fields = new Array(
     $('#username').val(), 
     $('#password').val(), 
     $('#email').val(), 
     $('#firstname').val() + ' ' + $('#lastname').val(), 
     $('#age').val(), 
     $('#gender').val(), 
     $('#country').val()      
    ); 
    var tr = $('#fourth_step tr'); 
    tr.each(function(){ 
     //alert(fields[$(this).index()]) 
     $(this).children('td:nth-child(2)').html(fields[$(this).index()]); 
    }); 

    //slide steps 
    $('#third_step').slideUp(); 
    $('#fourth_step').slideDown();    
}); 


$('#submit_fourth').click(function(){ 
    //send information to server 
    alert('Sent. Thank you!'); 
}); 

}); 

而且PHP是我的contact.php文件中使用的是:

<?php 
$errors = ''; 
$myemail = '[email protected]';//<-----Put Your email address here. 
if(empty($_POST['name']) || 
empty($_POST['email']) || 
empty($_POST['message'])) 
{ 
$errors .= "\n Error: all fields are required"; 
} 

$name = $_POST['name']; 
$email_address = $_POST['email']; 
$message = $_POST['message']; 

if (!preg_match(
"/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", 
$email_address)) 
{ 
$errors .= "\n Error: Invalid email address"; 
} 

if(empty($errors)) 
{ 
$to = $myemail; 
$email_subject = "Contact form submission: $name"; 
$email_body = "You have received a new message. ". 
" Here are the details:\n Name: $name \n Email: $email_address \n Message \n $message"; 

$headers = "From: $myemail\n"; 
$headers .= "Reply-To: $email_address"; 

mail($to,$email_subject,$email_body,$headers); 
//redirect to the 'thank you' page 
header('Location: contact-form-thank-you.html'); 
} 
?> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 

http://www.w3.org/TR/html4/loose.dtd”>

<html> 
<head> 
<title>Contact form handler</title> 
</head> 

<body> 
<!-- This page is displayed only if there is some error --> 
<?php 
    echo nl2br($errors); 
    ?> 
</body> 
</html> 
+1

也许如果你实际上添加了一些PHP。我在任何地方都看不到“contact.php”或任何形式的动作。如果'action =“#”'和你的页面中没有任何PHP,那么它不会执行任何操作。 – cygorx 2013-04-05 21:45:28

+0

这需要很大的未显示的javascript来做_anything_。 – Wrikken 2013-04-05 21:46:44

+0

基本上任何出发点将非常感激。我曾尝试修改负载不同的contactform处理程序来使用此html,但我无法得到任何东西,使提交按钮工作丝毫。谢谢。 – user1386796 2013-04-05 21:55:14

回答

0

$('form').submit(function(){ return false; });告诉提交应该返回false

+0

嗨,谢谢你,但没有告诉第一步不要提交... – user1386796 2013-04-05 22:34:28

+0

// first_step $('form')。submit(function(){return false;}); ()函数(){ – user1386796 2013-04-05 22:35:14

+0

不,它会告诉提交应该返回false,而不管它是哪一步(它每次执行$(function()被执行)。尝试取消它的注释并且你会看到 – bestprogrammerintheworld 2013-04-05 22:38:10