tags:

views:

133

answers:

3

hey everyone,

im having a problem with php yet again... i've created a page with multiple forms on it and when i test it i've learnt that the first form is processed (with the ongoing, complete and reject) values but then i cant seem to process the 2nd form the same way. what could be the matter?

any help would be appreciated... happy new year to all the users of the site!

   <? 

    if (array_key_exists('complete',$_POST)) {
                echo "Sucess!";
                exit;
                };

    ?>

            <?php   

    $days = range (01, 31);
    $months = range (1, 12);
    $y1 = date("Y")-2;
    $y2 = date("Y");
    $years = range ($y1, $y2);

    if (array_key_exists('caseStatus',$_POST)) {
                    $case = $_POST['case'];

    if ($case == 'complete')
    { 
    echo 'Please set the date on which the case was <b>completed</b>.<p>';
    echo "<form action='" . $_SERVER['PHP_SELF'] . "' method='post'>"; 
    echo '<select name="completeDay">';
    foreach (range(1, 31) as $day) {
        echo '<option value="'.sprintf("%02d", $day).'">'.sprintf("%02d", $day).'</option>';
    }   echo '</select>';
    echo '<select name="completeMon">';
    foreach (range(1, 12) as $month) {
        echo '<option value="'.sprintf("%02d", $month).'">'.sprintf("%02d", $month).'</option>';
    }   echo '</select>';
    echo '<select name="completeYr">';
    foreach ($years as $value) {
        echo '<option value="'.$value.'">'.$value.'</option>';
    }   echo '</select>
    <p>
    <input type="hidden" name="complete" value="1"/> 
    <input name="submit" type="submit" value="Save"/> 
    <input type="button" value="Cancel" onclick="window.location=\'\'"/>
    </form>
    '; 
    exit;
    } 
<form method="POST" action="<?php echo $_SERVER['PHP_SELF'] . '?id=' . intval($client_id); ?>">
    <select name="case" class="rta">
      <option value="<?php echo $row_caseStatus['progress']; ?>" selected="selected"><?php echo $row_caseStatus['progress']; ?></option>
      <option value=""></option>
      <option value="ongoing">ongoing</option>
      <option value="complete">complete</option>
      <option value="reject">reject</option>
      </select>
    <input type="submit" name="caseStatus" id="caseStatus" value="Save" />
                                    <input type="hidden" name="caseStatus" value="1"/> 
    <br />
  </form>
A: 

Its hard to know exactly whats going wrong without more detail.

do you actually see the 2nd form or the word "sucess"?

seengee
i can see the 2nd form but i can't see the word success once the 2nd form is posted... it simply reverts back to an older state of the form
jeansymolanza
A: 

It's hard to tell what the problem is without more information. Can you post the outputted HTML? Are you sure it's not a problem with the other variables you are passing to the method attribute?

In fact, could it be that when you are doing intval($client_id) you are in fact trying to change a string or other non-integer into an integer?

Also, just as a note, if you are adhering to strict XHTML, you should set your form's method attribute to 'post' instead of 'POST'.

John
good catch. somehow i totally missed that. d'oh :)
seengee
No problem. Sorry for having to post a whole new answer for that. x.x
John
the problem is that the 2nd form (once submitted) will not result in the msg being displayed "Sucess".. excuse the spelling
jeansymolanza
Yes, but can you give us the exact HTML output of the page? Hit Ctrl + U if you are on Firefox or go to View -> View Source, copy and paste that here?
John
A: 
<?php

    if (array_key_exists('complete',$_POST)) {
                echo "Sucess!";
                exit;
                };

    ?>

a simple error... just needed to edit the opening php tag!

jeansymolanza
if thats the case then the other solution would have been to enable short tags. Its seen as bad practice due to the fact its not always on - and hence your issues - but i tend to use them myself.
seengee
thanks for the tip
jeansymolanza