Join us on Discord!
You can help CodeWalrus stay online by donating here.

Contact Form Not Working

Started by Dudeman313, March 28, 2016, 03:39:48 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Dudeman313

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
  • Calculators owned: TI-84 PCE
  • Consoles, mobile devices and vintage computers owned: Android O Phone
Does this qualify as a signature? 
The answer is "Sure."


Jokeriske

i've noticed some typo's, in the first line there is a "z" after the DIV tag

Dudeman313

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.
  • Calculators owned: TI-84 PCE
  • Consoles, mobile devices and vintage computers owned: Android O Phone
Does this qualify as a signature? 
The answer is "Sure."


ben_g


$.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.

Dream of Omnimaga

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?
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

Adriweb

  • Calculators owned: TI-Nspire CX CAS, TI-Nspire CX, TI-Nspire CAS (x3), TI-Nspire (x2), TI-Nspire CM-C CAS, TI-Nspire CAS+, TI-80, TI-82 Stats.fr, TI-82 Plus, TI-83 Plus, TI-83 Plus.fr USB, TI-84+, TI-84+ Pocket SE, TI-84+ C Silver Edition, TI-84 Plus CE, TI-89 Titanium, TI-86, TI-Voyage 200, TI-Collège Plus, TI-Collège Plus Solaire, 3 HP, some Casios
Co-founder & co-administrator of TI-Planet and Inspired-Lua

Dudeman313

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?
  • Calculators owned: TI-84 PCE
  • Consoles, mobile devices and vintage computers owned: Android O Phone
Does this qualify as a signature? 
The answer is "Sure."


Dream of Omnimaga

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.
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

Dudeman313

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.
  • Calculators owned: TI-84 PCE
  • Consoles, mobile devices and vintage computers owned: Android O Phone
Does this qualify as a signature? 
The answer is "Sure."


Dream of Omnimaga

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.
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

Dudeman313

#10
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:


[spoiler=Oops...]
I may or may not have stolen your :trollface: for my site there...
|s it copy-righted?
[/spoiler]
  • Calculators owned: TI-84 PCE
  • Consoles, mobile devices and vintage computers owned: Android O Phone
Does this qualify as a signature? 
The answer is "Sure."


Dream of Omnimaga

Lol, Trollface is an internet meme and we got it from there anyway, so it's fine. :P Also I like the design :3=
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

Dudeman313

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:
  • Calculators owned: TI-84 PCE
  • Consoles, mobile devices and vintage computers owned: Android O Phone
Does this qualify as a signature? 
The answer is "Sure."


Jokeriske

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.

Dream of Omnimaga

#14
@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
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

Powered by EzPortal