0

im using wampserver and i want to put password in the database. i check some video tutorias but when i try it it is not working in my case. can anybody please help me give some ideas. thanks

4
Contributors
14
Replies
60
Views
4 Years
Discussion Span
Last Post by lloydsbackyard
0

Password of what? Of a database user? You can use phpMyAdmin. Don't forget to flush priviliges or restart wamp.

0

You should use POST method for that:

<form method="post" action="process.php">
    <input type="password" name="pass">
    <input type="submit" name="submit" value="Submit password">
</form>

And this is an example of a process.php

<?php
// check if password is set and matches criteria
if(isset($_POST['pass']) && $_POST['pass'] != '') {

    // escape the value to avoid most sql injection attacks
    // use your database driver's function
    // I am using mysqli in this example
    $password = mysqli_real_escape_string($_POST['pass']);

    // hash the pasword using a function of your choice
    $hashedPassword = ...

    // store the hashed password
    $query = "INSERT INTO users (hashedpassword) VALUES ($hashedPassword)";
    ...

    // let the user know
    echo "The password has been stored.";

} else {
    // if password is not set or does not match the criteria notify the user.
    die("Please go back and enter correct password");
}
?>

This is just a basic example. Many things can be improved.

Edited by broj1

0

like this one..the there is no password.. $server='localhost'; $user='root';$password='';$database='nohs';$con=mysql_connect ($server,$user,$password);$db = mysql_select_db($database);if (!$con || !$db){die ("Server down be back later!);}but if i place a password on it like $password='12345' how do i do place 12345 for the database like nohs in phpmyadmin... or can i put a password to the database nohs like 12345?

0

i already created it.my host name is nohs....so how do i use it? in the url do i have to type nohs instead of localhost?

0

You should have created/edited the host name for the user as localhost to use on the same computer, or % to be able to connect from any computer. If MySQL cannot resolve nohs as a hostname, it won't work.

0

thanks.i think i need to read more and try it here ..do u have any other links about this?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.