开发者

problems posting twice to same page using PHP_SELF... is this possible?

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;
                };

    ?>

      开发者_如何学JAVA      <?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>


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

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


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'.


<?php

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

    ?>

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