Jump to content

[SOLVED] Modifing information in mysql


xiler

Recommended Posts

Hi cant get to work my user information editor. Any help is welcome ;)

And PS! sorry its written in estonian language but i think you guys understand the php code ;)

 

 

Should i do it simple like that

<?
//Määra vajalikud failid
include 'design/konf.php';
?>
<?
if(isset($_GET['id']))
{
   $query  = "SELECT id, nimi, vanus, telefon, mail, aadress, koerad, aktiivsus, reg_kuupaev, liikme_tasu ".
             "FROM liikmed_info ".
             "WHERE id = '{$_GET['id']}'";
   $result = mysql_query($query) or die('Viga : ' . mysql_error());
   list($id, $nimi, $vanus, $telefon, $mail, $aadress, $koerad, $aktiivsus, $reg_kuupaev, $liikme_tasu) = mysql_fetch_array($result);

      $nimi = htmlspecialchars($nimi);
      $vanus = htmlspecialchars($vanus);
      $telefon = htmlspecialchars($telefon);
      $mail = htmlspecialchars($mail);
      $aadress = htmlspecialchars($aadress);
      $koerad = htmlspecialchars($koerad);
      $aktiivsus = htmlspecialchars($aktiivsus);
      $reg_kuupaev = htmlspecialchars($reg_kuupaev);
      $liikme_tasu = htmlspecialchars($liikme_tasu);
   
}
else if(isset($_POST['save']))
{
   $id = $_POST['id'];
   $nimi = $_POST['nimi'];
   $vanus = $_POST['vanus'];
   $telefon = $_POST['telefon'];
   $mail = $_POST['mail'];
   $aadress = $_POST['aadress'];
   $koerad = $_POST['koerad'];
   $aktiivsus = $_POST['aktiivsus'];
   $reg_kuupaev = $_POST['reg_kuupaev'];
   $liikme_tasu = $_POST['liikme_tasu'];

   // update the article in the database
   $query = "UPDATE liikmed_info".
            "SET nimi = '$nimi', vanus = '$vanus', telefon = '$telefon', mail = '$mail', aadress = '$aadress', koerad = '$koerad', aktiivsus = '$aktiivsus', reg_kuupaev = '$reg_kuupaev', liikme_tasu = '$liikme_tasu' ".
            "WHERE id = '$id'";
   mysql_query($query) or die('Viga uuendamisel : ' . mysql_error());

   echo "Liige '$id'.'$nimi' uuendatud!";


?>
<table width="431" border="0" align="center">
<form action="" method="post">
<input type="hidden" name="id" value="<?=$id;?>">
  <tr>
    <td width="122">Nimi:</td>
    <td width="167"><input name="nimi" type="text" value="<?=$nimi;?>" size="30"></td>
  </tr>
  <tr>
    <td>Vanus:</td>
    <td><input name="Vanus" type="text" value="<?=$vanus;?>" size="30"></td>
  </tr>
  <tr>
    <td>Telefon:</td>
    <td><input name="telefon" type="text" value="<?=$telefon;?>" size="30"></td>
  </tr>
  <tr>
    <td>E-Mail:</td>
    <td><input name="mail" type="text" value="<?=$mail;?>" size="30"></td>
  </tr>
  <tr>
    <td>Aadress:</td>
    <td><input name="aadress" type="text" value="<?=$aadress;?>" size="30"></td>
  </tr>
  <tr>
    <td>Koerad:</td>
    <td><textarea name="koerad" cols="40" rows="3"><?=$koerad;?>
    </textarea></td>
  </tr>
  <tr>
    <td>Registreerimis kuupäev:</td>
    <td><input name="reg_kuupaev" type="text" value="<?=$reg_kuupaev;?>" size="30"></td>
  </tr>
  <tr>
    <td></td>
    <td colspan="2" align="center"><input name="update" type="submit" class="box" id="update" value="Muuda"></td>
  </tr>
  </form>
</table>
<p align="center"><a href="design/admin.php">Tagasi administraatori konsooli</a></p>

 

or should i use addslashes & stripslashes ?

 

<?
//Määra vajalikud failid
include 'design/konf.php';
?>
<?
if(isset($_GET['id']))
{
   $query  = "SELECT id, nimi, vanus, telefon, mail, aadress, koerad, aktiivsus, reg_kuupaev, liikme_tasu ".
             "FROM liikmed_info ".
             "WHERE id = '{$_GET['id']}'";
   $result = mysql_query($query) or die('Viga : ' . mysql_error());
   list($id, $nimi, $vanus, $telefon, $mail, $aadress, $koerad, $aktiivsus, $reg_kuupaev, $liikme_tasu) = mysql_fetch_array($result);

      $nimi = htmlspecialchars($nimi);
      $vanus = htmlspecialchars($vanus);
      $telefon = htmlspecialchars($telefon);
      $mail = htmlspecialchars($mail);
      $aadress = htmlspecialchars($aadress);
      $koerad = htmlspecialchars($koerad);
      $aktiivsus = htmlspecialchars($aktiivsus);
      $reg_kuupaev = htmlspecialchars($reg_kuupaev);
      $liikme_tasu = htmlspecialchars($liikme_tasu);
   
}
else if(isset($_POST['save']))
{
   $id = $_POST['id'];
   $nimi = $_POST['nimi'];
   $vanus = $_POST['vanus'];
   $telefon = $_POST['telefon'];
   $mail = $_POST['mail'];
   $aadress = $_POST['aadress'];
   $koerad = $_POST['koerad'];
   $aktiivsus = $_POST['aktiivsus'];
   $reg_kuupaev = $_POST['reg_kuupaev'];
   $liikme_tasu = $_POST['liikme_tasu'];
   

   if(!get_magic_quotes_gpc())
   {
      $nimi = addslashes($nimi);
      $vanus = addslashes($vanus);
      $telefon = addslashes($telefon);
      $mail = addslashes($mail);
      $aadress = addslashes($aadress);
      $koerad = addslashes($koerad);
      $aktiivsus = addslashes($aktiivsus);
      $reg_kuupaev = addslashes($reg_kuupaev);
      $liikme_tasu = addslashes($liikme_tasu);
   }

   // update the article in the database
   $query = "UPDATE liikmed_info ".
            "SET nimi = '$nimi', vanus = '$vanus', telefon = '$telefon', mail = '$mail', aadress = '$aadress', koerad = '$koerad', aktiivsus = '$aktiivsus', reg_kuupaev = '$reg_kuupaev', liikme_tasu = '$liikme_tasu' ".
            "WHERE id = '$id'";
   mysql_query($query) or die('Viga uuendamisel : ' . mysql_error());

   echo "Liige '$id'.'$nimi' uuendatud!";

   // now we will display $title & content
   // so strip out any slashes
      $nimi = stripslashes($nimi);
      $vanus = stripslashes($vanus);
      $telefon = stripslashes($telefon);
      $mail = stripslashes($mail);
      $aadress = stripslashes($aadress);
      $koerad = stripslashes($koerad);
      $aktiivsus = stripslashes($aktiivsus);
      $reg_kuupaev = stripslashes($reg_kuupaev);
      $liikme_tasu = stripslashes($liikme_tasu);
?>
<table width="431" border="0" align="center">
<form action="" method="post">
<input type="hidden" name="id" value="<?=$id;?>">
  <tr>
    <td width="122">Nimi:</td>
    <td width="167"><input name="nimi" type="text" value="<?=$nimi;?>" size="30"></td>
  </tr>
  <tr>
    <td>Vanus:</td>
    <td><input name="Vanus" type="text" value="<?=$vanus;?>" size="30"></td>
  </tr>
  <tr>
    <td>Telefon:</td>
    <td><input name="telefon" type="text" value="<?=$telefon;?>" size="30"></td>
  </tr>
  <tr>
    <td>E-Mail:</td>
    <td><input name="mail" type="text" value="<?=$mail;?>" size="30"></td>
  </tr>
  <tr>
    <td>Aadress:</td>
    <td><input name="aadress" type="text" value="<?=$aadress;?>" size="30"></td>
  </tr>
  <tr>
    <td>Koerad:</td>
    <td><textarea name="koerad" cols="40" rows="3"><?=$koerad;?>
    </textarea></td>
  </tr>
  <tr>
    <td>Registreerimis kuupäev:</td>
    <td><input name="reg_kuupaev" type="text" value="<?=$reg_kuupaev;?>" size="30"></td>
  </tr>
  <tr>
    <td></td>
    <td colspan="2" align="center"><input name="update" type="submit" class="box" id="update" value="Muuda"></td>
  </tr>
  </form>
</table>
<p align="center"><a href="design/admin.php">Tagasi administraatori konsooli</a></p>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.