Hi there,
I tried a profile update form, but am kind of stuck with it, it is not displaying anything at all on that page, perhaps you can help me? ๐
<?PHP
//Get Config
include("config.inc.php");
//Get Settings
include("" . $absolute_path . "/config/settings.inc.php");
//Get Level1 Check
include("" . $absolute_path . "/members/level1_check.php");
//Get Header
include("" . $absolute_path . "/elements/header.php");
session_start();
echo $_SESSION['username'];
$getdata = "SELECT * FROM login_table where user_id ='" . $_SESSION['username'] . "';";
$querygetdata = mysql_query($getdata);
while($row = mysql_fetch_object($querygetdata)) {
//Shortening
$userid = $row->user_name;
$fname = $row->fname;
$lname = $row->lname;
$email = $row->user_email;
$adress = $row->user_adress;
$adress2 = $row->user_adress2;
$zipcode = $row->user_zipcode;
$city = $row->user_city;
$hphone = $row->user_hphone;
$mphone = $row->user_mphone;
$password = $row->user_password;
}
if(isset($_POST['submit'])) {
if($password == $_POST['cpassword'] {
if(isset($_POST['npassword'])) {
if($_POST['npassword'] == $_POST['nvpassword']) {
$putdata = "Update login_table set user_name='" . $_POST['userid'] . "', user_pass='" . $_POST['npassword'] . "', user_email='" . $_POST['email'] . "', user_fname='" . $_POST['fname'] . "', user_lname='" . $_POST['lname'] . "', user_adress='" . $_POST['adress'] . "', user_adress2='" . $_POST['adress2'] . "', user_zipcode='" . $_POST['zipcode'] . "', user_city='" . $_POST['city'] . "', user_hphone='" . $_POST['hphone'] . "', user_mphone='" . $_POST['mphone'] . "' where userid='" . $_SESSION['username'] . "';";
echo "<font color=\"green\"><center>Your Profile has been updated.</center></font>";
} else {
echo "<font color=\"red\"><center>ERROR: The passwords did not match!</font></center>";
}
elseif($password == $_POST['cpassword']) {
$putdata = "Update login_table set user_name='" . $_POST['userid'] . "', user_email='" . $_POST['email'] . "', user_fname='" . $_POST['fname'] . "', user_lname='" . $_POST['lname'] . "', user_adress='" . $_POST['adress'] . "', user_adress2='" . $_POST['adress2'] . "', user_zipcode='" . $_POST['zipcode'] . "', user_city='" . $_POST['city'] . "', user_hphone='" . $_POST['hphone'] . "', user_mphone='" . $_POST['mphone'] . "' where userid='" . $_SESSION['username'] . "';";
echo "<font color=\"green\"><center>Your Profile has been updated.</center></font>";
}
} else {
echo "<font color=\"red\"><center>ERROR: The password you have entered is not your correct password!</center></font>";
}
}
?>
<form name="Profileform" method="post" action="register.php">
<table align="center" border="0">
<tr>
<td>Nickname:</td>
<td><input name="userid" type="text" id="userid" width="200" value="<?PHP echo $userid; ?>" /></td>
</tr>
<tr>
<td>First name:</td>
<td><input name="fname" type="text" id="fname" width="250" value="<?PHP echo $fname; ?>" /></td>
</tr>
<tr>
<td>Last name:</td>
<td><input name="lname" type="text" id="lname" width="250" value="<?PHP echo $lname; ?>" /></td>
</tr>
<tr>
<td>Adress Line 1:</td>
<td><input name="ad1" type="text" id="ad1" width="250" value="<?PHP echo $adress; ?>" /></td>
</tr>
<tr>
<td>Adress Line 2:</td>
<td><input name="ad2" type="text" id"ad2" width="250" value="<?PHP echo $adress1; ?>" /></td>
</tr>
<tr>
<td>Zip Code:</td>
<td><input name="zipcode" type="text" id="zipcode" width="50" value="<?PHP echo $zipcode; ?>" /></td>
</tr>
<tr>
<td>City:</td>
<td><input name="city" type="text" id="city" width="100" value="<?PHP echo $city; ?>" /></td>
</tr>
<tr>
<td>Home Phone:</td>
<td><input name="hphone" type="text" id="hphone" width="100" value="<?PHP echo $hphone; ?>" /></td>
</tr>
<tr>
<td>Mobile Phone:</td>
<td><input name="mphone" type="text" id="mphone" width="100" value="<?PHP echo $mphone; ?>" /></td>
</tr>
<tr>
<td>Email:</td>
<td><input name="pemail" type="text" id="pemail" width="200" value="<?PHP echo $email; ?>" /></td>
</tr>
</table>
<table border="0" align="center">
<center>
To apply your changes please enter your current password:<br>
</center>
<tr>
<td>Current password:</td>
<td><input name="cpassword" type="text" id="cpassword" width="200"><br /><br /></td>
</tr>
<center>
If you would like to change your current password please enter your new one underneath:<br>
</center>
<tr>
<td>New password:</td>
<td><input name="npassword" type="password" id="npassword" width="200"></td>
</tr>
<tr>
<td>Verify new password:</td>
<td><input name="nvpassword" type="password" id="nvpassword" width="200"></td>
</tr>
</table>
<table border="0" align="center">
<tr>
<td><input name="reset" type="reset" value="Reset Form"></td>
<td><input name="submit" type="submit" value="Update ยป"></td>
</tr>
</table>
</form>
<?PHP
//Get Footer
include("" . $absolute_path . "/elements/footer.php");
?>
I'm a pretty big n00b so there are probably tons of errors in there but it would be kind if you could point me in the right direction.
Best regards and thanks in advance,
Max