Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Posting information in MYSQL from form-table

Status
Not open for further replies.

patrickstrijdonck

Programmer
Jan 18, 2009
97
NL
Hi all,

i have a little problem. when i put fields in my form, and create an post code etc etc... it will work fine

but when i put the fields into a nice table on the form,
the same code wont work to post into MYSQl.

this is the code that will see the fields "voornaam", "achternaam" etc etc as EMPTY
if fields are not in a table, the fields are not EMPTY

Code:
<?php
include 'dbc.php';
session_start();

$id=$_REQUEST['id'];
$personeelsnr = $_SESSION['personeelsnummer'];

if (!isset($_SESSION['user']))
{
 die ("Access Denied");
}

$useremail = $_SESSION['user'];

$result = mysql_query("SELECT * FROM users WHERE user_email = '$useremail'");
while($row = mysql_fetch_array($result))
{
	$fullname = $row['full_name'];
	
			
			}

if ($_POST['PZ'] == 'Wijzig Persoonsgegevens')
{ 

$voornaamQ = $_SESSION['voornaam'];
$achternaamQ = $_SESSION['achternaam'];
$gebdatumQ = $_SESSION['gebdatum'];
$gebplaatsQ = $_SESSION['gebplaats'];
$adresQ = $_SESSION['adres'];
$postcodeQ = $_SESSION['postcode'];
$plaatsQ = $_SESSION['plaats'];
$fillnrQ = $_SESSION['fillnr'];
$telnrQ = $_SESSION['telnr'];
$faxnrQ = $_SESSION['faxnr'];
$rechtQ = $_SESSION['rechtrayon'];
$lcursusQ = $_SESSION['lcursus'];
$statusQ = $_SESSION['status'];

if(empty($_POST['voornaam']))
	{ $nieuwevoornaam = "$voornaamQ"; } else { $nieuwevoornaam = ($_POST['voornaam']); }
if(empty($_POST['achternaam']))
	{ $nieuweachternaam = "$achternaamQ"; }
if(empty($_POST['gebdatum']))
	{ $nieuwegebdatum = "$gebdatumQ"; }
if(empty($_POST['gebplaats']))
	{ $nieuwegebplaats = "$gebplaatsQ"; }
if(empty($_POST['adres']))
	{ $nieuweadres = "$adresQ"; }
if(empty($_POST['postcode']))
	{ $nieuwepostcode = "$postcodeQ"; }
if(empty($_POST['plaats']))
	{ $nieuweplaats = "$plaatsQ"; }
if(empty($_POST['fillnr']))
	{ $nieuwefillnr = "$fillnrQ"; }
if(empty($_POST['telnr']))
	{ $nieuwetelnr = "$telnrQ"; }
if(empty($_POST['faxnr']))
	{ $nieuwefaxnr = "$faxnrQ"; }
if(empty($_POST['recht']))
	{ $nieuwerecht = "$rechtQ"; }
if(empty($_POST['lcursus']))
	{ $nieuwelcursus = "$lcursusQ"; }
if(empty($_POST['status']))
	{ $nieuwestatus = "$statusQ"; }

$persnr = $_SESSION['pznummer'];

$query1="UPDATE personeel SET voornaam = '$nieuwevoornaam', achternaam = '$nieuweachternaam', gebdatum = '$nieuwegebdatum', gebplaats = '$nieuwegebplaats', adres = '$nieuweadres', postcode = '$nieuwepostcode', plaats = '$nieuweplaats', fillnr = '$nieuwefillnr', telnr = '$nieuwetelnr', faxnr = '$nieuwefaxnr', recht = '$nieuwerecht', lcursus = '$nieuwelcursus', status = '$nieuwestatus' WHERE Personeelsnummer = '$persnr'";

mysql_query($query1) or die(mysql_error());
echo "Record Updated";
echo $nieuwevoornaam;

}





?>

<?php
$rayonlogin = $_SESSION['rayonlogin']; 
if ( $rayonlogin == "1" ) {
 ?><style type="text/css">
<!--
body {
	background-color: #999999;
}
.style1 {
	font-size: 24px;
	font-weight: bold;
}
.style2 {
	font-size: 24px;
}
-->
</style>
<h2 align="center">Welkom <?php echo $fullname; ?> </h2>
<div align="center">
  <?php if (isset($_SESSION['user'])) { ?>
</div>
  <p align="center">Logged in als: <?php echo $_SESSION['user']; ?> | <a href="checkstatus.php">Hoofdscherm</a> | <a href="settings.php">Account instellingen </a> 
  | <a href="personeeltoevoegen.php">Voeg personeel toe</a>  | Cursus Planning | Informatie | <a href="logout.php">Loguit</a> |</p>
  <div align="center">
    <?php } ?>
</div>
<? } 
$bedrijflogin = $_SESSION['bedrijflogin'];

