php/mysql update
Hi, I am trying to devolop a website with mysql database. I want to update member password , for which I have following code. its not working,please help.
<?php
// session begins
session_start(); // Use session variable on this page. This function must put on the top of page.
if(session_is_registered("user")){ // if session variable "user" exists.
echo $_SESSION['user'];
$currentuser=$_SESSION['user'];
$newpassword=$_POST['newpassword'];
$reenternewpassword=$_POST['reenternewpassword'];
//Database Information
$dbhost = "somehost";
$dbname = "database";
$dbuser = "user";
$dbpass = "pass";
//Connect to database
mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());
//check if passwords are same
if($newpassword!=$reenternewpassword){
unset($newpassword);
echo "<br />";
echo "<br />";
echo"passwords doesn'tmatch";
exit;
}
//Update Password
$query="UPDATE dcmembers SET password='$newpassword' WHERE user='".$_session['user']."'";
mysql_query($query) or die('Error, query failed');
mysql_close();
}
?>
<html>
<head>
<title>Dharwadcity/change password</title>
<link rel="stylesheet" type="text/css"
href="dc.css" >
</head>
<body class="pg1">
<table class="t1" valign=top>
<tr><td class="td1"><img src="dc1.gif">
</td></tr>
<tr>
<td class="td2">
<a class="a2" href="index.html"><span class="sp2"> Home</span></a>
<a class="a2"href="login.html"><span class="sp2"> Login</span></a>
<a class="a2"href="register.html"><span class="sp2"> Register</span></a>
<a class="a2"href="jobs.html"><span class="sp2"> Jobs</span></a>
<a class="a2"href="members.php"><span class="sp2"> Members</span></a>
<a class="a2"href="myaccount.php"><span class="sp2"> My Account</span></a>
<a class="a2"href="contactus.html"><span class="sp2"> Contact us</span></a>
</td>
</td>
</tr>
<tr>
<td>
<table class="t2">
<tr>
<td>
<table class="t3"border="1">
YYY
</table>
</td>
<td class="td4">
<p>your new password is <?php echo "$newpassword" ?> </p>
<p> Your user name is<?php echo $_session['user'] ?> </p>
<p> Continue to <a class="a2"href="myaccount.php"><span class="sp2"> My Account</span></a></P>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
Last edited by coolgirl; 2007-03-04 at 01:26 PM.
|