Need Help with Contact Form and Newsletter

  • garrett2828
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Oct 18, 2011
  • Posts: 6
  • Status: Offline

Post October 18th, 2011, 1:22 pm

thanks so much for everything guys...... Now do you think there is a way to make the newsletter task work?
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post October 18th, 2011, 1:22 pm

  • jharvey1029
  • Novice
  • Novice
  • No Avatar
  • Joined: Oct 15, 2011
  • Posts: 31
  • Loc: New Castle, PA
  • Status: Offline

Post October 18th, 2011, 1:26 pm

you might want to look up the original posting with the same thread name as this and check out bigwebmaster's html code there.
  • garrett2828
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Oct 18, 2011
  • Posts: 6
  • Status: Offline

Post October 18th, 2011, 1:35 pm

real quick..... how do i make the page route back to my home page etc. once you hit submit.... it is just taking me to a blank page with url as contact.php is there a way to change this? thanks
Garrett
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Joined: Dec 20, 2002
  • Posts: 8926
  • Loc: Seattle, WA & Phoenix, AZ
  • Status: Offline

Post October 18th, 2011, 1:43 pm

Glad you were able to get it to work with the new script James. Wish we could figure out what the actual problem was with your original script as that script still looks fine to me. I am sure there has to be some sort of logical problem to why it was not working. At least its working for you now!
Ozzu Hosting - Want your website on a fast server like Ozzu?
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Joined: Dec 20, 2002
  • Posts: 8926
  • Loc: Seattle, WA & Phoenix, AZ
  • Status: Offline

Post October 18th, 2011, 1:46 pm

Garrett - in the contact.php code change this line:

PHP Code: [ Select ]
header('Location: contacts.html');


to something like:

PHP Code: [ Select ]
header('Location: http://www.yoursite.com/');


and it should redirect you to your main site page instead.
Ozzu Hosting - Want your website on a fast server like Ozzu?
  • jharvey1029
  • Novice
  • Novice
  • No Avatar
  • Joined: Oct 15, 2011
  • Posts: 31
  • Loc: New Castle, PA
  • Status: Offline

Post October 18th, 2011, 1:53 pm

Brian,

was more to do with the php file than anything. Just not configured correctly.

I do have one thing you might be able to help with:

If I use the following: <input type="submit" value="Submit" name='submit'> the form submits redirects back to its original page (as directed to) and the email and EU data is received in email as planned.

However I dont like that grey boring submit button and want to use the buttons that you see on the page as of now. (will PM you a link to this page) only I cant seem to get the form to submit when the EU clicks "Send". It appears begins to process the php file but then stops and all I get is a blank screen.
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Joined: Dec 20, 2002
  • Posts: 8926
  • Loc: Seattle, WA & Phoenix, AZ
  • Status: Offline

Post October 18th, 2011, 2:15 pm

It is not working because it is expecting the "submit" variable to be passed which it is no longer doing. Somewhere before the submit button you could add this to override that:

HTML Code: [ Select ]
<input type="hidden" id="submit" name="submit" value="1">


and then it would pass the submit variable through the form that your script is looking for.
Ozzu Hosting - Want your website on a fast server like Ozzu?
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Joined: Dec 20, 2002
  • Posts: 8926
  • Loc: Seattle, WA & Phoenix, AZ
  • Status: Offline

Post October 18th, 2011, 2:36 pm

By the way I think I just figured out why your original script was not working. It was driving me crazy, the problem ended up being your HTML, not the PHP script. In your HTML you had on your original script for the form element:

HTML Code: [ Select ]
<form id="contacts-form" action="contact.php" enctype="multipart/form-data">


You were missing the method which clarifies you are doing post data. So for anybody who is getting blank $_POST variables to fix this you should verify you have your method declared like so:

HTML Code: [ Select ]
<form id="contacts-form" action="contact.php" enctype="multipart/form-data" method="post">


By default it would be using the GET method which means the variables in PHP would be accessed like so:

$_GET['variable']

instead of:

$_POST['variable']

Once you declare the method="post" then you could access via the $_POST variable in PHP.

