Código PHP:
<?php
include "conexion.php";
if (isset($_POST['submit'])) {
$username = $_COOKIE['loggedin'];
if (!isset($_COOKIE['loggedin'])) die("You are not logged in, <br><a href=login.php>Procced.</a>");
$cpass = $_POST["cpass"];
$pass = $_POST["pass"];
if ( $pass = $cpass) {
mysql_connect($server, $db_user, $db_pass) or die (mysql_error());
mysql_select_db($database)
or die ("Could not select database because ".mysql_error());
mysql_query("UPDATE $table SET password = '".$_POST['password']."'
WHERE username = '$username'");
}
else {
echo "no se cambia";
}
}
?>
Código PHP:
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post" >
<TABLE BORDER=0 align=center >
<TD>Old Password: </td>
<TD>
<?php
include "config.php";
mysql_connect($server, $db_user, $db_pass) or die (mysql_error());
$result = mysql_db_query($database, "select * from $table WHERE username = '$username'") or die (mysql_error());
while ($qry = mysql_fetch_array($result)) {
echo " <input type='text' name='cpass' size='24' />";
?><br>
<input type="text" name="pass" value="<?php echo "$qry[password]"; }?> "/>
</TD>
<TR><br>
<TD>New Password: </TD>
<TD>
<?php
echo " <input type='text' size='24' />";
?>
</TD>
</TR>
<TR><br>
<TD>Confirm New Password: </TD>
<TD>
<?php
echo " <input type='text' name='password' size='24' />";
?>
</TD>
</TR>
</TABLE>
<input name="submit" size="23" type="submit" value="Change Password">
</FORM>