Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Second Select Won't POST

I have a form that includes two <select> tags:

<li>
    <label for="uname">Select User : </label>
    <select id="uname" name="uname">
        <option value="3">Kaine McAuley</option>
    </select>
</li>
<li>
    <label for="uweek">Week Number : </label>
    <select id="uweek" name="uweek">
        <option value="1">Week 1</option>
        <option value="2">Week 2</option>
        <option value="3">Week 3</option>
        <option value="4">Week 4</option>
        <option value="5">Week 5</option>
        <option value="6">Week 6</option>
        <option value="7">Week 7</option>
        <option value="8">Week 8</option>
        <option value="9">Week 9</option>
        <option value="10">Week 10</option>
        <option value="11">Week 11</option>
        <option value="12">Week 12</option>
    </select>
</li>

That's how it comes out in the browser. I have echo'd the contents of $_POST and uweek doesn't exist in there. However, uname does!

My actual PHP code that creates the form is as follows:

echo '<h2>Update Users</h2><form action="" method="post">
    <ul style="list-style: none;">
            <li>
            <label for="uname">Select User : </label>
            <select id="uname" name="uname">';
while($r = mysqli_fetch_assoc($sql))
{
    switch($r['Username'])
    {
        case 'Mike':
        case '3rungohan':
        case 'Test':
        case 'Jestress':break;
        default: echo '<option value="' . $r['UserID'] . '">' . $r['RealName'] . '</option>';
    }
}

echo '</select></li>
<li>
    <label for="uweek">Week Number : </label>
    <select id="uweek" name="uweek">';
    for($i=1;$i<13;$i++)
    {
        $week = "Week " . $i;
        echo '<option value="' . $i . '">' . $week . '</option>';
    }
    echo '</select>
</li>
<li>
    <label for="uaims">Week Aims : </label><br />
    <textarea id="uaims" name="uaims" rows="4" cols="40" required="required"></textarea>
</li>
<li>
    <label for="upros">Week Progress : </label><br />
    <textarea id="upros" name="upros" rows="4" cols="40" required="required"></textarea>
</li>
<li>
    <label for="unote">Week Notes : </label><br />
    <textarea id="unote" name="unote" rows="4" cols="40" required="required" placeholder="If no notes, just enter: No notes"></textarea>
</li>
<li>
    <input type="submit" value="Submit" />
</li>
</ul>
</form>';

Results of print_r($_POST);

Array ( [uname] => 3 [uaims] => Aims [upros] => Nope [unote] => No )

Similar results from var_dump($_REQUEST);

array(4) { ["uname"]=> string(1) "3" ["uaims"]=> string(4) "Aims" ["upros"]=> string(4) "Nope" ["unote"]=> string(2) "No" }

Once $_POST executes and goes through, my code (at the top of the php document): Sorry for the endless queries I needed several rounds of info from different tables.

if(!empty($_POST['uname']))
{
    foreach($_POST as $k => $v) {$up[$k] = $v;}
    $sql2 = mysqli_query($link, "SELECT * FROM jestresstracker WHERE UserID='" . mysqli_real_escape_string($link, $up['uname']) ."' ORDER BY WeekNum DESC LIMIT 1");
    $temp = mysqli_fetch_assoc($sql2);
    $sql3 = mysqli_query($link, "SELECT * FROM jestress_users WHERE UserID='" . mysqli_real_escape_string($link, $up['uname']) ."' LIMIT 1");
    $r = mysqli_fetch_assoc($sql3);
    foreach($r as $k => $v) {$User[$k] = $v;}
    if(!empty($temp['WeekNum']))
    {
        if($up['uweek']<=$temp['WeekNum']) {$result = "Error. Update already set for this week. Week Num: " . $temp['WeekNum'];}
    }
    else {
        $ins = mysqli_query($link, "INSERT INTO jestresstracker (UserID, WeekNum, WeekAims, WeekPro, Updated, UpdatedBy, Notes) VALUES('" . mysqli_real_escape_string($link, $up['uname']) . "', '" . mysqli_real_escape_string($link, $up['uweek']) . "', '" . mysqli_real_escape_string($link, nl2br($up['uaims'])) . "', '" . mysqli_real_escape_string($link, nl2br($up['upros'])) . "', NOW(), '" . mysqli_real_escape_string($link, $res['UserID']) . "', '" . mysqli_real_escape_string($link, nl2br($up['unote'])) . "')");
        if($ins) {$result = "Successfully updated " . $User['RealName'] . "'s Week " . $up['uweek'] . " post.";var_dump($_REQUEST);}
        else {$result = "Error: " . mysqli_error($link);}
    }
}

EDIT: Changing the id/name doesn't return different results.

like image 700
Mike Shaw Avatar asked Oct 03 '13 21:10

Mike Shaw


People also ask

Why are my Facebook posts not posting?

If a message like "There Was a Problem Updating Your Status" or "This Message Could Not Be Posted to This Timeline" appears when you attempt to post to your profile, more than likely Facebook is experiencing network or server issues.

Why is my Facebook post not showing up on the News Feed?

If your Facebook feed doesn't appear to be showing the most recent posts, or if some posts which are shared to your Facebook page are missing, then the most likely explanation is that those posts in your feed may be shared from a user's personal Facebook profile or a Facebook page which has an age or location ...

Why can't I highlight someone's name on Facebook?

Your tag may need to be approved by the person you tagged or the person who posted the photo (if it is not yours), depending on their privacy settings for Timeline Review or tag review. You may not see the option to tag people in photos posted by others, depending on their audience settings.

Why is tagging not working on Facebook?

In 2021, Facebook discontinued its facial recognition feature, meaning that the service will no longer recognize your face and suggest it as a tag in photos for your friends. Manual tagging for photos and posts is still an option, however.


1 Answers

The best friend here in such situation is firebug or any network analysis tool..

Check the headers and make sure that concerned field is indeed posted through..

I think this may help greatly..

like image 97
Dev Avatar answered Oct 07 '22 00:10

Dev