Hi all,
I have a function called newuser, the problem is that when the data gets inserted from a join form it gets posted into the wrong tables. My first impression is that the form is posting the data into the fields by order rather than associating the $_POST variable to the relevant part of the database.
here is the code:
join form
newuser($strUsername = isset($_POST['username']) ? $_POST['username'] : "",
$strPassword = isset($_POST['password']) ? $_POST['password'] : "",
$strfirst_name = isset($_POST['first_name']) ? $_POST['first_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'] : "",
$stremail_address = isset($_POST['email_address']) ? $_POST['email_address'] : "",
$stredbday = isset($_POST['dbday']) ? $_POST['dbday'] : "",
$stredbmonth = isset($_POST['dbmonth']) ? $_POST['dbmonth'] : "",
$stredbyear = isset($_POST['dbyear']) ? $_POST['dbyear'] : "",
$strwdday = isset($_POST['wdday']) ? $_POST['wdday'] : "",
$strwdmonth = isset($_POST['wdmonth']) ? $_POST['wdmonth'] : "",
$strwdyear = isset($_POST['wdyear']) ? $_POST['wdyear'] : "",
$strterms = isset($_POST['terms']) ? $_POST['terms'] : "");
and then we have a functions file which has the newuser function like so:
function newUser($username, $password, $first_name, $maiden_name, $last_name, $address_line1, $address_line2, $town, $county, $postcode, $daytime_phone, $mobile_phone, $evening_phone, $email_address, $dbday, $dbmonth, $dbyear, $wdday, $wdmonth, $wdyear, $terms) {
// $terms, $mobile_phone) {
/*
Creating a New User Record in the DB:
In this function we create a new user record in the db.
We first build a query and save it into the $query variable.
The query statement says:
//*( '$terms', '$mobile_phone')
'Insert the value of $login and $password into the 'login'
and 'password' columns in the 'users' table' (line 77)
*/
global $link;
$query="INSERT INTO users (username, password, first_name, maiden_name, last_name, address_line1, address_line2, town, county, postcode, daytime_phone, mobile_phone, evening_phone, email_address, dbday, dbmonth, dbyear, wdday, wdmonth, wdyear, terms)
VALUES('$username', '$password', '$first_name', '$maiden_name', '$last_name', '$address_line1', '$address_line2', '$town', '$county', '$postcode', '$daytime_phone', '$mobile_phone', '$evening_phone', '$email_address', '$dbday', '$dbmonth', '$dbyear', '$wdday', '$wdmonth', '$wdyear', '$terms')";
$result=mysql_query($query, $link) or die("Died inserting login info into db. Error returned if any: ".mysql_error());
return true;
} // end func newUser($username, $pass)
I end up getting a phone number posted into postcode, the date of birth year posted in the day they were born, its all screwed!
Any ideas?
Thanks,
G