[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Notice: in file /includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4284: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3493)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4286: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3493)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4287: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3493)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4288: Cannot modify header information - headers already sent by (output started at /includes/functions.php:3493)
www.dhtmlgoodies.com • View topic - Ajax contact form doesn't work with php
Advertisement

Ajax contact form doesn't work with php

Moderators: Calcifer, slothy

Ajax contact form doesn't work with php

Postby mizzfail (Restore) » Fri Oct 14, 2011 11:42 am

I really need help, even I found a problem but I can't resolve it.

My goal was to use a fancy animated contact form using ajax and jquery, it worked but the problem appeared that if put the correct info into required fields, the submit (enviar) button doesn't react, I don't receive the email, here you can see in the 1 example:

http://portfolio.raulpinadesign.pt/contactos1.php (you can try filling the incorrect info and correct)

the contact form works, I receive a email if just from the input "submit" I delete the class "submit". But when my animation's don't work if I put the incorrect info, because this class is described in javascript. You can check in example 2:

http://portfolio.raulpinadesign.pt/contactos.php

I don't understand in which part javascript doesn't want to work with php... here is the code of 1 example:

java code that goes in the header:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

<script type="text/JavaScript">
$(document).ready(function() {

$('.submit').click(function(e){

// Declare the function variables:
// Parent form, form URL, email regex and the error HTML
var $formId = $(this).parents('form');
var formAction = $formId.attr('action');
var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
var $error = $('<span class="error"></span>');

// Prepare the form for validation - remove previous errors
$('li',$formId).removeClass('error');
$('span.error').remove();

// Validate all inputs with the class "required"
$('.required',$formId).each(function(){

var inputVal = $(this).val();
var $parentTag = $(this).parent();
if(inputVal == ''){
$parentTag.addClass('error').append($error.clone().text('Preencha por favor'));
}

// Run the email validation using the regex for those input items also having class "email"

if($(this).hasClass('email') == true){
if(!emailReg.test(inputVal)){
$parentTag.addClass('error').append($error.clone().text('Preencha e-mail válido'));
}
}


});

// All validation complete - Check if any errors exist
// If has errors
if ($('span.error').length > 0) {

$('span.error').each(function(){

// Set the distance for the error animation
var distance = 5;

// Get the error dimensions
var width = $(this).outerWidth();

// Calculate starting position
var start = width + distance;

// Set the initial CSS
$(this).show().css({
display: 'block',
opacity: 0,
right: -start+'px'
})
// Animate the error message
.animate({
right: -width+'px',
opacity: 1
}, 'slow');

});
} else {
$formId.submit();
}
// Prevent form submission
e.preventDefault();
});

// Fade out error message when input field gains focus
$('.required').focus(function(){
var $parent = $(this).parent();
$parent.removeClass('error');
$('span.error',$parent).fadeOut();
});
});
</script>



contact form that goes in a body

<div id="formulario1">
<form id="form-sign-up" class="styled" action="mail-enviado.php" method="post">
<fieldset>
<h2>Entre em contacto connosco</h2>
<ol>
<li class="form-row"><label>Nome</label>
<input name="name" type="text" class="text-input required" />
</li>
<li class="form-row"><label>Empresa</label>
<input name="empresa" type="text" class="text-input required" />
</li>
<li class="form-row"><label>Email</label>
<input name="email" type="text" id="register-email" class="text-input required email" />
</li>
<li class="form-row"><label>Telefone</label>
<input name="telefone" type="text" class="text-input required" />
</li>
<li class="form-row"><label>Mensagem</label>
<textarea name="message" id="styled" /></textarea>
</li>
<li class="button-row">
<input type="submit" value="ENVIAR" name="submit" class="submit"/>
</li>
</ol>
</fieldset>
</form>
</div>


and php code that goes to the file mail-enviado.php

<div id="formulario1">


<div class="mensagem"><h2>MENSAGEM ENVIADO. OBRIGADO!</h2></div>

<?php
if(isset($_POST['submit'])) {
$to = "lina_balciunaite@yahoo.com";
$subject = "Trabalho";
$name_field = $_POST['name'];
$empresa_field = $_POST['empresa'];
$email_field = $_POST['email'];
$telefone_field = $_POST['telefone'];
$message = $_POST['message'];

$body = "Da: $name_field\n Empresa: $empresa_field\n E-mail: $email_field\n Telefone: $telefone_field\n Mensagem:\n $message";

mail($to, $subject, $body);
}
?>
</div>


ofcause there is also stylesheet but I think here is not important Could smb tell me what is wrong, why javascript doesn't work together with php? THANK YOU VERY MUCH!


mizzfail (Restore)
 
Posts: 0
Joined: Thu Jan 01, 1970 1:00 am

Return to General questions regarding AJAX scripts

Who is online

Users browsing this forum: No registered users and 2 guests

cron