Need Help with Contact Form and Newsletter

  • garrett2828
  • Newbie
  • Newbie
  • garrett2828
  • Posts: 6

Post 3+ Months Ago

thanks so much for everything guys...... Now do you think there is a way to make the newsletter task work?
  • jharvey1029
  • Novice
  • Novice
  • jharvey1029
  • Posts: 31
  • Loc: New Castle, PA

Post 3+ Months Ago

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
  • garrett2828
  • Posts: 6

Post 3+ Months Ago

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
  • Posts: 9091
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

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!
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9091
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

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.
  • jharvey1029
  • Novice
  • Novice
  • jharvey1029
  • Posts: 31
  • Loc: New Castle, PA

Post 3+ Months Ago

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
  • Posts: 9091
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

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.
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9091
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

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 :)
  • jharvey1029
  • Novice
  • Novice
  • jharvey1029
  • Posts: 31
  • Loc: New Castle, PA

Post 3+ Months Ago

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

any more ideas?
  • garrett2828
  • Newbie
  • Newbie
  • garrett2828
  • Posts: 6

Post 3+ Months Ago

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
  • Posts: 9091
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

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.
  • jharvey1029
  • Novice
  • Novice
  • jharvey1029
  • Posts: 31
  • Loc: New Castle, PA

Post 3+ Months Ago

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
  • Posts: 9091
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

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>
  • jharvey1029
  • Novice
  • Novice
  • jharvey1029
  • Posts: 31
  • Loc: New Castle, PA

Post 3+ Months Ago

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
  • Posts: 9091
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

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
  • jharvey1029
  • Novice
  • Novice
  • jharvey1029
  • Posts: 31
  • Loc: New Castle, PA

Post 3+ Months Ago

ok JS line fixed and the file is loaded into the JS directory with the rest of the js files....wait for it............it still doesnt work....lmao

The button doesnt do anything at all. Almost like JS isnt capable of submitting the form.

Cant believe I have this whole thing working, But ONLY if I use the crappy
Code: [ Select ]
<input type="submit" value="Submit" name='submit'>
code.

the site has 2 very nice combo buttons within the site code, but getting these to work is proving harder than reversing time.
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9091
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

Yeah its because multiple problems are going on at once here. Just gotta fix each one. Will look it over shortly.
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9091
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

Okay I have a new resolution for you to try. Go ahead and change this:

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


to:

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


Then in your PHP Code change this line:

PHP Code: [ Select ]
if(isset($_POST['submit']))


to:

PHP Code: [ Select ]
if(isset($_POST['form_submit']))


and see what happens :)
  • garrett2828
  • Newbie
  • Newbie
  • garrett2828
  • Posts: 6

Post 3+ Months Ago

Perfect! thanks so much!
  • jharvey1029
  • Novice
  • Novice
  • jharvey1029
  • Posts: 31
  • Loc: New Castle, PA

Post 3+ Months Ago

Brian,

you are a champion!!!!! It now works. I cant thank you enough. You have made my day, trust me been working on using this site for sometime now and finally its almost complete.

A great many thanks and if there is anything I can do for you please let me know.


James
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9091
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

No problem, glad I could help :)

Post Information

  • Total Posts in this topic: 51 posts
  • Users browsing this forum: No registered users and 39 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.