[php]Checkbox nic nie zwraca

0

Witam. Robię formularz do rejestracji i mam w nim kilka checkbox'ów. Problem jest taki, że jak chce potem sprawdzić czy są zaznaczone, to nie zwracają żadnej warotści, bez względu na to czy są zaznaczone, czy nie. Tak wygląda kawałek formularza, gdzie są chceckbox'y:

<table width="100%" cellspacing="1" cellpadding="0" bgcolor="White">
  <tbody style="font-size : 11px; background-color : #F5F5F5" valign="center">
    <tr><td><b>Opcje</b></td></tr>
    <tr><td><input type="checkbox" checked="true" name="ShowMyEMail">Pokazuj mój e-mail</td></tr>
    <tr><td><input type="checkbox" name="ShowMobilephone">Pokazuj mój nr telefonu komórkowego</td></tr>
    <tr><td><input type="checkbox" checked="true" name="EneablePM">Pozwalaj wysyłać do mnie e-mail z formularza na stronie</td></tr>
    <tr><td><input type="checkbox" name="InformMe">Informuj mnie o nowościach</td></tr>
 </tbody>
</table>

A tak część skryptu, który te zmienne pobiera:

//...
$ShowMyEMail = $_POST['ShowMyEMail'];
$ShowMobilephone = $_POST['ShowMobilepoone'];
$EneablePM = $_POST['EneablePM'];
$InformMe = $_POST['InformMe'];
//...
//tutaj kilka funkcji, które w ogóle nie kożystają z tych zmiennych
//...

//teraz sprawdzałem czy w ogóle coś działa:
echo "$ShowMyEMail";
echo "<br>";
echo "$ShowMobilephone";
echo "<br>";
echo "$EneablePM";
echo "<br>";
echo "$InformMe";

No i niezależnie od tego czy którykolwiek checkbox był zaznaczony nic nie jest wyświetlane

0

A masz kod HTML zagnieżdżony w <form>?

0

Mam. Dam może cały kod
Plik registry.php:

  <?
    $Action = $_POST['Action'];
    if($Action != 'registry'){ 
      showregistryform();
    }
    else{
      $UserID          = $_POST['UserID'];
      $Name            = $_POST['Name'];
      $Surname         = $_POST['Surname'];
      $Password        = $_POST['Password'];
      $Password2       = $_POST['Password2'];
      $EMail           = $_POST['EMail'];
      $GGNumber        = $_POST['GGNumber'];
      $ICQNumber       = $_POST['ICQNumber'];
      $TlenID          = $_POST['TlenID'];
      $JabberID        = $_POST['JabberID'];
      $Mobilephone     = $_POST['Mobilephone'];
      $WWW             = $_POST['WWW'];
      $City            = $_POST['City'];
      $Hobby           = $_POST['Hobby'];
      $AboutUser       = $_POST['AboutUser'];
      $ShowMyEMail     = $_POST['ShowMyEMail'];
      $ShowMobilephone = $_POST['ShowMobilepoone'];
      $EneablePM       = $_POST['EneablePM'];
      $InformMe        = $_POST['InformMe'];
      $Avatar          = $_POST['Avatar'];
      //Sprawd czy wymagane dane zostay wprowadzone i czy haso si?zgadza
      //...
      $IsOK = true;
      echo '<span style="font-size : 13px; color:red"><b>';
      if($UserID == ''){echo "Musisz wypenić pole \"Nazwa użttkownika\"<br>"; $IsOK = false;}
      if($Password == ''){echo "Musisz wypenić pole \"Hasło\"<br>"; $IsOK = false;}
      if($Password2 == ''){echo "Musisz wypenić pole \"Potwierdź hasło\"<br>"; $IsOK = false;}
      if($Password != $Password2 && $Password != '' && $Password2 != ''){echo "Podane hasła nie są takie same<br>"; $IsOK = false;}
      echo '</b></span>';
      //Sprawd czy wprowadzone frazy nie s za dugie
      //...
      //Zastp znaki specjalne ich odpowiednikami w php
      //...
      //Sprawd czy wszystkie dane s w miar?poprawne - np. czy GGNumber jest liczb
      //...
      //Sprawd czy podany uytkownik czasem ju nie istnieje
      //...
      if($IsOK == true){acceptdata();} else{showregistryform();}
    }

    function showregistryform(){
      echo '<span style="font-size : 20px;"><b><div align="center">';
      echo 'Rejestracja';
      echo '</div></b></span><br>';
      echo '<form method="POST">';
      echo '<input type="hidden" name="Action" value="registry">';
      include('pages/registryform.php');
      echo '</form>';
      echo '<br><br>';
    }

    function acceptdata(){
      echo '<span style="font-size : 20px;"><b><div align="center">';
      echo 'Kończenie rejestracji';
      echo '</div></b></span><br><br>';
      echo 'Oto jakie podałeś informacje:<br>';
      echo "$ShowMyEMail"; //tutaj właście sprawdzam czy działa. Narazie tylko na jednym checkboxie, ale na innych też sprawdzałem
      echo '<br><br>';
    }
  ?>