if( $bedrijflogin == "1" ) {
?>
<h2 align="center">Welkom <?php echo $fullname; ?> </h2>
<div align="center">
  <?php if (isset($_SESSION['user'])) { ?>
</div>
<p align="center">Logged in als: <?php echo $_SESSION['user']; ?> | <a href="checkstatus.php">Hoofdscherm</a> | <a href="settings.php">Account instellingen </a> 
  | <a href="personeeltoevoegen.php">Voeg personeel toe</a> | Cursus Planning | Informatie | <a href="logout.php">Loguit</a> |</p>
  <div align="center">
    <?php } ?>
</div>
<? } 
$cursuslogin = $_SESSION['cursuslogin'];
if( $cursuslogin == "1" ) {
?>
<h2 align="center">Welkom <?php echo $fullname; ?> </h2>
<div align="center">
  <?php if (isset($_SESSION['user'])) { ?>
</div>
<p align="center">Logged in als: <?php echo $_SESSION['user']; ?> | <a href="checkstatus.php">Hoofdscherm</a> | <a href="settings.php">Account instellingen </a> 
  | Cursus Planning | Informatie | <a href="logout.php">Loguit</a> |</p>
<div align="center">
    <?php } ?>
</div>
  <p align="center">
    <? } else {
;
}
?></p>
    <p align="center"><span class="style1">Personeelslid:</span>
<? 
  $personeelsnr = $_SESSION['personeelsnummer'];
		  $query  = "SELECT Personeelsnummer, voornaam, achternaam, fillnr FROM personeel WHERE Personeelsnummer = '$id'";
$result = mysql_query($query);

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{ ?> <span class="style2"> <? echo "{$row['voornaam']} ";
echo "{$row['achternaam']} ";
 } 
  ?></p></span>
  <table width="874" border="1" align="center">
    <tr>
      <td width="150" bgcolor="#006666">Personeelsnummer</td>
      <td width="203"><? $personeelsnr = $_SESSION['personeelsnummer'];
		  $query  = "SELECT Personeelsnummer, voornaam, achternaam, fillnr FROM personeel WHERE Personeelsnummer = '$id'";
$result = mysql_query($query);

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{ echo "{$row['Personeelsnummer']} <br>";
$pznummer = $row['Personeelsnummer'];
$_SESSION['pznummer']= $pznummer;
 } ?></td>
      <td width="155">&nbsp;</td>
      <td width="338">* Personeelsnummer kan niet gewijzigt worden</td>
    </tr>
    <tr>
      <td bgcolor="#006666">Voornaam</td>
      <td><? $personeelsnr = $_SESSION['personeelsnummer'];
		  $query  = "SELECT Personeelsnummer, voornaam, achternaam, fillnr FROM personeel WHERE Personeelsnummer = '$id'";
$result = mysql_query($query);

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{ echo "{$row['voornaam']} <br>";
$voornaam = $row['voornaam'];
$_SESSION['voornaam']= $voornaam;
 } ?></td>
      <td><form name="form1" method="post" action="">
        <label>
          <input type="text" name="voornaam" id="voornaam">
        </label>
      </form>      </td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td bgcolor="#006666">Achternaam</td>
      <td><? $personeelsnr = $_SESSION['personeelsnummer'];
		  $query  = "SELECT Personeelsnummer, voornaam, achternaam, fillnr FROM personeel WHERE Personeelsnummer = '$id'";
$result = mysql_query($query);

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{ echo "{$row['achternaam']} <br>";
$achternaam = $row['achternaam'];
$_SESSION['achternaam']= $achternaam;
 } ?></td>
      <td><form name="form3" method="post" action="">
        <label>
          <input type="text" name="achternaam" id="achternaam">
        </label>
      </form>      </td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td bgcolor="#006666">Geboortedatum</td>
      <td><? $personeelsnr = $_SESSION['personeelsnummer'];
		  $query  = "SELECT Personeelsnummer, voornaam, achternaam, gebdatum, gebplaats, fillnr FROM personeel WHERE Personeelsnummer = '$id'";
