Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 1 of 1
  1. #1
    Senior Member Tyler Smith's Avatar
    Join Date
    Oct 2011
    Posts
    115
    Member #
    29767
    Liked
    7 times
    Hi all,

    I have asked for help concerning a jQuery/PHP contact form previously, but that thread fell idle when no one continued to give suggestions. I've still been working on this and will solve this on my own even if I receive no further replies.

    I am seeing a response posted to the div with the id of status, but it is obviously not receiving the correct data input for the e-mail. I have set it up to echo the e-mail address value currently in there, and every time the PHP script is receiving "your e-mail" as the data from that input; therefore, the result echoed is always "Submission Failure- Nothing in Box: your e-mail".

    This is the form markup:
    HTML Code:
    <form id="emailbox" name="form1" method="get" action="Scripts/emailtester.php">
            <div>
              <input type="text" name="email" id="go" value="your e-mail" onclick="input_focus(this)"  onblur="input_reset(this)" maxlength="60"/>
              <input type="submit" id="submit" value="Join" />
            </div>
          </form>
    The jQuery:
    Code:
    jQuery(document).ready(function(){
        jQuery("#emailbox").submit(function(event){
            event.preventDefault();
            var ea = $("#go").val();
    
            $.ajax({
                url: $(this).attr('action'),
                type: $(this).attr('method'),
                data: $(this).serialize(),
                success: function(response){
                    $('#status').append(response);
                }
                });
        });
    });
    emailtester.php
    PHP Code:
    <?php
            
    require_once('checkfirstsub.php');
            
    $email $_GET['email'];
            if (!isset(
    $email) || $email == "your e-mail")
                echo 
    '<p>Submission Failure - Nothing in Box:  ' $email '</p>';
            else {
                
    $email htmlentities($email);
                
    $obj_PE = new ProcessEmail();
                
    $messages $obj_PE -> processor($email);
                echo 
    $messages;
            }
    ?>
    checkfirstsub.php
    PHP Code:
    <?php
        
    class ProcessEmail
        
    {
            public function 
    processor($email)
            {
                if (!empty(
    $email)){
                    if (
    $email != "your e-mail"){
                            if (
    isItAValidEmail($email))
                            {
                                return 
    '<p>Submission Successful</p>';
                            } else {
                                return 
    '<p>Submission Failure- Invalid E-mail</p>';
                            }
                    } else {
                        return 
    '<p>Submission Failure- Default Value in Box</p>';
                    }
                } else {
                    return 
    '<p>Submission Failure- Nothing in Box</p>';
                }
            }

            public function 
    isItAValidEmail($email)
            {
                if (
    filter_var($emailFILTER_VALIDATE_EMAIL))
                    return 
    true;
                else
                    return 
    false;
            }
        }
    ?>
    If it helps to figure out why "your e-mail" is being sent to the PHP script, below I've posted a JavaScript snippet that changes the input value from "your e-mail" to blank when the input element is activated.

    Code:
    function input_focus(obj){
        if ( obj.value == obj.defaultValue ){
            obj.value = ""
        }
    }
    
    function input_reset(obj){
        obj.value = obj.defaultValue;
    }
    Hopefully someone can point me in the right direction.

  2.  


Remove Ads

Posting Permissions

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

Search tags for this page

jquery get pass current input value

Click on a term to search for related topics.
All times are GMT -6. The time now is 09:53 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com