Plik registryform.php:

<table width="100%" cellspacing="1" cellpadding="0" bgcolor="White">
  <tbody style="font-size : 11px; background-color : #F5F5F5" valign="center">
    <tr><td><b>Informacje o Tobie</b></td><td></td></tr>
    <tr><td>Nazwa użytkownika *</td><td><input type="text" name="UserID" class="textinput" <? $ThisValue = $_POST['UserID']; echo 'value="' ."$ThisValue" .'"'; ?>></td></tr>
    <tr><td>Imię</td><td><input type="text" name="Name" class="textinput" <? $ThisValue = $_POST['Name']; echo 'value="' ."$ThisValue" .'"'; ?>></td></tr>
    <tr><td>Nazwisko</td><td><input type="text" name="Surname" class="textinput" <? $ThisValue = $_POST['Surname']; echo 'value="' ."$ThisValue" .'"'; ?>></td></tr>
    <tr><td>Hasło *</td><td><input type="password" name="Password" class="textinput"></td></tr>
    <tr><td>Powtórz hasło *</td><td><input type="password" name="Password2" class="textinput"></td></tr>
    <tr><td>Adres E-Mail</td><td><input type="text" name="EMail" class="textinput" <? $ThisValue = $_POST['EMail']; echo 'value="' ."$ThisValue" .'"'; ?>></td></tr>
    <tr><td>Numer Gadu-Gadu</td><td><input type="text" name="GGNumber" class="textinput" <? $ThisValue = $_POST['GGNumber']; echo 'value="' ."$ThisValue" .'"'; ?>></td></tr>
    <tr><td>Numer ICQ</td><td><input type="text" name="ICQNumber" class="textinput" <? $ThisValue = $_POST['ICQNumber']; echo 'value="' ."$ThisValue" .'"'; ?>></td></tr>
    <tr><td>Tlen ID</td><td><input type="text" name="TlenID" class="textinput" <? $ThisValue = $_POST['TlenID']; echo 'value="' ."$ThisValue" .'"'; ?>></td></tr>
    <tr><td>Jabber ID</td><td><input type="text" name="JabberID" class="textinput" <? $ThisValue = $_POST['JabberID']; echo 'value="' ."$ThisValue" .'"'; ?>></td></tr>
    <tr><td>Nr telefonu komórkowego</td><td><input type="text" name="Mobilephone" class="textinput" <? $ThisValue = $_POST['Mobilephone']; echo 'value="' ."$ThisValue" .'"'; ?>></td></tr>
    <tr><td>Strona www</td><td><input type="text" name="WWW" class="textinput" <? $ThisValue = $_POST['WWW']; echo 'value="' ."$ThisValue" .'"'; ?>></td></tr>
    <tr><td>Skąd</td><td><input type="text" name="City" class="textinput" <? $ThisValue = $_POST['City']; echo 'value="' ."$ThisValue" .'"'; ?>></td></tr>
    <tr><td>Zainteresowania</td><td><input type="text" name="Hobby" class="textinput" <? $ThisValue = $_POST['Hobby']; echo 'value="' ."$ThisValue" .'"'; ?>></td></tr>
  </tbody>
</table>

