Hi,
As an update I have now tried putting the function (or rather the query into the updatedetails page itself, removing the function until I get this working). However, upon loading the following page it is blank, if I run a debug it seems that all that is happening is that the update query is running..
Just to re-iterate all i want to do is update a user's details into the database with some field validation:
Code: Select all
$id = $_SESSION['username'];
$query = "select * from users where username='$id'";
//now we pass the query to the database
$result=mysql_query($query) or die("Could not get data.".mysql_error());
//get the first (and only) row from the result
$row = mysql_fetch_array($result, MYSQL_ASSOC);
//now finally create variables with data we have got which will be used later
//we will set the value attribute of the appropriate form element to the value from the database
$username=$row['username'];
$password=$row['password'];
$first_name=$row['first_name'];
$maiden_name=$row['maiden_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'];
$evening_phone=$row['evening_phone'];
if(isset($_POST["submit"])){
/*field_validator("username", $_POST["username"], "alphanumeric", 4, 15);
field_validator("password", $_POST["password"], "string", 4, 10);
field_validator("confirmation password", $_POST["password2"], "string", 4, 10);*/
field_validator("first_name", $_POST["first_name"], "alphanumeric", 1, 15);
field_validator("maiden_name", $_POST["maiden_name"], "alphanumeric", 1, 15);
field_validator("last_name", $_POST["last_name"], "alphanumeric", 1, 15);
field_validator("address_line1", $_POST["address_line1"], "alphanumeric", 4, 15);
field_validator("address_line2", $_POST["address_line2"], "alphanumeric", 4, 15);
field_validator("town", $_POST["town"], "alphanumeric", 4, 15);
field_validator("postcode", $_POST["postcode"], "alphanumeric", 4, 9);
field_validator("daytime_phone", $_POST["daytime_phone"], "number", 1, 11);
field_validator("mobile_phone", $_POST["mobile_phone"], "number", 1, 11);
field_validator("evening_phone", $_POST["evening_phone"], "number", 1, 11);
}
/*if(empty($messages)) {
// registration ok, get user id and update db with new info:
updateuser(*/$strUsername = isset($_POST['username']) ? $_POST['username'] : "";
$strPassword = isset($_POST['password']) ? $_POST['password'] : "";
$strfirst_name = isset($_POST['first_name']) ? $_POST['first_name'] : "";
$strmaiden_name = isset($_POST['maiden_name']) ? $_POST['maiden_name'] : "";
$strlast_name = isset($_POST['last_name']) ? $_POST['last_name'] : "";
$straddress_line1 = isset($_POST['address_line1']) ? $_POST['address_line1'] : "";
$straddress_line2 = isset($_POST['address_line2']) ? $_POST['address_line2'] : "";
$strtown = isset($_POST['town']) ? $_POST['town'] : "";
$strcounty = isset($_POST['county']) ? $_POST['county'] : "";
$strpostcode = isset($_POST['postcode']) ? $_POST['postcode'] : "";
$strdaytime_phone = isset($_POST['daytime_phone']) ? $_POST['daytime_phone'] : "";
$strmobile_phone = isset($_POST['mobile_phone']) ? $_POST['mobile_phone'] : "";
$strevening_phone = isset($_POST['evening_phone']) ? $_POST['evening_phone'] : "";
$query = "UPDATE `users` SET `first_name`='$first_name', `maiden_name`='$maiden_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', `evening_phone`='$evening_phone'";
$result=mysql_query($query, $link) or die("Died inserting login info into db. Error returned if any: ".mysql_error());
return true;