genista Posted August 17, 2006 Share Posted August 17, 2006 Hi all,I have the following script for a user to update their details:[code=php:0]$id = $_SESSION['username']; $query = "select * from suppliers where username='$id'"; //now we pass the query to the database $result=mysql_query($query, $link) or die("MySQL query $query failed. Error if any: ".mysql_error()); //get the first (and only) row from the result $row = mysql_fetch_array($result, MYSQL_ASSOC); if(empty($messages)) { updateuser ($username=$row['username'], $password=$row['password'], $first_name=$row['first_name'], $last_name=$row['last_name'], $address_line1=$row['address_line1'], $address_line2=$row['address_line2'], $town=$row['town'], $county=$row['county'], $postcode=$row['postcode'], $daytime_phone=$row['daytime_phone'], $mobile_phone=$row['mobile_phone'], $email_address=$row['email_address']); } ?> [/code]I then have html below that:[code=php:0]<form name="form1" method="post" action="<?=$_SERVER["PHP_SELF"]?>" onSubmit="return check()"> <p>Username: <?php echo $username; ?> </p> <p>First Name: <input type="text" name="first_name" value="<?php echo $first_name; ?>"> </p> <p>Last Name: <input type="text" name="last_name" size="10" value="<?php echo $last_name; ?>"> </p> <p>Address Line 1: <input type="text" name="address_line1" size="10" value="<?php echo $address_line1; ?>"> </p> <p>Address Line 2: <input type="text" name="address_line2" size="10" value="<?php echo $address_line2; ?>"> </p> <p>Town: <input type="text" name="town" size="10" value="<?php echo $town; ?>"> etc, etc [/code]The problem is that the html is not being populated with the data and is not posting either, I have simply copied the function from a newuser function when a user signs up, the function as it is in the functions file looks like so:[code=php:0]function updateuser ($password, $username, $first_name, $last_name, $address_line1, $address_line2, $town, $county, $postcode, $daytime_phone, $mobile_phone, $email_address) { global $link; $query="UPDATE suppliers SET password='$password', username='$username', first_name='$first_name', last_name='$last_name', address_line1='$address_line1', address_line2='$address_line2', town='$town' , county='$county', postcode='$postcode', daytime_phone='$daytime_phone', mobile_phone='$mobile_phone', email_address='$email_address' where username= '$username'"; $result=mysql_query($query, $link) or die("Died inserting login info into db. Error returned if any: ".mysql_error()); return true; } // [/code]Any help would be much appreciated as I am really stuck.Thanks,G Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted August 17, 2006 Share Posted August 17, 2006 is $messages empty? if not then yoru form won't be popluated Quote Link to comment Share on other sites More sharing options...
genista Posted August 17, 2006 Author Share Posted August 17, 2006 Not sure if this is what you mean, but I just added:[code=php:0]<?php//Check if $message is set, and output it if it is:if(!empty($messages)){ displayErrors($messages);}?>[/code]Still no joy though Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.