User Cp N Profile.php With Password Change

Started on the old forum in January 2008 · view the original in the archive · old links redirect here

4 replies · 3,425 views · started 18 years ago · 1 min read

2 participants
rukiya Lead · 569 posts #2

to change passoword

<html>
<head>
<title>Change Password</title>
</head>
<body>

<?php
if(isset($_POST['update']))
{
$dbhost = '';
$dbuser = '';
$dbpass = '';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
  die('Could not connect: ' . mysql_error());
}

$id = $_POST['emp_id'];
$pass = $_POST['pass'];

$sql = "UPDATE user ".
       "SET pass = $pass ".
       "WHERE id = id";

mysql_select_db('test_db');
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
  die('Could not update data: ' . mysql_error());
}
echo "Updated data successfully\n";
mysql_close($conn);
}
else
{
?>
<form method="post" action="<?php $_PHP_SELF ?>">
<table width="400" border="0" cellspacing="1" cellpadding="2">
<tr>
<td width="100">User ID</td>
<td><input name="emp_id" type="text" id="emp_id"></td>
</tr>
<tr>
<td width="100">Password</td>
<td><input name="emp_salary" type="text" id="emp_salary"></td>
</tr>
<tr>
<td width="100"> </td>
<td> </td>
</tr>
<tr>
<td width="100"> </td>
<td>
<input name="update" type="submit" id="update" value="Update">
</td>
</tr>
</table>
</form>
<?php
}
?>
</body>
</html>

SQL table

CREATE TABLE `user` (
  `id` int(100) NOT NULL auto_increment,
  `name` varchar(30) NOT NULL default '',
  `pass` varchar(60) NOT NULL default '',
 PRIMARY KEY  (`id`),
  UNIQUE KEY `name` (`name`)
) ENGINE=MyISAM  AUTO_INCREMENT=1;
rukiya Lead · 569 posts #3

profile.php

<?php
$dbhost = '';
$dbuser = '';
$dbpass = '';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
  die('Could not connect: ' . mysql_error());
}
$sql = 'SELECT id, name FROM user';

mysql_select_db('test_db');
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
  die('Could not get data: ' . mysql_error());
}
while($row = mysql_fetch_assoc($retval))
{
    echo "USER ID :{$row['emp_id']}  
 ".
         "USER NAME : {$row['emp_name']} 
 ".
         "--------------------------------
";
} 

mysql_close($conn);
?>

and for USER CP

echo "
[b]---General Options---[/b]
";
  echo "<a href=\"profile.php?id=$id\">View  Profile</a>
";
  echo "<a href=\"password.php?id=$id\">Change Password</a>
";
cortez Junior · 27 posts #4

lol i nedd chatzone edit profile scripts

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close