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 5 of 5
  1. #1
    Regular Coder
    Join Date
    Sep 2007
    Posts
    809
    Thanks
    5
    Thanked 2 Times in 2 Posts

    One variable not posting while the rest are?

    Hi,

    I have a number of variables posting correctly but my ID one doesn't seem to want to work for me, despite it being setup in the same manner as the rest...

    PHP Code:
    <?php
          $id 
    $_GET['candidateid'];
        
    $query "SELECT * FROM my_table WHERE id = $id";
        
    $result mysql_query($query) or die (mysql_error());
        
    $row mysql_fetch_array($result);
    ?>
    PHP Code:
    <input type="text" name"candidateid" id="candidateid" class="bodyinput" value="<?php echo $id;?>"/> // This correctly puts the candidate id in the box
    but when I submit the form to the next page, and try to drag it out like so:

    PHP Code:
    $candidateid mysql_real_escape_string($_POST['candidateid']); 
    <tr>
    <td style='background-color:#CCCCCC;'>Candidate ID:</td>
    <td style='background-color:#CCCCCC;'>$candidateid</td>
    </tr>

    I just get a blank space where it should display the candidate id, anyone got any ideas?

    Just so you can compare it with one of my working variables:
    PHP Code:
      <input type="text" name="candidatename" id="candidatename" class="bodyinput" value="<?php echo $row['fname'];?>"/>

    $candidatename = mysql_real_escape_string($_POST['candidatename']);
    <tr>
    <td>Candidate Name:</td>
    <td>$candidatename</td>
    </tr>

    This displays the candidate name exactly as I would expect.

  • #2
    Regular Coder
    Join Date
    Dec 2009
    Location
    UK
    Posts
    495
    Thanks
    0
    Thanked 58 Times in 58 Posts
    You use $_GET and $_POST in your examples, which of the two is it meant to be? My guess is that is what's causing the problem. A simple way to check is to put this at the top of your script for the form processing script and see which has the candidateid in it
    PHP Code:
    echo '<h2>POST</h2>';
    echo 
    '<pre>'.print_r($_POSTtrue).'</pre>';
    echo 
    '<h2>GET</h2>';
    echo 
    '<pre>'.print_r($_GETtrue).'</pre>'
    My site: JayGilford.com
    Resources:
    PHP Pagination Class | Getting all page links | Handling PHP Errors properly
    If you like a users help, show your appreciation with the rep and thanks buttons :)

  • #3
    New Coder
    Join Date
    Mar 2009
    Posts
    90
    Thanks
    5
    Thanked 14 Times in 14 Posts
    Hi, maybe td style='background-color:#CCCCCC; is the same as your text color inside td -> use mouse select or view source.

    You can use
    PHP Code:
    <input type="text" name"candidateid" id="candidateid" class="bodyinput" value="<?php echo htmlentities($_GET['candidateid']);?>"/>
    for the first page instead of sql result.

    p.p.: Try also:
    PHP Code:
    var_dump($_REQUEST); 
    Regards

  • #4
    Regular Coder
    Join Date
    Sep 2007
    Posts
    809
    Thanks
    5
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by JAY6390 View Post
    You use $_GET and $_POST in your examples, which of the two is it meant to be? My guess is that is what's causing the problem. A simple way to check is to put this at the top of your script for the form processing script and see which has the candidateid in it
    PHP Code:
    echo '<h2>POST</h2>';
    echo 
    '<pre>'.print_r($_POSTtrue).'</pre>';
    echo 
    '<h2>GET</h2>';
    echo 
    '<pre>'.print_r($_GETtrue).'</pre>'
    Hey Jay,

    thanks for the reply... to be honest I've actually tried both $_GET & $_POST and neither of them work...

    As for your test, neither of them actually print the candidate ID... obviously this show the problem, I'm just not sure why it's picking up the rest though, when im using the same method!

    To try and make things a bit clearer the structure is:

    schoolarea.php

    This page contains a 'candidate ticker', once the user clicks to enquire about a certain candidate then next page loads up with a url of:

    http://www.my-site.co.uk/candidateen...candidateid=10

    Then I have a form, where the candidate id is successfully posted to the form, along with a number of other variables...

    however when I post the form (so that it will email me the details, I recieve all the details I'd expect except for the candidate id... but I cant see any difference in the way I'm calling the candidate id or any of the other variables!

  • #5
    Regular Coder
    Join Date
    Sep 2007
    Posts
    809
    Thanks
    5
    Thanked 2 Times in 2 Posts
    Might be worth noting, it I add the same code to the previous page...

    candidateenquire.php

    It returns candidateid as a $_GET rather than a $_POST?


  •  

    Posting Permissions

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