• Lucid Dreaming - Dream Views




    Results 1 to 12 of 12
    1. #1
      !DIREKTOR! Adam's Avatar
      Join Date
      Jan 2007
      Gender
      Location
      Aquanina's closet
      Posts
      5,195
      Likes
      34

      PHP / Java scripting help.

      Hey.... again....

      I have the following email submission form on my site:

      Quote Originally Posted by index.html
      <form action="add_email.php" method="post" name="email_form" target="_self" id="email_form">
      <input name="email" type="text" id="email_box"/><a href="javascript: submitform()">SUBSCRIBE</a></form>
      and the following php in the same directory:

      Quote Originally Posted by add_email.php
      <?php
      if($_POST['email'] != ""){
      $email = $_POST['email'];
      $to = "[email protected]";
      $from = "dadamash.com";
      $subject = "New Subscriber - (".$email.")";
      $details = "There has been a new subscriber to your mailing list:\n\n- ".$email;

      if(mail($to,$subject,$details,"From: ".$from)){
      header("Location: ok.html");
      } else {
      header("Location: error.html");
      }
      } else {
      header("Location: contact.html");
      }
      ?>
      But for some reason nothing happens when I click the subscribe button. Is there something wrong with my code? Been over it a thousand times with tired eyes but cannot see anything wrong. It is more than likely something really simple!

      Any help?

      Thanks,
      Adam.

    2. #2
      Emotionally unsatisfied. Sandform's Avatar
      Join Date
      Jul 2007
      Gender
      Location
      Texas
      Posts
      4,298
      Likes
      24
      Bah I wish I still remembered what I learned about Java

    3. #3
      !DIREKTOR! Adam's Avatar
      Join Date
      Jan 2007
      Gender
      Location
      Aquanina's closet
      Posts
      5,195
      Likes
      34
      Thanks lol.

      The output is here: http://www.djadamash.com


    4. #4
      Dreaming up music skysaw's Avatar
      Join Date
      Jun 2007
      Gender
      Location
      Alexandria, VA
      Posts
      2,330
      Likes
      5
      I don't know php, but your HTML form is formed unusually, and probably is the problem.

      <a href="javascript: submitform()">SUBSCRIBE</a></form>

      I'm not familiar with any built-in function called submitform(). Is this supposed to be a user-defined function you didn't include?

      It would probably be easier to, instead of using an anchor tag to use the submit type of input for the form.

      <input type="Submit" title="SUBSCRIBE">

      Or if you really want it to be an anchor tag, you'll need a javascript function such as:

      function submitform()
      {
      document.email_form.submit();
      }
      _________________________________________
      We now return you to our regularly scheduled signature, already in progress.
      _________________________________________

      My Music
      The Ear Is Always Correct - thoughts on music composition
      What Sky Saw - a lucid dreaming journal

    5. #5
      FBI agent Ynot's Avatar
      Join Date
      Oct 2005
      Gender
      Location
      Southend, Essex
      Posts
      4,337
      Likes
      14
      Your javascript for submitting the form probably wrong
      (and seeing as your not doing any client side validation, using JS just to submit the form seems pointless)

      Try replacing
      Code:
      <a href="javascript: submitform()">SUBSCRIBE</a>
      with
      Code:
      <input type="submit" value="SUBSCRIBE">
      *edit*
      beaten to it
      (\_ _/)
      (='.'=)
      (")_(")

    6. #6
      !DIREKTOR! Adam's Avatar
      Join Date
      Jan 2007
      Gender
      Location
      Aquanina's closet
      Posts
      5,195
      Likes
      34
      The reason I have gone for the <a href="javascript: submitform()">SUBSCRIBE</a></form> is to avoid the crappy boxes put around the "submit"

      I had it working on another site, but for this one it doen't. Using the same code. This is the page (none of the other files/CSS are linked with this, but you can see the subscribe bit working: http://www.djadamash.com/index_.htm

      Weird....

    7. #7
      FBI agent Ynot's Avatar
      Join Date
      Oct 2005
      Gender
      Location
      Southend, Essex
      Posts
      4,337
      Likes
      14
      Quote Originally Posted by skysaw View Post
      function submitform()
      {
      document.email_form.submit();
      }
      I think that'll only work in IE

      if you really want JS
      better to use
      Code:
      document.getElementById('email_form').submit();
      (\_ _/)
      (='.'=)
      (")_(")

    8. #8
      !DIREKTOR! Adam's Avatar
      Join Date
      Jan 2007
      Gender
      Location
      Aquanina's closet
      Posts
      5,195
      Likes
      34
      Quote Originally Posted by Ynot View Post
      I think that'll only work in IE

      if you really want JS
      better to use
      Code:
      document.getElementById('email_form').submit();
      where would I stick that?

    9. #9
      !DIREKTOR! Adam's Avatar
      Join Date
      Jan 2007
      Gender
      Location
      Aquanina's closet
      Posts
      5,195
      Likes
      34
      ignore me I am a tool - I forgot to put the JS in the head of the page lmao!!!

      I forgot to add:

      <SCRIPT language="JavaScript">
      function submitform()
      {
      document.email_form.submit();
      }
      </SCRIPT>

      DUH!

    10. #10
      FBI agent Ynot's Avatar
      Join Date
      Oct 2005
      Gender
      Location
      Southend, Essex
      Posts
      4,337
      Likes
      14
      Quote Originally Posted by Adam View Post
      where would I stick that?
      Code:
      <a href="#" onclick="document.getElementById('email_form').submit();return false;">submit</a>
      the "return false" ensures that the text link doesn't interfere with the php redirection
      (\_ _/)
      (='.'=)
      (")_(")

    11. #11
      Dreaming up music skysaw's Avatar
      Join Date
      Jun 2007
      Gender
      Location
      Alexandria, VA
      Posts
      2,330
      Likes
      5
      Quote Originally Posted by Adam View Post
      The reason I have gone for the <a href="javascript: submitform()">SUBSCRIBE</a></form> is to avoid the crappy boxes put around the "submit"
      Learn to use style sheets. They are your friend.
      _________________________________________
      We now return you to our regularly scheduled signature, already in progress.
      _________________________________________

      My Music
      The Ear Is Always Correct - thoughts on music composition
      What Sky Saw - a lucid dreaming journal

    12. #12
      !DIREKTOR! Adam's Avatar
      Join Date
      Jan 2007
      Gender
      Location
      Aquanina's closet
      Posts
      5,195
      Likes
      34
      I do use them religiosly, however, as I am sure it is evident, I am a beginner at all this, learning fast though. I am learning to use them day by day though.

      It seems to be working now after adding the info at the top, so thanks for your help guys

    Bookmarks

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •