开发者

$_POST not working in php

I am new here and I have a question. I have a problem that I can't figure it out with _POST. I have been searching for hours before start writing! As far as I can see I haven't done any of the mistakes that are posted for other similar question (form action..., name attribute...,etc). Please, can you check my code below to tell me what am I doing wrong??

I use xampp 1.7.3 on windows 7.


<?php require("includes/header.php"); ?>
<?php require_once("includes/connection.php"); ?>
<?php require_once("includes/functions.php"); ?><head>
<script type="text/javascript">

function theChecker()
{
 if(document.getElementById('checker').checked){
     document.getElementById('submitter').disabled=false;
 }
 else{
     document.getElementById('submitter').disabled=true;
 }
}
</script>

</head>

<?php require("includes/body_no_menus.php"); ?>

<div align="center">
<form name="signup" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">

 <?php

 echo "<hr/>
<table width='600' border='0'>
  <tr>
    <td width='237'>Κωδικός οικοδομής</td>
    <td width='351'><input name='building_id' type='text' id='building_id' size='30' maxlength='40' />*</td>
  </tr>
  <tr>
    <td>Κωδικός διαμερίσματος</td>
    <td><input name='apartment_id' type='text' id='apartment_id' size='30' maxlength='40' />*</td>
  </tr>
  &开发者_如何学JAVAlt;tr>
   <td></td>
    <td height='31' colspan='2' ><label>
     <input name='send' type='submit' value='Αποστολή' />
    </label></td>
    </tr>

</table>
";
?>
</form>
</div>


<p>

<?php 

if(isset($_POST['send'])) {
 // Check input / Required fields
 $building_id = check_input($_POST['building_id'],"Εισάγετε τον κωδικό της οικοδομής!");
 $apartment_id = check_input($_POST['apartment_id'],"Εισάγετε όνομα χρήστη!");

 $query = "SELECT  idTENANT,FNAME,LNAME,BUILDING_ADMIN,PHONE FROM TENANT,APARTMENT, BUILDING
    WHERE  TENANT.APARTMENT_ID = APARTMENT.idAPARTMENT
    AND    APARTMENT.BUILDING_ID = BUILDING.idBUILDING
    AND  idAPARTMENT = '$apartment_id'
    AND  idBUILDING = '$building_id'";
 $result=mysql_query($query) or die ("Couldn't execute query.");
 $row = mysql_fetch_array( $result );  

 $id = $row['idTENANT'];
 $fname = $row['FNAME'];
 $lname = $row['LNAME'];
 $apartment = $row['APARTMENT_ID'];
 $phone = $row['PHONE'];
 if($row['BUILDING_ADMIN'] == 0)
  $admin = "ΟΧΙ";
 else
  $admin = "ΝΑΙ";
echo " <hr />
<table width='300' border='0'>
    <tr>     
     <td>Όνομα</td>           
  <td>$fname</td>   
 </tr>
    <tr>     
  <td>Επίθετο</td>          
  <td>$lname</td>   
 </tr>
    <tr>     
     <td>Όνομα χρήστη</td>        
     <td><input name='username' type='text' size='30' maxlength='20' />*</td>   
    </tr>
    <tr>     
  <td>Κωδικός χρήστη</td>      
  <td><input name='password' type='password' size='30' maxlength='20'/>*</td>   
 </tr>
    <tr>     
  <td>Επαλήθευση κωδικού</td>    
  <td><input name='verify_password' type='password' size='30' maxlength='40'/> *</td> 
 </tr>
    <tr>     
  <td>Διαχείριση οικοδομής</td>  
  <td>$admin</td>   
 </tr>
    <tr>     
  <td>Τηλέφωνο</td>            
  <td>$phone</td>   </tr>

    <tr>   
  <td></td>
  <td><input name='checkterms' type='checkbox' id='checker' onclick='theChecker()' value='Ναι'/>
    <label>Έχω διαβάσει και αποδέχομαι τους όρους χρήσης.</label> *</td>
   </tr>
   <tr>
    <td></td>
     <td><input type='submit' name='complete'  id='submitter' value='Ολοκλήρωση εγγραφής' disabled/></td>
  </tr>
</table>
";
}

if(isset($_POST['complete'])) {
 // Password match
 if ($password != $verify_password)
 {
   echo '<font color="red">Οι κωδικοί δεν ταιριάζουν</font>';
 }//if
 else 
 { 
  // Execute MySQL commands
  $query = "UPDATE TENANT SET USERNAME = '$un', PASSWD='$pw' WHERE idTENANT='$id'";
  $result=mysql_query($query) or die ("Couldn't execute query.");
  header("Location: main_login.php");
 }//else
}//if
?>

</p>
<?php require("includes/footer.php"); ?>

The first _POST (if(isset($_POST['send']))...) works perfectly. But if(isset($_POST['complete'])) {... does nothing. I ve tried to echo some data to see if my connection doesn't work, but its the _POST...

Please help me!!!!

Thanks for your time!


what you could try:

  1. use vardump to see what $_POST contains: var_dump($_POST);.
  2. use firebug (or something similar for another browser) to lookup the request and see which POST-Parameters are sent.


The second set of form elements (username, password, verify_password, checkterms, complete) are not inside any html form element. Clicking the second button does not post the form to server.


header("Location: main_login.php");

Is not going to work, when $_POST["complete"] is reached. You already sent heaps of output before that. Enable more error_reporting.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