Sponsored by NuSphere - PHP Software for PHP Application Developers - On Sale This Week for $100



Go Back   PHP-Editors > Programming Help > PHP Programming Help

PHP Programming Help Post any question relating to PHP Programming here and hopefully someone can help.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 2007-03-04, 01:11 PM
Junior Member
 
Join Date: Mar 2007
Posts: 4
coolgirl is on a distinguished road
Post 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">&nbsp;&nbsp;&nbsp;Home</span></a>
<a class="a2"href="login.html"><span class="sp2">&nbsp;&nbsp;&nbsp;Login</span></a>
<a class="a2"href="register.html"><span class="sp2">&nbsp;&nbsp;&nbsp;Register</span></a>
<a class="a2"href="jobs.html"><span class="sp2">&nbsp;&nbsp;&nbsp;Jobs</span></a>
<a class="a2"href="members.php"><span class="sp2">&nbsp;&nbsp;&nbsp;Members</span></a>
<a class="a2"href="myaccount.php"><span class="sp2">&nbsp;&nbsp;&nbsp;My Account</span></a>
<a class="a2"href="contactus.html"><span class="sp2">&nbsp;&nbsp;&nbsp;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">&nbsp;&nbsp;&nbsp;My Account</span></a></P>



</td>

</tr>
</table>

</td>
</tr>

</table>
</body>
</html>

Last edited by coolgirl; 2007-03-04 at 01:26 PM.
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 2007-03-05, 10:57 PM
Xnuiem's Avatar
Senior Member
 
Join Date: May 2004
Location: DFW, Texas
Posts: 1,104
Xnuiem will become famous soon enough
Send a message via Yahoo to Xnuiem
Default

its $_SESSION not $_session.
__________________
I rarely give code examples.
No, I have never used IIS or Windows of any kind as a web server. Get a real OS!
Please don't PM me, I won't respond.
Reply With Quote
  #3 (permalink)  
Old 2007-03-08, 02:45 PM
Junior Member
 
Join Date: Mar 2007
Posts: 4
coolgirl is on a distinguished road
Default

Hi,thanks for reply. I will change $_SESSION. but is update code is correct?if so why isn't it working?
Reply With Quote
  #4 (permalink)  
Old 2007-03-08, 02:52 PM
Junior Member
 
Join Date: Mar 2007
Posts: 4
coolgirl is on a distinguished road
Default

Hi Xnuiem
I changed it to $_SESSION, it worked, thanku verymuch.
Reply With Quote
Must read Review for Serious PHP Developers


NuSphere PhpED 5.5 : The Staff of php-editors.com recently spent a few days working with NuSphere PhpED 5.5 (a popular PHP IDE) and NuCoder 2.0 (a PHP Encoding Utility), read up on all the details.

Sponsored Links
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 10:43 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.