我们的PHP课程,期末实训考核方案,要求有用PHP程序编写代码,要求也要有数据数据库搞,我油箱: 243486802@QQ.com 那些好心人帮忙下 ,在这里先谢谢你们,非常感激,不要求网上下载的,,,谢谢,越快越好
大概给你写吧,js验证部分就不给写了:updatepass.php
user表:
uid name pass
**********************************************
$session_statr();
< form action="updatepass.php" method="post">
原始密码:<input type="text" name="oldpass" >
新密码:<input type="text" name="newfpass" >
新密码:<input type="text" name="newlpass" >
<input type="hidden" name="useid" value="$_SESSION['uid']">
#用户id保存在session中吧,是用户登录进来的时候放进去的
</form>
<?php
$link = mysql_connect("localhost", "mysql_user","mysql_password")
or die("Could not connect: " . mysql_error());
if($_POST['oldpass'])
{
$selsql="select pass from user where uid='".$_POST['uid']."'";
$passres=mysql_fetch_array(mysql_query($selsql,$link));
if($passres[0]['pass']==$_POST['oldpass'])
{
if($_POST['newfpass']==$_POST['newlpass'])
{
$upsql="update user set pass='".$_POST['newfpass']."' where uid='".$_POST['id']."' ";
$result= mysql_query($upsql,$link);
if($result)
{
echo "修改成功~";
}
}else
{
echo "两次输入密码不一致";
}
}else
{
echo "原始密码错误";
}
}
?>
user表:
uid name pass
**********************************************
$session_statr();
< form action="updatepass.php" method="post">
原始密码:<input type="text" name="oldpass" >
新密码:<input type="text" name="newfpass" >
新密码:<input type="text" name="newlpass" >
<input type="hidden" name="useid" value="$_SESSION['uid']">
#用户id保存在session中吧,是用户登录进来的时候放进去的
</form>
<?php
$link = mysql_connect("localhost", "mysql_user","mysql_password")
or die("Could not connect: " . mysql_error());
if($_POST['oldpass'])
{
$selsql="select pass from user where uid='".$_POST['uid']."'";
$passres=mysql_fetch_array(mysql_query($selsql,$link));
if($passres[0]['pass']==$_POST['oldpass'])
{
if($_POST['newfpass']==$_POST['newlpass'])
{
$upsql="update user set pass='".$_POST['newfpass']."' where uid='".$_POST['id']."' ";
$result= mysql_query($upsql,$link);
if($result)
{
echo "修改成功~";
}
}else
{
echo "两次输入密码不一致";
}
}else
{
echo "原始密码错误";
}
}
?>
温馨提示:答案为网友推荐,仅供参考
第1个回答 2010-12-10
发个函数给你看