Hopefully that helps for anybody who has this problem down the road with blank $_POST variables :)
Ozzu Hosting - Want your website on a fast server like Ozzu?
  • jharvey1029
  • Novice
  • Novice
  • No Avatar
  • Joined: Oct 15, 2011
  • Posts: 31
  • Loc: New Castle, PA
  • Status: Offline

Post October 18th, 2011, 2:37 pm

nope that doesn't work in fact now the button doesn't work at all.

any more ideas?
  • garrett2828
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Oct 18, 2011
  • Posts: 6
  • Status: Offline

Post October 18th, 2011, 2:43 pm

Hey James,
Could you send me your html code that you used that actually made it redirect back to your site like it was supposed to do, I did like Brian said but same results. I'm just wondering what you did to edit it and make the redirection work without trying to route to the contact.php file thanks again
Garrett
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Joined: Dec 20, 2002
  • Posts: 8926
  • Loc: Seattle, WA & Phoenix, AZ
  • Status: Offline

Post October 18th, 2011, 2:45 pm

Hi James - Took a look at your HTML, on your current script you are using you have JavaScript trying to search by ID and you have no ID specified on the form:

HTML Code: [ Select ]
<form method="POST" name="contact_form" action="contact.php">


Change that to:

HTML Code: [ Select ]
<form method="POST" id="contact_form" name="contact_form" action="contact.php">


That should get rid of that JavaScript error I am receiving. See if that resolves anything, there may be further problems still after that.
Ozzu Hosting - Want your website on a fast server like Ozzu?
  • jharvey1029
  • Novice
  • Novice
  • No Avatar
  • Joined: Oct 15, 2011
  • Posts: 31
  • Loc: New Castle, PA
  • Status: Offline

Post October 18th, 2011, 2:47 pm

Garrett,

in the php file that I called contact.php look for header('Location:'); you will see a link to something like thank-you.html or something like that. change that to where you want it to be redirected to once the form has been sent.

hope that helps
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Joined: Dec 20, 2002
  • Posts: 8926
  • Loc: Seattle, WA & Phoenix, AZ
  • Status: Offline

Post October 18th, 2011, 2:51 pm

The other problem you have James is this line:

HTML Code: [ Select ]
<script type="text/javascript" src="gen_validatorv31.js"></script>


gen_validatorv31.js does not exist on your site. It needs to be loaded from your js directory:

HTML Code: [ Select ]
<script type="text/javascript" src="js/gen_validatorv31.js"></script>
Ozzu Hosting - Want your website on a fast server like Ozzu?
  • jharvey1029
  • Novice
  • Novice
  • No Avatar
  • Joined: Oct 15, 2011
  • Posts: 31
  • Loc: New Castle, PA
  • Status: Offline

Post October 18th, 2011, 2:52 pm

lol Brian,

take a look at the following HTML code and tell me where I am going wrong. I have followed your instructions and now the darn button doesn do a darn thing...not a single thing.

