CodeWalrus

Development => Web => Topic started by: Dudeman313 on March 28, 2016, 03:39:48 PM

Title: Contact Form Not Working
Post by: Dudeman313 on March 28, 2016, 03:39:48 PM
I'm creating a website with a Page Builder made for the Greater Southern Tier Districts.
I tried to create a contact form, but I can't figure out how to make the form send the message to my email.

Contact Form:


<divz id="p473I"><!--NEW ID-->
    <script>
$(document).ready(function(){
        $('#send_message').click(function(e){
           
            //Stop form submission & check the validation
            e.preventDefault();
           
            // Variable declaration
            var error = false;
            var name = $('#name').val();
            var email = $('#email').val();
            var message = $('#message').val();
            var txtInput = $('#txtInput').val();

          // Form field validation
            if(name.length == 0){
                var error = true;
                $('#name_error').fadeIn(500);
            }else{
                $('#name_error').fadeOut(500);
            }
            if(email.length == 0 || email.indexOf('@') == '-1'){
                var error = true;
                $('#email_error').fadeIn(500);
            }else{
                $('#email_error').fadeOut(500);
            }
            if(message.length == 0){
                var error = true;
                $('#message_error').fadeIn(500);
            }else{
                $('#message_error').fadeOut(500);
            }
if(txtInput.length == 0){
                var error = true;
                $('#txtInput_error').fadeIn(500);
            }else{
                var str1 = removeSpaces(document.getElementById('txtCaptcha').value);
var str2 = removeSpaces(document.getElementById('txtInput').value);
if (str1 == str2){
$('#txtInput_error').fadeOut(500);
}else{
$('#txtInput_error').fadeIn(500);
var error = true;
}
            }
           
            if(error == false){
               // Disable submit button just after the form processed 1st time successfully.
                $('#send_message').attr({'disabled' : 'true', 'value' : 'Sending...' });
               
$.post("http://pages.gstboces.org/page/sendMail.cfm", $("#contact_form").serialize(),function(result){
                    //Check the result set
                    if(result == 'sent'){
                        //If the email is sent successfully, remove the submit button
                         $('#submit').remove();
                        //Display the success message
                        $('#mail_success').fadeIn(500);
                    }else{
                        //Display the error message
                        $('#mail_fail').fadeIn(500);
                        // Enable the submit button again
                        $('#send_message').removeAttr('disabled').attr('value', 'Send The Message');
                    }
                });
            }
        });   
//Generates the captcha function
var a = Math.ceil(Math.random() * 9)+ "";
var b = Math.ceil(Math.random() * 9)+ "";
var c = Math.ceil(Math.random() * 9)+ "";
var d = Math.ceil(Math.random() * 9)+ "";
var e = Math.ceil(Math.random() * 9)+ "";

var code = a + b + c + d + e;
document.getElementById("txtCaptcha").value = code;
document.getElementById("txtCaptchaDiv").innerHTML = code;
    });


// Validate the Entered input aganist the generated security code function
function ValidCaptcha(){
var str1 = removeSpaces(document.getElementById('txtCaptcha').value);
var str2 = removeSpaces(document.getElementById('txtInput').value);
alert(str1);alert(str2);
if (str1 == str2){
return true;
}else{
return false;
}
}

// Remove the spaces from the entered and generated code
function removeSpaces(string){
return string.split(" ").join("");
}
</script>
    <style>
