Jump to content

Recommended Posts

Hi guys, I am redesigning my website, I want my visitors to keep upto date with things, and would like a 'get notified' email form, where users enter their email address and once the website is finised, they will get a email about it. So far, I have 3 lots of code, but I am getting an error when I upload the files to my server and try - 'Oops. Looks like something went wrong. Please try again later'.

 

Can someone take a look and see where I have gone wrong

 

This is my form code

<form action="notify-me.php" id="notifyMe" method="POST">

                                        <div class="form-group">
                                            <div class="controls">
                                                <input type="text" id="mail-sub" name="email" placeholder="Write your email and stay tuned!" class="form-control email srequiredField">
                                                <button class="btn btn-lg submit">Subscribe</button>
                                            </div>
                                        </div>

                                    </form>

This is my php code notify-me.php

<?php

## CONFIG ##

# LIST EMAIL ADDRESS
$recipient = "myemail@address.com";

# SUBJECT (Subscribe/Remove)
$subject = "Subscribe";

## FORM VALUES ##

# SENDER - WE ALSO USE THE RECIPIENT AS SENDER IN THIS SAMPLE
# DON'T INCLUDE UNFILTERED USER INPUT IN THE MAIL HEADER!
$sender = $recipient;

# MAIL BODY
$body .= "Name: ".$_REQUEST['Name']." \n";
# add more fields here if required

## SEND MESSGAE ##

mail( $recipient, $subject, $body, "From: $sender" ) or die ("Mail could not be sent.");

## SHOW RESULT PAGE ##


?>

and finally, my JS file

/*
 notifyMe jQuery Plugin v1.0.0
 Copyright (c)2014 Sergey Serafimovich
 Licensed under The MIT License.
*/
(function(e){e.fn.notifyMe=function(t){var n=e.extend({msgError404:"Service is not available at the moment. Please check your internet connection or try again later.",msgError503:"Oops. Looks like something went wrong. Please try again later.",msgErrorValidation:"This email address looks fake or invalid. Please enter a real email address.",msgErrorFormat:"Your e-mail address is incorrect. Please check it and try again.",msgSuccess:"Congrats! You are on list. We will inform you as soon as we finish."},t);var r=e(this);var i=e(this).find("input[name=email]");var s=e(this).attr("action");var o=e(this).find(".note");var u=e("<p class='message'></p>").appendTo(e(this));var a=e("<i></i>");var f="fa fa-spinner fa-spin";var l="fa fa-check-circle";var c="fa fa-exclamation-circle";i.after(a);e(this).on("submit",function(t){t.preventDefault();var h=i.val();var p=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;if(p.test(h)){a.removeClass();a.addClass(f);e(this).removeClass("error success");u.text("");o.show();e.ajax({type:"POST",url:s,data:{email:h},dataType:"json",error:function(e){r.addClass("error");o.hide();a.removeClass();a.addClass(c);if(e.status==404){u.text(n.msgError404)}else{u.text(n.msgError503)}}}).done(function(e){o.hide();if(e.status=="success"){r.addClass("success-full").removeClass("bad-email");a.removeClass();a.addClass(l);u.text(n.msgSuccess)}else{r.addClass("error");a.removeClass();a.addClass(c);if(e.type=="ValidationError"){u.text(n.msgErrorValidation)}else{u.text(n.msgError503)}}})}else{e(this).addClass("bad-email");o.hide();a.removeClass();a.addClass(c);u.text(n.msgErrorFormat)}})}})(jQuery)

Link to comment
https://forums.phpfreaks.com/topic/297184-notify-php-script-help/
Share on other sites

  • 1 month later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.