Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 15 of 15
  1. #1
    Regular Coder
    Join Date
    Sep 2007
    Posts
    809
    Thanks
    5
    Thanked 2 Times in 2 Posts

    Value not sending

    Hi all,

    I've added a radio button, that will basically check if the user has already set email alerts and will let them turn them off if they so wish:

    PHP Code:
    <?php
        $joinquery 
    "SELECT * FROM resumes LEFT JOIN jobseekers ON jobseekers.jobseekerid = resumes.jobseekerid WHERE resumes.jobseekerid=\"$a1[jobseekerid]\"";
           
    $alertr mysql_query($joinquery) or die (mysql_query());
                while (
    $alertrow mysql_fetch_array($alertr)) {
                     
    $alertstatus $alertrow['alertstatus']; 
                }
      
        if(
    $alertstatus == '') {
        echo 
    "<input type='radio' name='alertstatus' value='Yes' checked>Yes
                <input type='radio' name='alertstatus' value='No'>No"
    ;
         } elseif(
    $alertstatus == 'Yes')    {
        echo 
    "<input type='radio' name='alertstatus' value='Yes' checked>Yes
                <input type='radio' name='alertstatus' value='No'>No"
    ;
        } else {
        echo 
    "<input type='radio' name='alertstatus' value='Yes'>Yes
            <input type='radio' name='alertstatus' value='No' checked>No"
    ;
            }
    ?>
    While this succeeds in checked if they have previously allowed email alerts or not, when I then press to change to 'No' or even 'Yes' then value isn't being posted to the database, on the processing side of things I have added this:

    PHP Code:
    $alertstatus mysql_real_escape_string($_POST['alertstatus']);
    echo 
    $alertstatus;
     
    $query "UPDATE resumes SET 
    title = \"$title\",
    hour = \"$hour\",
    category = \"$category\",
    subcounty = \"$subcounty\",
    alertstatus = \"$alertstatus\"
    where jobseekerid = \"$a1[jobseekerid]\""

    Added the echo to see if the value was being passed but I can now see that it isn't... the problem is I don't know why it isn't being passed?

    Can anyone offer any advice on this?

    many thanks,

    Greens85
    Last edited by greens85; 07-02-2010 at 04:11 PM.

  • #2
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,378
    Thanks
    8
    Thanked 1,075 Times in 1,066 Posts
    I don't see any kind of <form> tag with the action and method.

  • #3
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    So where do you actually run your query? I see no call to mysql_query in your code.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #4
    Regular Coder
    Join Date
    Sep 2007
    Posts
    809
    Thanks
    5
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by mlseim View Post
    I don't see any kind of <form> tag with the action and method.
    Hey mlseim,

    The form tag is present but as its a long form I just didnt bother to show it... it is set like so:

    Code:
    <form action="setalerts.php" method="post">
    At least I assume that is what you mean?

  • #5
    Regular Coder
    Join Date
    Sep 2007
    Posts
    809
    Thanks
    5
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by _Aerospace_Eng_ View Post
    So where do you actually run your query? I see no call to mysql_query in your code.
    Hi aerospace,

    Not sure I fully get what you mean, are you talking about this part?
    PHP Code:
    <?php
        $joinquery 
    "SELECT * FROM resumes LEFT JOIN jobseekers ON jobseekers.jobseekerid = resumes.jobseekerid WHERE resumes.jobseekerid=\"$a1[jobseekerid]\"";
           
    $alertr mysql_query($joinquery) or die (mysql_query());
                while (
    $alertrow mysql_fetch_array($alertr)) {
                     
    $alertstatus $alertrow['alertstatus']; 
                } 
    ?>
    If so, is the call not this part?

    PHP Code:
    $alertr mysql_query($joinquery) or die (mysql_query()); 

  • #6
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    Are you saying that you're not getting the POST value or your are getting it but it's not inserting? What's the order of your code? Can you take the whole thing, trim it down to the relevant portion and post it here?

    I don't know if it matters for your app, but the inputs aren't valid XHTML. The input tags should be closed and the checked attribute should be in standard attribute="value" format. Like this, for example:
    Code:
    <input type='radio' name='alertstatus' value='Yes' checked="checked" />
    Are you a Help Vampire?

  • #7
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Well in the part you said you added you have some SQL in there for an UPDATE but you never show a call to mysql_query.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #8
    Regular Coder
    Join Date
    Sep 2007
    Posts
    809
    Thanks
    5
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by tomws View Post
    Are you saying that you're not getting the POST value or your are getting it but it's not inserting? What's the order of your code? Can you take the whole thing, trim it down to the relevant portion and post it here?

    I don't know if it matters for your app, but the inputs aren't valid XHTML. The input tags should be closed and the checked attribute should be in standard attribute="value" format. Like this, for example:
    Code:
    <input type='radio' name='alertstatus' value='Yes' checked="checked" />
    Hey Tomws,

    In answer to your question, I suppose the answer is both! I'm not getting the POST value for that one particular record, and as a result it isn't inserting. It might be worth noting that all other values are being passed just fine!

    I'm not sure exactly what parts you would need to troubleshoot, so I will just provide the whole page for both the entry part and the processing script.. hope this is fine with you.

    As for the validation stuff, unfortunately the vast bulk of the code is pre bought software which quite honestly is wrote horrendously, however I inherited without choice... i would love to clean it up but quite simply it would take too much time, that I am currently using to develop and enhance the features of the site!
    Attached Files Attached Files

  • #9
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Can you post the table structure for your resumes table? An sql dump for the table would be best as it shows the types for each field. If you use this for your update query after you echo alertstatus
    PHP Code:
        $query "UPDATE resumes SET 
         title = '$title',
         hour = '$hour',
         category = '$category',
        subcounty = '$subcounty',
         alertstatus = '$alertstatus'
        where jobseekerid = {$a1['jobseekerid']}"
    ;
        echo 
    $query;
        
    $result mysql_query($query) or die(mysql_error()); 
    and paste the query that is echoed into something like phpmyadmin do you get any results?
    Last edited by _Aerospace_Eng_; 07-02-2010 at 03:11 PM.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #10
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    To start with, this is on the form page:
    Code:
        <td><input type="hidden" name="alertstatus" id="alertstatus" value"Yes"></td>
    Same name as the radio buttons, but after them. I'm unsure how the browser would pass values and what the handler would receive. It would be worth the time to change that or comment it out for testing.
    EDIT: Oh, look! The value attribute isn't used correctly there. It's missing the "=". I'll be that's why you're not even getting a "Yes".
    Are you a Help Vampire?

  • #11
    Regular Coder
    Join Date
    Sep 2007
    Posts
    809
    Thanks
    5
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by _Aerospace_Eng_ View Post
    Can you post the table structure for your resumes table? An sql dump for the table would be best as it shows the types for each field. If you use this for your update query after you echo alertstatus
    PHP Code:
        $query "UPDATE resumes SET 
         title = '$title',
         hour = '$hour',
         category = '$category',
        subcounty = '$subcounty',
         alertstatus = '$alertstatus'
        where jobseekerid = {$a1['jobseekerid']}"
    ;
        echo 
    $query;
        
    $result mysql_query($query) or die(mysql_error()); 
    and paste the query that is echoed into something like phpmyadmin do you get any results?
    I'm using PHPmyadmin but not sure how to get a dump of the table, would you be kind enough to talk me through it?

  • #12
    Regular Coder
    Join Date
    Sep 2007
    Posts
    809
    Thanks
    5
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by tomws View Post
    To start with, this is on the form page:
    Code:
        <td><input type="hidden" name="alertstatus" id="alertstatus" value"Yes"></td>
    Same name as the radio buttons, but after them. I'm unsure how the browser would pass values and what the handler would receive. It would be worth the time to change that or comment it out for testing.
    EDIT: Oh, look! The value attribute isn't used correctly there. It's missing the "=". I'll be that's why you're not even getting a "Yes".
    You are right in that:

    Code:
    <input type=hidden" name="alertstatus" id="alertstatus" value="Yes">
    is part of the old setup, I will remove it now!

    Not sure where to go from here though?

  • #13
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    Quote Originally Posted by greens85 View Post
    Not sure where to go from here though?
    Um... try it and see if it works? If I'm correct, that's where your empty value was coming from, so now it should be passing the correct value from the radios.
    Are you a Help Vampire?

  • #14
    Regular Coder
    Join Date
    Sep 2007
    Posts
    809
    Thanks
    5
    Thanked 2 Times in 2 Posts
    Just an update, after removing that line the variable is now echoing out

    However it is still not inserting into the database

  • #15
    Regular Coder
    Join Date
    Sep 2007
    Posts
    809
    Thanks
    5
    Thanked 2 Times in 2 Posts
    Not to worry it is now updating the record

    I think it may have been because I edited the field directly in the database at some point, this has proved a problem with updates before but either way all works fine now...

    Many thanks to everyone who helped me out here, it is greatly appreciated!


  •  

    Posting Permissions

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