6 Replies - 293 Views - Last Post: 04 February 2012 - 07:25 AM Rate Topic: -----

Topic Sponsor:

#1 decongh  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 39
  • Joined: 31-December 11

update value is not changing

Posted 03 February 2012 - 09:05 AM

I have my hidden id
<input type="hidden" name="id" value="<?php echo "$id" ?>" />
in my form

I have my
$id = $_REQUEST['id'];
to get the id from the url

And on the update script i have
$navtype = $_GET['nav'];


And i have
WHERE id=$id
, but it keep updating just one record over and over,no matter which record i select.

When i make the hidden text, i see the right id
<input type="text" name="id" value="<?php echo "$id" ?>" />
.

I echo
"$sql";
, and the value is always one
UPDATE persoz SET lname='Daniel',fname='Ekow Gilbert Jr.',p_no='012012',todate='2011-01-01', WHERE id=1 


Is This A Good Question/Topic? 0
  • +

Replies To: update value is not changing

#2 Dormilich  Icon User is online

  • 痛覚残留
  • member icon

Reputation: 2146
  • View blog
  • Posts: 5,429
  • Joined: 08-June 10

Re: update value is not changing

Posted 03 February 2012 - 09:18 AM

View Postdecongh, on 03 February 2012 - 05:05 PM, said:

When i make the hidden text, i see the right id
<input type="text" name="id" value="<?php echo "$id" ?>" />
.

that is certainly not what you see in the HTML …

besides that the quotes around $id are superfluous.
Was This Post Helpful? 1
  • +
  • -

#3 codeprada  Icon User is offline

  • Changed Man With Different Priorities
  • member icon

Reputation: 876
  • View blog
  • Posts: 2,250
  • Joined: 15-February 11

Re: update value is not changing

Posted 03 February 2012 - 10:30 AM

Avoid using $_REQUEST. If your form data was posted then someone can overwrite it back adding their own variables to the URL. This depends on the order of your variables (variables_order) in php.ini.

I'm guessing your form is using the GET method. Either which way dump $_GET or $_POST depending on which one is relevant.

You should also sanitize user input before using it in a query. Have a look at prepared statements from either MySQLi or PDO.

This post has been edited by codeprada: 03 February 2012 - 01:45 PM

Was This Post Helpful? 1
  • +
  • -

#4 decongh  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 39
  • Joined: 31-December 11

Re: update value is not changing

Posted 03 February 2012 - 01:25 PM

are you saying i should use
$_GET
and not
$_POST
?
Was This Post Helpful? 0
  • +
  • -

#5 Dormilich  Icon User is online

  • 痛覚残留
  • member icon

Reputation: 2146
  • View blog
  • Posts: 5,429
  • Joined: 08-June 10

Re: update value is not changing

Posted 03 February 2012 - 01:36 PM

if you use the get method in your form, you should be using $_GET.
Was This Post Helpful? 1
  • +
  • -

#6 decongh  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 39
  • Joined: 31-December 11

Re: update value is not changing

Posted 04 February 2012 - 06:56 AM

my form uses post
Was This Post Helpful? 0
  • +
  • -

#7 Dormilich  Icon User is online

  • 痛覚残留
  • member icon

Reputation: 2146
  • View blog
  • Posts: 5,429
  • Joined: 08-June 10

Re: update value is not changing

Posted 04 February 2012 - 07:25 AM

get => $_GET, post => $_POST
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1