.error{display:none;padding:10px;margin:0 0 5px 0;color:#D8000C;font-size:12px;background-color:#FFBABA;}
.success{display:none;padding:10px;color:#044406;font-size:12px;background-color:#B7FBB9;}
</style>
    <div class="item contact" id="contact2">
       
    <div class="container">
   
    <div class="col-md-4 col-md-offset-2">
   
    <h4>Contact me</h4>
   
    <p>
    Click "Content" above and then you can click here to edit this text.
    </p>
   
    <p class="small">
    Thank you
    </p>
   
    </div><!-- ./col-md-4 -->
   
    <div class="col-md-4 col-offset-2">
    <h4>Get in touch</h4>
   
    <form role="form" action="sendMail.cfm" name="contactForm" id="contact_form" enctype="text/plain" method="post">
    <div id="name_error" class="error">Please enter your name.</div>

    <div class="form-group">
        <input type="text" class="form-control input-lg" id="name" name="name" placeholder="Your name *">
      </div>
      <div id="email_error" class="error">Please enter your valid E-mail ID.</div>
     
      <div class="form-group">
      <input type="email" class="form-control input-lg" id="email" name="email" placeholder="Your email *">
      </div>
      <div id="message_error" class="error">Please enter your message.</div>

      <div class="form-group">
      <textarea class="form-control" rows="4" id="message" name="message" placeholder="Add comment..."></textarea>
      </div>
                        <div id="mail_success" class="success">Your message has been sent successfully.</div>
<div id="mail_fail" class="error">Sorry, error occured this time sending your message.</div>
                        <div>
<font color="#DD0000">Enter Code &gt;</font>
                            <span id="txtCaptchaDiv" style="background-color:#A51D22;color:#FFF;padding:5px">94145</span>
<input type="hidden" id="txtCaptcha" value="94145">
                            <input type="text" name="txtInput" id="txtInput" size="15">
                            <div id="txtInput_error" class="error">Please enter code shown.</div>
</div>

          <p id="submit">  
      <button type="submit" id="send_message" class="btn btn-primary btn-embossed btn-lg btn-wide"><span class="fui-mail"></span> Submit</button> </p>
   
    </form>
   
    </div><!-- /.col-md-4 -->
   
    </div><!-- /.container -->
       
    </div><!-- /.item -->
   
    <p align="right"><a href="#top" style="text-decoration:underline;">Top</a></p> </divz><!--NEW ID-->

Here's the actual site: http://pages.gstboces.org/StudHaven
Title: Re: Contact Form Not Working
Post by: Jokeriske on March 29, 2016, 06:15:36 AM
i've noticed some typo's, in the first line there is a "z" after the DIV tag
Title: Re: Contact Form Not Working
Post by: Dudeman313 on March 29, 2016, 12:51:40 PM
Quote from: Jokeriske on March 29, 2016, 06:15:36 AM
i've noticed some typo's, in the first line there is a "z" after the DIV tag
The entire block is in a "<divz></divz>" tag.
I just want to know where the info is sent and how to change it.
Title: Re: Contact Form Not Working
Post by: ben_g on March 29, 2016, 02:18:50 PM

$.post("http://pages.gstboces.org/page/sendMail.cfm", $("#contact_form").serialize(),function(result){

I guess the form information is sent to the script at http://pages.gstboces.org/page/sendMail.cfm . The email adress is probably defined in that file.
Title: Re: Contact Form Not Working
Post by: Dream of Omnimaga on March 29, 2016, 02:49:58 PM
Quote from: Dudeman313 on March 29, 2016, 12:51:40 PM
Quote from: Jokeriske on March 29, 2016, 06:15:36 AM
i've noticed some typo's, in the first line there is a "z" after the DIV tag
The entire block is in a "<divz></divz>" tag.
I just want to know where the info is sent and how to change it.
<divz> tags don't exist in HTML. I just checked Google and there's no indication that they're valid HTML. Could this make the HTML parser have troubles parsing the contact form or at least cause issues with the PHP script?
Title: Re: Contact Form Not Working
Post by: Adriweb on March 29, 2016, 06:27:50 PM
Technically.... https://w3c.github.io/webcomponents/spec/custom/ :P
Title: Re: Contact Form Not Working
Post by: Dudeman313 on March 29, 2016, 08:29:55 PM
Quote from: ben_g on March 29, 2016, 02:18:50 PM

$.post("http://pages.gstboces.org/page/sendMail.cfm", $("#contact_form").serialize(),function(result){

I guess the form information is sent to the script at http://pages.gstboces.org/page/sendMail.cfm . The email adress is probably defined in that file.
To me, that cannot be accessed.  :-\

Quote from: DJ Omnimaga on March 29, 2016, 02:49:58 PM
Quote from: Dudeman313 on March 29, 2016, 12:51:40 PM
Quote from: Jokeriske on March 29, 2016, 06:15:36 AM
i've noticed some typo's, in the first line there is a "z" after the DIV tag
The entire block is in a "<divz></divz>" tag.
I just want to know where the info is sent and how to change it.
<divz> tags don't exist in HTML. I just checked Google and there's no indication that they're valid HTML. Could this make the HTML parser have troubles parsing the contact form or at least cause issues with the PHP script?

Quote from: Adriweb on March 29, 2016, 06:27:50 PM
Technically.... https://w3c.github.io/webcomponents/spec/custom/ :P
It makes sense to me that BOCES would use custom tags in their site builder to create individual blocks.
The entire Builder is built on the simplicity of drag and drop, but also allows you to edit the blocks' source.

Maybe I just won't be able to use their Contact form, but if I can't, how can I put in my own?
Title: Re: Contact Form Not Working
Post by: Dream of Omnimaga on March 29, 2016, 08:35:18 PM
Are you sure that your web hosting provider allows you to send e-mails? Some hosting providers block such features, IIRC.

I sadly can't help you much, though.
Title: Re: Contact Form Not Working
Post by: Dudeman313 on March 29, 2016, 08:42:38 PM
Quote from: DJ Omnimaga on March 29, 2016, 08:35:18 PM
Are you sure that your web hosting provider allows you to send e-mails? Some hosting providers block such features, IIRC.

I sadly can't help you much, though.
Nope. The block is there, so I assumed I could. When I was editing the site, I sent a message "successfully"  somehow, but I didn't know where.

Is there a way to put IRC into the website? I want to make an online chat room just for the site.
Title: Re: Contact Form Not Working
Post by: Dream of Omnimaga on March 29, 2016, 08:46:18 PM
Just because the block is there doesn't mean the code will work on every server. The form might show up, but fail to send properly. In your case, though, it does send fine, but at an unspecified location. Hopefully someone knows the answer (but you might need to ask on Stackexchange or something if that fails)

As for putting IRC on your website, you could use OmnomIRC or WalrusIRC, but you would need a place to host the bots.

Now the next question is why you need a shoutbox? Are you making a new site that intends to compete against Cemetech, CodeWalrus and Omnimaga? Judging from the fact that all three sites combined can barely even average at 100 posts total per day, I don't think there is enough demand for another calc-oriented forum/chat. Even when Omnimaga alone had 150 posts per day, United-TI didn't survive.
Title: Re: Contact Form Not Working
Post by: Dudeman313 on March 29, 2016, 08:55:16 PM
Quote from: DJ Omnimaga on March 29, 2016, 08:46:18 PM
Just because the block is there doesn't mean the code will work on every server. The form might show up, but fail to send properly. In your case, though, it does send fine, but at an unspecified location. Hopefully someone knows the answer (but you might need to ask on Stackexchange or something if that fails)

As for putting IRC on your website, you could use OmnomIRC or WalrusIRC, but you would need a place to host the bots.

Now the next question is why you need a shoutbox? Are you making a new site that intends to compete against Cemetech, CodeWalrus and Omnimaga? Judging from the fact that all three sites combined can barely even average at 100 posts total per day, I don't think there is enough demand for another calc-oriented forum/chat. Even when Omnimaga alone had 150 posts per day, United-TI didn't survive.
I didn't think of that. I'll probably just abandon the idea.

I just want a chat room just for my website. I don't want to use another site's, because my site isn't about calculators at all.

No...did you check out the link in the first post? It's not even a forum.
Here's a screenshot of the first page:
(http://i.imgur.com/qDaZlBK.png)

[spoiler=Oops...]
I may or may not have stolen your :trollface: for my site there...
|s it copy-righted?
[/spoiler]
Title: Re: Contact Form Not Working
Post by: Dream of Omnimaga on March 29, 2016, 09:26:45 PM
Lol, Trollface is an internet meme and we got it from there anyway, so it's fine. :P Also I like the design :3=
Title: Re: Contact Form Not Working
Post by: Dudeman313 on March 29, 2016, 09:32:08 PM
Notice that I used Steve as my mascot. :)
So, about making a private chat room for my site?
I want to use it for Homework Help and just plain chatting.
Would I be able to make an embedded IRC client thingy and then make a channel(for free), or would I be better off with a chat room?

Also, just now noticed this, but if you accidentally hit the back button while making a post, you can hit the forward button and your stuff is still there!  :thumbsup:
Title: Re: Contact Form Not Working
Post by: Jokeriske on March 30, 2016, 06:30:52 AM
i don't want to bring up negativity but before you try to build a website you should learn the basics before you build something, i also started to program before i even could do anything, so i suggest to learn some basics so you can understand it.
Title: Re: Contact Form Not Working
Post by: Dream of Omnimaga on March 30, 2016, 03:36:18 PM
@Jokeriske in his case, I think it's not necessarily just experience, but also technical hosting specs that could be a problem. I'm 100% sure that he's using shared hosting and not a VPS/dedicated server, and I doubt that any shared hosting provider, especially the free or overselling ones, will be able to host a real-time chat script (most shared hosting providers disallow chat scripts). Some shared hosting providers don't even have full PHP support (some commands are disabled).

But yeah, if those scripts are allowed on his hosting provider, then he could use WalrusIRC, OmnomIRC or embed IRCCloud on his website. There are probably instructions on how to install them.


Just don't build a VPS and all its parts from scratch like a certain other forum member :P
Title: Re: Contact Form Not Working
Post by: Dudeman313 on March 31, 2016, 09:49:57 PM
Quote from: Jokeriske on March 29, 2016, 06:15:36 AM
i've noticed some typo's, in the first line there is a "z" after the DIV tag
@Jokeriske , I just now found out that <divz> is the builder's custom name for the <body> tag, because I cannot put <body> tags into them without an error.

Quote from: Jokeriske on March 30, 2016, 06:30:52 AM
i don't want to bring up negativity but before you try to build a website you should learn the basics before you build something, i also started to program before i even could do anything, so i suggest to learn some basics so you can understand it.

Quote from: DJ Omnimaga on March 30, 2016, 03:36:18 PM
@Jokeriske in his case, I think it's not necessarily just experience, but also technical hosting specs that could be a problem. I'm 100% sure that he's using shared hosting and not a VPS/dedicated server, and I doubt that any shared hosting provider, especially the free or overselling ones, will be able to host a real-time chat script (most shared hosting providers disallow chat scripts). Some shared hosting providers don't even have full PHP support (some commands are disabled).

But yeah, if those scripts are allowed on his hosting provider, then he could use WalrusIRC, OmnomIRC or embed IRCCloud on his website. There are probably instructions on how to install them.
They should be. When I get to it, I'll try it.

Quote from: DJ Omnimaga on March 30, 2016, 03:36:18 PM
Just don't build a VPS and all its parts from scratch like a certain other forum member :P
Meaning Velocity? I noticed that was in the affiliates now. :)
Title: Re: Contact Form Not Working
Post by: Jokeriske on April 01, 2016, 03:17:24 PM
Quote from: DJ Omnimaga on March 30, 2016, 03:36:18 PM
@Jokeriske in his case, I think it's not necessarily just experience, but also technical hosting specs that could be a problem. I'm 100% sure that he's using shared hosting and not a VPS/dedicated server, and I doubt that any shared hosting provider, especially the free or overselling ones, will be able to host a real-time chat script (most shared hosting providers disallow chat scripts). Some shared hosting providers don't even have full PHP support (some commands are disabled).

But yeah, if those scripts are allowed on his hosting provider, then he could use WalrusIRC, OmnomIRC or embed IRCCloud on his website. There are probably instructions on how to install them.


Just don't build a VPS and all its parts from scratch like a certain other forum member :P


We build the VPS from an old computer since we don't have any budget :P
Title: Re: Contact Form Not Working
Post by: Dream of Omnimaga on April 01, 2016, 04:31:04 PM
Oh I really meant building each part from scratch. It was a joke in reference to that "Making a wire from scratch"  topic by Ephraim. :P
Title: Re: Contact Form Not Working
Post by: Dudeman313 on April 02, 2016, 02:57:56 AM
So, is there a way to embed a contact form from somewhere else?