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.

Page 5 of 6 FirstFirst ... 3 4 5 6 LastLast
Results 41 to 50 of 52
Like Tree5Likes

Thread: Can't processing values in HTML PHP Form correctly

  1. #41
    Senior Member
    Join Date
    Mar 2010
    Posts
    104
    Member #
    21316
    Liked
    1 times
    So just to re-cap with Ronald's method working, my form stands to look like:

    HTML:

    Code:
    <p><input type="checkbox" name="treatment01" id="checkboxG5" class="css-checkbox checkboxG5 treatment01" value="Back & Neck Aroma Massage" /><label for="checkboxG5" class="css-label">Back & Neck Aroma Massage</label></p>
    <p><input type="checkbox" name="treatment02" id="checkboxG6" class="css-checkbox checkboxG6 treatment02" value="Hello" /><label for="checkboxG6" class="css-label">Hello</label></p>
    Jquery:

    Code:
    jQuery(document).ready(function() {
        $('.checkinform').submit(function() {
            var action = $(this).attr('action');
            var form = this;
            $('.submit', this).attr('disabled', 'disabled').after(
                  '<img src="assets/ajax-loader.gif" class="loader" />');
            $('.message', this).slideUp(750, function() {
                $(this).hide();
                
                var t01 = $('#checkboxG5').is(':checked'),
    t02 = $('#checkboxG6').is(':checked');
                
                $.post(action, {
                    title: $('.title', form).val(),
                    firstname: $('.firstname', form).val(),
                    lastname: $('.lastname', form).val(),
                    idnum: $('.idnum', form).val(),
                    birth: $('.birth', form).val(),
                    married: $('.married', form).val(),
                    officephone: $('.officephone', form).val(),
                    cellphone: $('.cellphone', form).val(),            
                    email: $('.email', form).val(),
                    company: $('.company', form).val(),
                    position: $('.position', form).val(),
                    addressline1: $('.addressline1', form).val(),
                    addressline2: $('.addressline2', form).val(),
                    city: $('.city', form).val(),
                    postalcode: $('.postalcode', form).val(),
                    bookingdate: $('.bookingdate', form).val(),
                    estimate: $('.estimate', form).val(),
                    currentpackages: $('.currentpackages', form).val(),
                    treatment01: t01,
                    treatment02: t02,
                    specialrequests: $('.specialrequests', form).val(),
                    verify: $('.verify', form).val()
                },
                function(data) {
                    $('.message', form).html(data);
                    $('.message', form).slideDown('slow');
                    $('img.loader', form).fadeOut('fast', function() {
                        $(this).remove();
                    });
                    $('.submit', form).removeAttr('disabled');
                });
            });
            return false;
        });
    });

    PHP:

    Code:
    $treatment01 = $_POST['treatment01'];
    $treatment02 = $_POST['treatment02'];
    Email output in PHP:
    Code:
    <td width="375" valign="middle"><span style="font-family:Arial, Helvetica, sans-serif; font-size:14px;">'.$_POST['treatment01'].'<br />'.$_POST['treatment02'].'</span></td>

  2.  

  3. #42
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,139
    Member #
    27197
    Liked
    959 times
    You should be able to replace this in your PHP:
    PHP Code:
    $treatment01 $_POST['treatment01'];
    $treatment02 $_POST['treatment02']; 
    with this:
    PHP Code:
    if($_POST['treatment01']){
    $treatment01 "Whatever text you want here";
    }
    if(
    $_POST['treatment02']){
    $treatment02 "Whatever text you want here";

    mlseim and reflex84 like this.
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

  4. #43
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,980
    Member #
    5580
    Liked
    761 times
    whew! Thanks Ron, I just didn't have time to keep up with these posts. I hope this one is resolved.

    @reflex84, what we went through here (5 pages of posts) is typical of scripting issues a person has when making a website. It's a good lesson in how to try different things to see what works. I'm sure you'll have other problems ... if so, start a new thread for a new problem.

    All of this scripting stuff takes years to be proficient, so keep at it and don't get too frustrated. It becomes addicting.
    Ronald Roe likes this.


  5. #44
    Senior Member
    Join Date
    Mar 2010
    Posts
    104
    Member #
    21316
    Liked
    1 times
    @reflex84, what we went through here (5 pages of posts) is typical of scripting issues a person has when making a website. It's a good lesson in how to try different things to see what works. I'm sure you'll have other problems ... if so, start a new thread for a new problem.

    All of this scripting stuff takes years to be proficient, so keep at it and don't get too frustrated. It becomes addicting.
    I see!! ... and it's hard not to get frustrated because I'm also thinking that maybe I'm not giving you guys enough information etc and I just can't believe checkboxes have delayed me by over a week! You've both done an excellent job nevertheless!

    @Ronald ... I replaced that code but it didn't make any difference. The result was still 'True' or 'False' ...

  6. #45
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,980
    Member #
    5580
    Liked
    761 times
    When you construct your email message,
    use $treatment01 instead of $_POST['treatment01']

    This code at the beginning of the script,

    if($_POST['treatment01']){
    $treatment01 = "Whatever text you want here";
    }
    if($_POST['treatment02']){
    $treatment02 = "Whatever text you want here";
    }

    Determines if it's true or false and assigns the appropriate string (text) to the variables.

    After that happens, you'll use $treatment01 and $treatment01 without the $_POST portion.

    EDIT:
    You did fine giving us information. Ron and I know exactly what to do with checkboxes pertaining to PHP, it's the JQuery/javascripting that had us stumped. But we both learned from it, just as you did.

    I always learn more by helping someone else with a problem, than by reading books or tutorials.
    Last edited by mlseim; Jul 29th, 2014 at 12:25 PM.


  7. #46
    Senior Member
    Join Date
    Mar 2010
    Posts
    104
    Member #
    21316
    Liked
    1 times
    Thanks Mlseim again for explaining!
    I was pretty certain that it couldn't be the javascript but hey what do I know!

    Okay I did what you said ... replaced:

    <td width="375" valign="middle"><span style="font-family:Arial, Helvetica, sans-serif; font-size:14px;">'.$_POST['treatment01'].'<br />'.$_POST['treatment02'].'</span></td>
    with:

    <td width="375" valign="middle"><span style="font-family:Arial, Helvetica, sans-serif; font-size:14px;">'.$treatment01.'<br />'.$treatment02.'</span></td>
    and now when I receive the email, (regardless if none, 1 or both checkboxes are ticked) I always get BOTH of the checkbox values or string as it's called in:


    Code:
    if($_POST['treatment01']){
        $treatment01 = "Back & Neck Aroma Massage";
        }
    if($_POST['treatment02']){
        $treatment02 = "Hello";
        }

  8. #47
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,980
    Member #
    5580
    Liked
    761 times
    Before, when you did the script and the email said "True", did it actually say "True" or "False" ... those words?
    In other words, $_POST['treatment01'] actually contains the words "True" or "False".

    If so, that explains why you're getting both.

    Let me know what the words actually were, when you were using $_POST in your email message.


  9. #48
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,139
    Member #
    27197
    Liked
    959 times
    I wondered about that. It's pushing true/false through as a string, which is truthy, isn't it?
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

  10. #49
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,980
    Member #
    5580
    Liked
    761 times
    If the word "true" is literal, do this ...

    Code:
    $treatment01 = "";
    if(strtolower($_POST['treatment01'])=="true"){
        $treatment01 = "Back & Neck Aroma Massage";
        }
    $treatment02 = "";
    if(strtolower($_POST['treatment02'])=="true"){
        $treatment02 = "Hello";
        }
    reflex84 likes this.


  11. #50
    Senior Member
    Join Date
    Mar 2010
    Posts
    104
    Member #
    21316
    Liked
    1 times
    Before, when you did the script and the email said "True", did it actually say "True" or "False" ... those words?
    In other words, $_POST['treatment01'] actually contains the words "True" or "False".
    If so, that explains why you're getting both.
    Let me know what the words actually were, when you were using $_POST in your email message.
    Yes, when I submitted the form with the:

    "Hello" checkbox ticked
    "Back & Neck Aroma Massage" checkbox unticked

    the email came back as:

    true
    false

    .......

    WAHHHOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO !!!!!!!!!!!!!!!!!!!!!!!!!!!
    This worked:

    Code:
    $treatment01 = "";
    if(strtolower($_POST['treatment01'])=="true"){
        $treatment01 = "Back & Neck Aroma Massage";
        }
    $treatment02 = "";
    if(strtolower($_POST['treatment02'])=="true"){
        $treatment02 = "Hello";
        }
    It is CHRISTMAS for me right now!!!!
    Wow I am so happy!! Thanks guys so much!

    So it wasn't a combination of both php and jquery that needed fiddling with and you Ronald who's good with Jquery, cracked it and Mlseim who's good with php cracked it! You guys make a good team - well done!


Page 5 of 6 FirstFirst ... 3 4 5 6 LastLast

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
  •  

Tags for this Thread

All times are GMT -6. The time now is 01:31 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2022 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com