How to store password in MYSQL ?

i created the new page,
index.html

<form action="calc.php" method="POST">
Username: <input type="text" name="username">
Password: <input type="password" name="password">
<input type="submit" name="submit" value="Submit">
</form>

and clac.php,

<?php
$username = $_POST['username'];
$pass = $_POST['password'];
if ($username == "a" && $pass =="abc")
/* here i set the password to "abc" */
	{
	echo 'Welcome to the Page';
	echo '<a href="cp.html">Change Pass</a>';
	}
else
	echo "Wrong";
	?>

and here is cp.html,

<form method="POST">
<input type="password" name="newpassword">
<input type="submit" name="submit">
</form>

i want to store that password in mysql and when a users clicks on change password and entered new password then the old password shoukld be replace by old password in mysql and it automatically set to the default value of password. , how can i do this ?
i am newbie in php and don't know how to store something in MYSQL

Hi Xufyan,

It looks like you have a lot to learn but have no fear i believe this resource will be fantastic for you to get to grips with what you want to do, and will also help you improve your login/registration files. Go to this link http://www.youtube.com/watch?v=h1Cv3zpWXj4

Enjoy and happy coding!

how can i do this without using Sessions and only MYSQL??

i dont know your answer

but you use sha1algorithm to incrept the password

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.