Jump to content

update problem


zmdlan

Recommended Posts

Hello

 

Recently I have developed a simple online instrument for our company. The problem is at a certain time when a user update his/her profile, it affected data in the whole table. For example when he/she update the password, his/her new password will replace/update all records in the table.

 

Thanks in advance

Link to comment
Share on other sites

here is the code

 

<?php

session_start();

 

include ('db_connect.php');

 

$_SESSION['kodsekolah'];

 

$kodsekolah=$_SESSION['kodsekolah'];

 

$password=$_POST['password'];

 

 

$update_password = mysql_query ( "UPDATE login SET Password='$password' WHERE KodSekolah LIKE '%$kodsekolah%' ");

 

header ("Location: utama.php");

 

?>

Link to comment
Share on other sites

Well, why are you using LIKE? If the value of $kodsekolah is something like just the letter 'a', then that query would update the password for ALL records containing the letter 'a' in that field. I have no idea what that value is supposed to represent. You also don't explain how that session value is set. But, that is most likely where the problem lies.

 

By the way, what is this line for?

$_SESSION['kodsekolah'];

 

It won't do anything.

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.