arne
12-28-2005, 04:17 PM
Hi, i have another problem, the code below was working right, untill i inserted the if (empty....) tags. I also think there's a better way to do it then the way i'm trying to.
It's like this : if the form 'catnaam' is empty, it shouldt update 'origcatnaam' into 'catnaam'. Also with this code, a part of the form is seen twice !
If you can't find in the code wich part is seen twice, go to here :
http://www.superprofile.nl/arne/catwijzigen.php
there you'll find it ! at least i hope so !
I'm sorry i'm a total noob in php !!!
<?
include 'global.php';
include("bovenbody.php");
if(isset($_GET['actie']) AND $_GET['actie'] == "controleren"){
//
if (empty($_POST['catnaam'])) {
$_POST['catnaam']=$_POST['origcatnaam'];
}
//
@mysql_query("UPDATE cats SET locatie='".lekubb($_POST['plaats'])."', naam='".lekubb($_POST['catnaam'])."', gebruikersnaam='".$lid."', inltekst='".lekubb($_POST['bericht'])."' WHERE gebruikersnaam='".$lid."' AND cat='".lekubb($_POST['origcatnaam'])."'");
if (empty($_POST['catnaam'])) {
}else{
@mysql_query("UPDATE links SET cat='".lekubb($_POST['catnaam'])."' WHERE gebruikersnaam='".$lid."' AND cat='".lekubb($_POST['origcatnaam'])."'");
}
?>
<?
begintabel("Succesvol aangepast");
echo "De categorie is aangepast !";
eindetabel();
} else {
begintabel("Categorie aanpassen");
echo "<form action='".$_SERVER['PHP_SELF']."?actie=controleren' method='POST'>
Bij het veranderen van de categorienaam worden automatisch ook de links in die categorie verplaatst naar de nieuwe categorie.<br><br><br>
<table width='100%' border='0' cellpadding='0' cellspacing='0' height='167'>
<tr>
<td width='50%' height='24'>Huidige categorienaam</td>
<td width='50%' height='24'>
<input type='text' name='origcatnaam' size='20'>";
$query = "SELECT * FROM cats WHERE gebruikersnaam='$lid'";
$uitvoer = mysql_query($query) or die (mysql_error());
while($lijst = mysql_fetch_object($uitvoer))
{?>
<option value='<?php echo"$lijst->naam"; ?>'><?php echo"$lijst->naam"; ?></option>
</td>
</tr>
<tr>
<td width='50%' height='24'>Nieuwe categorienaam*</td>
<td width='50%' height='24'>
<input type='text' name='catnaam' size='20'></td></tr>
*Laat dit leeg als u de huidige naam wil behouden !
<tr>
<td width='50%' height='24'>Locatie</td>
<td width='50%' height='24'>
<select size='1' name='plaats'>
<option value='1'>Links</option>
<option value='2'>Midden</option>
<option value='3'>rechts</option>
</select></td>
</tr>
<tr> <td width='50%' height='68'>Bericht</td>
<td width='50%' height='68'>
<textarea name='bericht' rows='4' cols='35' value='<?php echo"$lijst->bericht"; ?>'></textarea></td>
</tr>
<tr>
<td width='50%' height='25'> </td>
<td width='50%' height='25'> </td>
</tr>
<tr>
<td width='50%' height='26'>Bevestigen</td>
<td width='50%' height='26'><input type='submit' value='Toevoegen'></td>
</tr>
</table>
<?
eindetabel();
}
}
include("onderbody.php") ?>
Bye and thanx for helping me out !
It's like this : if the form 'catnaam' is empty, it shouldt update 'origcatnaam' into 'catnaam'. Also with this code, a part of the form is seen twice !
If you can't find in the code wich part is seen twice, go to here :
http://www.superprofile.nl/arne/catwijzigen.php
there you'll find it ! at least i hope so !
I'm sorry i'm a total noob in php !!!
<?
include 'global.php';
include("bovenbody.php");
if(isset($_GET['actie']) AND $_GET['actie'] == "controleren"){
//
if (empty($_POST['catnaam'])) {
$_POST['catnaam']=$_POST['origcatnaam'];
}
//
@mysql_query("UPDATE cats SET locatie='".lekubb($_POST['plaats'])."', naam='".lekubb($_POST['catnaam'])."', gebruikersnaam='".$lid."', inltekst='".lekubb($_POST['bericht'])."' WHERE gebruikersnaam='".$lid."' AND cat='".lekubb($_POST['origcatnaam'])."'");
if (empty($_POST['catnaam'])) {
}else{
@mysql_query("UPDATE links SET cat='".lekubb($_POST['catnaam'])."' WHERE gebruikersnaam='".$lid."' AND cat='".lekubb($_POST['origcatnaam'])."'");
}
?>
<?
begintabel("Succesvol aangepast");
echo "De categorie is aangepast !";
eindetabel();
} else {
begintabel("Categorie aanpassen");
echo "<form action='".$_SERVER['PHP_SELF']."?actie=controleren' method='POST'>
Bij het veranderen van de categorienaam worden automatisch ook de links in die categorie verplaatst naar de nieuwe categorie.<br><br><br>
<table width='100%' border='0' cellpadding='0' cellspacing='0' height='167'>
<tr>
<td width='50%' height='24'>Huidige categorienaam</td>
<td width='50%' height='24'>
<input type='text' name='origcatnaam' size='20'>";
$query = "SELECT * FROM cats WHERE gebruikersnaam='$lid'";
$uitvoer = mysql_query($query) or die (mysql_error());
while($lijst = mysql_fetch_object($uitvoer))
{?>
<option value='<?php echo"$lijst->naam"; ?>'><?php echo"$lijst->naam"; ?></option>
</td>
</tr>
<tr>
<td width='50%' height='24'>Nieuwe categorienaam*</td>
<td width='50%' height='24'>
<input type='text' name='catnaam' size='20'></td></tr>
*Laat dit leeg als u de huidige naam wil behouden !
<tr>
<td width='50%' height='24'>Locatie</td>
<td width='50%' height='24'>
<select size='1' name='plaats'>
<option value='1'>Links</option>
<option value='2'>Midden</option>
<option value='3'>rechts</option>
</select></td>
</tr>
<tr> <td width='50%' height='68'>Bericht</td>
<td width='50%' height='68'>
<textarea name='bericht' rows='4' cols='35' value='<?php echo"$lijst->bericht"; ?>'></textarea></td>
</tr>
<tr>
<td width='50%' height='25'> </td>
<td width='50%' height='25'> </td>
</tr>
<tr>
<td width='50%' height='26'>Bevestigen</td>
<td width='50%' height='26'><input type='submit' value='Toevoegen'></td>
</tr>
</table>
<?
eindetabel();
}
}
include("onderbody.php") ?>
Bye and thanx for helping me out !