PDA

View Full Version : PHP 'UPDATE' help


Dayo
01-22-2009, 12:48 PM
i need help with this code where does it go wrong?! i cant see atm im using notepad, dreamweaver cs4 is installing now and it taked bloody ages

who ever helps me sort this out gets all my credits for the next week :D*

<?php //Require Database Connection

require_once('../config.php');

//New Login Details
$newuser = mysql_real_escape_string($_POST['newusername']);
$newpass = mysql_real_escape_string($_POST['newpassword']);
$confirmpass = mysql_real_escape_string($_POST['confirmpassword']);

//first Name
$firstname = mysql_real_escape_string($_POST['Fname']);

//last name
$lastname = mysql_real_escape_string($_POST['Lname']);

//User verification

if($newuser == '') {
$errmsg_arr[] = 'please enter your first';
$errflag = true;
}

if($firstname == '') {
$errmsg_arr[] = 'Please enter your last';
$errflag = true;
}

if($lastname == '') {
$errmsg_arr[] = 'Please enter your last name';
$errflag = true;
}

if($newpass == '') {
$errmsg_arr[] = 'Please enter a new password';
$errflag = true;
}

if($confirmpass == '') {
$errmsg_arr[] = 'Please confirm your password';
$errflag = true;
}

if( strcmp($password, $cpassword) != 0 ) {
$errmsg_arr[] = 'Passwords do not match';
$errflag = true;
}

//If there are input validations, redirect back to the profile

if($errflag) {
session_start();
$_SESSION['ERRMSG_ARR'] = $errmsg_arr;
session_write_close();
header("location: profile.php");
exit();
}
$userid = "SELECT member_id FROM members WHERE firstname='$firstname' AND lastname='$lastname'"
$qry = "UPDATE members SET passwd='$confirmpass' login = '$newuser' WHERE member_id = '$userid' LIMIT 1";
$result=mysql_query($qry);

//Check whether the query was successful or not
if($result) {
mysql_query($qry) or die (mysql_error());
header("location: update-success.php");
exit();
}else {
header("location: profile.php");
exit();
}
else {
die("Query failed");
}
?>

EDIT: added php notes in the script

*script has to work :]

frecklemagic
01-22-2009, 12:51 PM
wait what please be specificer.

Dayo
01-22-2009, 01:04 PM
right this is an update profile script where the user enters in there name they then enter a new username and new password. i just cant seam to get it working :@ any help would be great you watch its simple like an extra { ' " :P


back in 3 or so hours cya