$result = mysql_query($query);

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{ echo "{$row['gebdatum']} <br>";
$gebdatum = $row['gebdatum'];
$_SESSION['gebdatum']= $gebdatum;
 } ?></td>
      <td><form name="form4" method="post" action="">
        <label>
          <input type="text" name="gebdatum" id="gebdatum">
        </label>
      </form>      </td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td bgcolor="#006666">Geboorteplaats</td>
      <td><? $personeelsnr = $_SESSION['personeelsnummer'];
		  $query  = "SELECT Personeelsnummer, voornaam, achternaam, gebdatum, gebplaats, fillnr FROM personeel WHERE Personeelsnummer = '$id'";
$result = mysql_query($query);

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{ echo "{$row['gebplaats']} <br>";
$gebplaats = $row['gebplaats'];
$_SESSION['gebplaats']= $gebplaats;
 } ?></td>
      <td><form name="form5" method="post" action="">
        <label>
          <input type="text" name="gebplaats" id="gebplaats">
        </label>
      </form>      </td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td bgcolor="#006666">Adres</td>
      <td><? $personeelsnr = $_SESSION['personeelsnummer'];
		  $query  = "SELECT Personeelsnummer, adres, plaats, postcode FROM personeel WHERE Personeelsnummer = '$id'";
$result = mysql_query($query);

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{ echo "{$row['adres']} <br>";
$adres = $row['adres'];
$_SESSION['adres']= $adres;
 } ?></td>
      <td><form name="form6" method="post" action="">
        <label>
          <input type="text" name="adres" id="adres">
        </label>
      </form>      </td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td bgcolor="#006666">Postcode</td>
      <td><? $personeelsnr = $_SESSION['personeelsnummer'];
		  $query  = "SELECT Personeelsnummer, adres, plaats, postcode FROM personeel WHERE Personeelsnummer = '$id'";
$result = mysql_query($query);

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{ echo "{$row['postcode']} <br>";
$postcode = $row['postcode'];
$_SESSION['postcode']= $postcode;
 } ?></td>
      <td><form name="form7" method="post" action="">
        <label>
          <input type="text" name="postcode" id="postcode">
        </label>
      </form>      </td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td bgcolor="#006666">Plaats</td>
      <td><? $personeelsnr = $_SESSION['personeelsnummer'];
		  $query  = "SELECT Personeelsnummer, adres, plaats, postcode FROM personeel WHERE Personeelsnummer = '$id'";
$result = mysql_query($query);

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{ echo "{$row['plaats']} <br>";
$plaats = $row['plaats'];
$_SESSION['plaats']= $plaats;
 } ?></td>
      <td><form name="form8" method="post" action="">
        <label>
          <input type="text" name="plaats" id="plaats">
        </label>
      </form>      </td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td bgcolor="#006666">Filliaalnummer</td>
      <td><? $personeelsnr = $_SESSION['personeelsnummer'];
		  $query  = "SELECT Personeelsnummer, adres, plaats, postcode, fillnr FROM personeel WHERE Personeelsnummer = '$id'";
$result = mysql_query($query);

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{ echo "{$row['fillnr']} <br>";
$fillnr = $row['fillnr'];
$_SESSION['fillnr']= $fillnr;
 } ?></td>
      <td><form name="form9" method="post" action="">
        <label>
          <input type="text" name="fillnr" id="fillnr">
        </label>
      </form>      </td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td bgcolor="#006666">Telefoonnummer</td>
      <td><? $personeelsnr = $_SESSION['personeelsnummer'];
		  $query  = "SELECT Personeelsnummer, adres, plaats, postcode, telnr FROM personeel WHERE Personeelsnummer = '$id'";
$result = mysql_query($query);

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{ echo "{$row['telnr']} <br>";
$telnr = $row['telnr'];
$_SESSION['telnr']= $telnr;
 } ?></td>
      <td><form name="form10" method="post" action="">
        <label>
          <input type="text" name="telnr" id="telnr">
        </label>
      </form>      </td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td bgcolor="#006666">Faxnummer</td>
      <td><? $personeelsnr = $_SESSION['personeelsnummer'];
		  $query  = "SELECT Personeelsnummer, adres, plaats, postcode, faxnr FROM personeel WHERE Personeelsnummer = '$id'";
