homepage Welcome to WebmasterWorld Guest from 54.161.214.221
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
having trouble updating data on submit
victorontop




msg:4602343
 7:10 am on Aug 16, 2013 (gmt 0)

i am having a little difficulty in displaying my id info on my update page. i have two entries 6 and 7 if i click update on id 6 , it will show on my update page, but when i click on submit, it wont update and also if i click update on id 7, on the address bar, it will indicate that the id =7 but it will still show id 6 infos.

here is my display code that display data on my update page

<?ph
include ('config.php');
// Retrieve data from database
$sql="SELECT * FROM $tbl_name ";
$result=mysql_query($sql);
$row=mysql_fetch_array($result);
?>

secondly if i change data on my update page and click on submit the change wont reflect on my view page. and the delete function i dont even know where to start from.

<?php
include('config.php');
//This is the directory where images will be saved
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
$address=$_POST['address'];
$nationality=$_POST['nationality'];
$accountnumber=$_POST['account'];
$accounttype=$_POST['accounttype'];
$balance=$_POST['balance'];
$username=$_POST['username'];
$password=$_POST['password'];
$id=$_POST['id'];
// update data in mysql database
$sql="UPDATE $tbl_name SET firstname='$firstname', lastname='$lastname', address='$address', nationality='$nationality',accountnumber='$account',accounttype='$accounttype',balance='$balance',username='$username',password='$password'
WHERE id='$id'";
$result=mysql_query($sql);

header ("Location: details.php");

?>

 

coopster




msg:4603672
 9:58 pm on Aug 20, 2013 (gmt 0)

Welcome to WebmasterWorld, victorontop.

Make sure that your $_POST indexes match the form field names in your HTML. Also, you should never trust user-supplied input like that in your queries, it is a huge security issue. You need to at the very minimum escape that user-supplied data using mysql_real_escape_string() or some other method of scrubbing the input.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved