Jump to content
  • 0

Odesílání emailu pomocí ajax


jAk3r

Dotaz

Zdravím, jak již jste z názvu téma pochopily v čem mám asi problém ale řeknu jej ještě jednou :)

 

Mám web na kterém mám send mailer tak jak je na php-fusion že prostě zadáte informační e-mail potom třeba jméno a pak zprávu a dáte odeslat a ono se to odešle na před definovaný email. jenže to úplně tak nefunguje..proto se snažím sehnat pomoc od vás.. zde přikládám kód-->

 

 

 

Contact.php

form id="form"  action="submit">
                        	<div class="form_left">
                           
                                <label>Name <small><em>(required)</em></small></label>
                                <input name="name" type="text" class="validate[required,custom[onlyLetter],length[0,100]] text-input" id="name" />
                             
                                <label>Email <small><em>(required)</em></small></label>
                                <input name="email" type="text" class="validate[required,custom[email]] text-input" id="email" />
                              
                                <label>Website</label>
                                <input type="text" name="web" id="web" />
                          
                            </div>
                            <div class="form_right">
                            <p class="text">
                            <label>Your Message <small><em>(required)</em></small></label>
                            <textarea name="text" class="validate[required,length[6,300]] text-input" id="comment" cols="10" rows="10"></textarea>
                            </p>
    						</div>
                            
                            <div class="form_submit"><input type="submit" value="post" class="read_more2" />
                            </div>
                        </form>
<!--******* Javascript Code for the comment form *******-->
<script type="text/javascript">
$(document).ready(function() {

	// SUCCESS AJAX CALL, replace "success: false," by:     success : function() { callSuccessFunction() }, 
	$("#form").validationEngine({
		ajaxSubmit: true,
			ajaxSubmitFile: "ajaxSubmit.php",
			ajaxSubmitMessage: "Thank you, your post has been submitted!",
		success :  false, ajaxSubmitMessage: "Thank you, your post has been submitted!",
		failure : function() {}
	})


});
</script>

a zda přikládám onen zmíněný ajaxSubmit.php

<?php

$name = ($_POST['name']); // contain name of person
$email = ($_POST['email']); // Email address of sender 
$web = ($_POST['web']); // Your website URL
$body = ($_POST['text']); // Your message 
$receiver = "[email protected]" ; // hardcorde your email address here - This is the email address that all your feedbacks will be sent to 
if (!empty($name) & !empty($email) && !empty($body)) {
    $body = "Name:{$name}\n\nWebsite :{$web}\n\nComments:{$body}";
	$send = mail($receiver, 'Contact Form Submission', $body, "From: {$email}");
    if ($send) {
        echo 'true'; //if everything is ok,always return true , else ajax submission won't work
    }

}

?>
  

 

 

Předem díky za pomoc :)

Link to comment
Share on other sites

0 odpovědí na tuto otázku

Recommended Posts

There have been no answers to this question yet

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...