<table width="100%" cellspacing="1" cellpadding="0" bgcolor="White">
  <tbody style="font-size : 11px; background-color : #F5F5F5" valign="center">
    <tr><td><b>Dodatkowe informacje</b></td></tr>
    <tr><td>Napisz coś o sobie (nie więcej niż 600 znaków)</td></tr>
    <tr><td><table style="width : 100%;" cellspacing="0" cellpading="0" align="left"><tr><td valign="top"><textarea id="abouttextarea" onchange="changeabouttextarea()" onkeyup="changeabouttextarea()" onfocus="changeabouttextarea()" class="textinput" name="AboutUser" rows="0" cols="0" style="width : 400px; height : 100px; text-align : left; font-size : 12px"><? $ThisValue = $_POST['AboutUser']; echo "$ThisValue"; ?></textarea></td><td valign="bottom" align="right"><div id="charactersleft">Pozostało 600 znaków</div></td><td width="8px"></td></tr></table></td></tr>
 </tbody>
</table>

<table width="100%" cellspacing="1" cellpadding="0" bgcolor="White">
  <tbody style="font-size : 11px; background-color : #F5F5F5" valign="center">
    <tr><td><b>Opcje</b></td></tr>
    <tr><td><input type="checkbox" checked="true" name="ShowMyEMail">Pokazuj mój e-mail</td></tr>
    <tr><td><input type="checkbox" name="ShowMobilephone">Pokazuj mój nr telefonu komórkowego</td></tr>
    <tr><td><input type="checkbox" checked="true" name="EneablePM">Pozwalaj wysyłać do mnie e-mail z formularza na stronie</td></tr>
    <tr><td><input type="checkbox" name="InformMe">Informuj mnie o nowościach</td></tr>
 </tbody>
</table>

<table width="100%" cellspacing="1" cellpadding="0" bgcolor="White">
  <tbody style="font-size : 11px; background-color : #F5F5F5" valign="center">
    <tr><td><b>Awatar (emblemat)</b></td></tr>
    <tr><td>Maksymalne wymiary awatara to 120x120 pikseli. Powinien on być typu *.png, *.jpeg lub *.gif i nie może zajmować więcej niż 200kb. Będzie on przechowywany na serwerze strony i dodawany do informacji o Tobie. Może to być Twoje zdjęcie, lub inny obrazek.</td></tr>
    <tr><td><INPUT type="file" class="textinput" style="width : 300px; height : 21px;" name="Avatar"></td></tr>
 </tbody>
</table>

<table width="100%" cellspacing="1" cellpadding="0" bgcolor="White">
  <tbody style="font-size : 11px; background-color : #F5F5F5;" valign="center">
    <tr><td><b>Rejestracja</b></td><td></td></tr>
    <tr><td valign="top" align="left">Rejestrując się potwierdzasz, że podane prez Ciebie informacje są zgodne z prawdą. Będziesz miał(a) możliwość edycji tych danych, oraz usunięcia konta w dowolnym czasie.</td><td width="180px" valign="bottom" style="text-align : right;"><INPUT class="buttoninput" type="submit" value="Zarejestruj"> <input class="buttoninput" value="Wyczyść" type="reset"></td></tr>
 </tbody>
</table>

<table width="100%" cellspacing="1" cellpadding="0" bgcolor="White">
  <tbody style="font-size : 11px; background-color : #F5F5F5;" valign="center">
    <tr><td>* - Pole obowiązkowe do wypełnienia</td></tr>
 </tbody>
</table>

<script language="javascript">
<!--
  function changeabouttextarea(){
    if((600-(document.getElementById("abouttextarea").value.length)) >= 0){
      document.getElementById("charactersleft").innerHTML = 'Pozostało ' + (600-(document.getElementById("abouttextarea").value.length)) + ' znaków';
    }
    else{
      document.getElementById("charactersleft").innerHTML = '<b><span style="color:red;">Za dużo o ' + (-(600-(document.getElementById("abouttextarea").value.length))) + ' znaków</span></b>';
    }
  }

  changeabouttextarea()
-->
</script>
0

brakuje wartości, czyli VALUE w definiowanych checkbox'ach i dlatego nic nie jest przekazywane do zmiennych.

1 użytkowników online, w tym zalogowanych: 0, gości: 1