Code: [ Select ]
<h2>Contact Form</h2>
                            <form method="POST" id="contact_form" name="contact_form" action="contact.php">
                            <p>
                            <label for='name'>Name: </label><br>
                            <input type="text" name="name">
                            </p>
                            <p>
                            <label for='email'>Email: </label><br>
                            <input type="text" name="email">
                            </p>
                            <p>
                            <label for='phone'>Phone: </label><br>
                            <input type="text" name="phone">
                            </p>
                            <p>
                            <label for='message'>Message:</label> <br>
                            <textarea name="message"></textarea>
                            </p>
                            <p>
                            <img src="captcha_code_file.php?rand=<?php echo rand(); ?>" id='captchaimg' ><br>
                            <label for='message'>Enter the code above here :</label><br>
                            <input id="6_letters_code" name="6_letters_code" type="text"><br>
                            <small>Can't read the image? click <a href='javascript: refreshCaptcha();'>here</a> to refresh</small>
                            </p>
                            <input type="hidden" id="submit" name="submit" value="1">
                            <div class="alignright"><div class="alignright"><a href="contacts.html" class="link4" onClick="document.getElementById('contact_form').reset()"><span><span>Clear</span></span></a><a href="javascript: submitform()" class="link2" onClick="document.getElementById('contact_form').submit()"><span><span>Send</span></span></a></div>
                            </form>
                            <script type="text/javascript">
                            function submitform()
                            {
                             document.forms["contact_form"].submit();
                            }
                            </script>
                            <script language="JavaScript">
                            // Code for validating the form
                            var frmvalidator = new Validator("contact_form");
                            //remove the following two lines if you like error message box popups
                            frmvalidator.EnableOnPageErrorDisplaySingleBox();
                            frmvalidator.EnableMsgsTogether();
                            
                            frmvalidator.addValidation("name","req","Please provide your name");
                            frmvalidator.addValidation("email","req","Please provide your email");
                            frmvalidator.addValidation("email","email","Please enter a valid email address");
                            </script>
                            <script language='JavaScript' type='text/javascript'>
                            function refreshCaptcha()
                            {
                                var img = document.images['captchaimg'];
                                img.src = img.src.substring(0,img.src.lastIndexOf("?"))+"?rand="+Math.random()*1000;
                            }
                            </script>
  1. <h2>Contact Form</h2>
  2.                             <form method="POST" id="contact_form" name="contact_form" action="contact.php">
  3.                             <p>
  4.                             <label for='name'>Name: </label><br>
  5.                             <input type="text" name="name">
  6.                             </p>
  7.                             <p>
  8.                             <label for='email'>Email: </label><br>
  9.                             <input type="text" name="email">
  10.                             </p>
  11.                             <p>
  12.                             <label for='phone'>Phone: </label><br>
  13.                             <input type="text" name="phone">
  14.                             </p>
  15.                             <p>
  16.                             <label for='message'>Message:</label> <br>
  17.                             <textarea name="message"></textarea>
  18.                             </p>
  19.                             <p>
  20.                             <img src="captcha_code_file.php?rand=<?php echo rand(); ?>" id='captchaimg' ><br>
  21.                             <label for='message'>Enter the code above here :</label><br>
  22.                             <input id="6_letters_code" name="6_letters_code" type="text"><br>
  23.                             <small>Can't read the image? click <a href='javascript: refreshCaptcha();'>here</a> to refresh</small>
  24.                             </p>
  25.                             <input type="hidden" id="submit" name="submit" value="1">
  26.                             <div class="alignright"><div class="alignright"><a href="contacts.html" class="link4" onClick="document.getElementById('contact_form').reset()"><span><span>Clear</span></span></a><a href="javascript: submitform()" class="link2" onClick="document.getElementById('contact_form').submit()"><span><span>Send</span></span></a></div>
  27.                             </form>
  28.                             <script type="text/javascript">
  29.                             function submitform()
  30.                             {
  31.                              document.forms["contact_form"].submit();
  32.                             }
  33.                             </script>
  34.                             <script language="JavaScript">
  35.                             // Code for validating the form
  36.                             var frmvalidator = new Validator("contact_form");
  37.                             //remove the following two lines if you like error message box popups
  38.                             frmvalidator.EnableOnPageErrorDisplaySingleBox();
  39.                             frmvalidator.EnableMsgsTogether();
  40.                             
  41.                             frmvalidator.addValidation("name","req","Please provide your name");
  42.                             frmvalidator.addValidation("email","req","Please provide your email");
  43.                             frmvalidator.addValidation("email","email","Please enter a valid email address");
  44.                             </script>
  45.                             <script language='JavaScript' type='text/javascript'>
  46.                             function refreshCaptcha()
  47.                             {
  48.                                 var img = document.images['captchaimg'];
  49.                                 img.src = img.src.substring(0,img.src.lastIndexOf("?"))+"?rand="+Math.random()*1000;
  50.                             }
  51.                             </script>
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Joined: Dec 20, 2002
  • Posts: 8926
  • Loc: Seattle, WA & Phoenix, AZ
  • Status: Offline

Post October 18th, 2011, 2:54 pm

Your JavaScript file is not loading which is part of that script, it is resulting in a 404 error. Please see my last post :)

Without that loading the Javascript function on the submit button is returning this error:

Quote:
Error: document.getElementById("contact_form").submit is not a function
Ozzu Hosting - Want your website on a fast server like Ozzu?
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post October 18th, 2011, 2:54 pm

Post Information

  • Total Posts in this topic: 51 posts
  • Users browsing this forum: No registered users and 181 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.