$result = mysql_query($query);

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{ echo "{$row['faxnr']} <br>";
$faxnr = $row['faxnr'];
$_SESSION['faxnr']= $faxnr;
 } ?></td>
      <td><form name="form11" method="post" action="">
        <label>
          <input type="text" name="faxnr" id="faxnr">
        </label>
      </form>      </td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td bgcolor="#006666">Rayon</td>
      <td><? $personeelsnr = $_SESSION['personeelsnummer'];
		  $query  = "SELECT Personeelsnummer, adres, plaats, postcode, recht FROM personeel WHERE Personeelsnummer = '$id'";
$result = mysql_query($query);

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{ echo "{$row['recht']} <br>";
$recht = $row['recht'];
$_SESSION['rechtrayon']= $recht;
 } ?></td>
      <td><select name="recht" id="recht">
        <option value="louwe">1. Marcel Louwe</option>
        <option value="bosters">2. Ron Bosters</option>
        <option value="boers">3. Peter Boers</option>
        <option value="klaassens">4. Fred Klaassens</option>
      </select></td>
      <td>* Wijzig hier het rayon waar personeelslid werkzaam is</td>
    </tr>
    <tr>
      <td bgcolor="#006666">Laatste Cursus</td>
      <td><? $personeelsnr = $_SESSION['personeelsnummer'];
		  $query  = "SELECT Personeelsnummer, adres, plaats, postcode, lcursus FROM personeel WHERE Personeelsnummer = '$id'";
$result = mysql_query($query);

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{ echo "{$row['lcursus']} <br>";
$lcursus = $row['lcursus'];
$_SESSION['lcursus']= $lcursus;
 } ?></td>
      <td><form name="form2" method="post" action="">
        <label>
          <input type="text" name="lcursus" id="lcursus">
        </label>
      </form>      </td>
      <td>* Wijzig hier de laatste cursus die geslaagt is</td>
    </tr>
    <tr>
      <td bgcolor="#006666">status</td>
      <td><? $personeelsnr = $_SESSION['personeelsnummer'];
		  $query  = "SELECT Personeelsnummer, adres, plaats, postcode, status FROM personeel WHERE Personeelsnummer = '$id'";
$result = mysql_query($query);

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{ echo "{$row['status']} <br>";
$status = $row['status'];
$_SESSION['status']= $status;
 } ?></td>
      <td><select name="status" id="status">
        <option value="in dienst">In dienst</option>
        <option value="uit dienst">Uit dienst</option>
      </select></td>
      <td>&nbsp;</td>
    </tr>
  </table>
<form name="form12" method="post" action="">
    <label>
    <div align="center">
      <input type="submit" name="PZ" id="PZ" value="Wijzig Persoonsgegevens">
    </div>
  </label>
    <label>
    <div align="center">
      <input type="submit" name="IN" id="IN" value="In Planning Zetten">
    </div>
  </label>
    <label>
    <div align="center">
      <input type="submit" name="UIT" id="UIT" value="Uit Planning Zetten">
    </div>
  </label>
    <label>
    <div align="center">
      <input type="submit" name="DEL" id="DEL" value="Verwijder Personeelslid">
    </div>
  </label>
  </form>
  <p align="center">&nbsp; </p>

what can be wrong???
 
The submit button in a form will submit all the fields from the said form. In your code, there are no fields in the form that has any submit buttons (form12). All the fields are in different forms that never get submitted (pressing enter in the text boxes might allow you to submit that particular form, but still only that particular text box value would then get sent. Ultimately, it seems like your select boxes are not even inside a form, so their value will never get submitted.

Since all the values that you want to send to another page need to be in the same form, I suggest you wrap the form code around the whole table (and the divs where the actual submit buttons are).

[small]Do something about world cancer today: Comprehensive cancer control information at PACT[/small]
 
i removed all
Code:
<form name="form12" method="post" action="personeelwijzigen.php">
from all fields except for the first 1
i also removed all
Code:
 </form>
except for the last one,
now when i push Submit, it will only change the first field wich is "Voornaam" and it will make the other fields blank!!
so only the first field is updated, i tried to switch the location of the
Code:
<form name="form12" method="post" action="personeelwijzigen.php">
from all fields except for the first 1
i also removed all
Code:
 </form>
but nothing helped.

Any suggestions?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top