PHP password hash script

Links for php scripts

Moderators: macek, egami, gesf

ms4sman
New php-forum User
New php-forum User
Posts: 8
Joined: Sat Sep 08, 2012 7:24 pm

PHP password hash script

Postby ms4sman » Sat Sep 08, 2012 7:31 pm

Hello everyone! I am pretty new to PHP so please bear with me. I am trying to write a super simple password hashing script, all it needs to do is hash the password in the variable and then print it on screen. This is what I have come up with so far:

Code: Select all

<?php
$hash = md5("Bananas")
echo $hash
?>

But for some reason it wont work when I run it. I am using XAMPP for this and I have had a similar script work at one point but I deleted it and can't remember the code I had entered. Does anyone know the problem? It's probably a very obvious answer but as I said I am very new. Thanks!

User avatar
freshnet
php-forum Active User
php-forum Active User
Posts: 285
Joined: Tue Feb 22, 2011 8:19 am
Location: Canada

Re: PHP password hash script

Postby freshnet » Sun Sep 09, 2012 4:15 am

You don't have any ';' at the end of your lines... when you say it doesn't work, do you get no output or do you get an error message?

ms4sman
New php-forum User
New php-forum User
Posts: 8
Joined: Sat Sep 08, 2012 7:24 pm

Re: PHP password hash script

Postby ms4sman » Sun Sep 09, 2012 5:42 am

Thanks for replying! I think i did have ; at the ends at one point but i dont think it worked. I will try it again though just to be sure. And yes, there is just no output. I dont understand the problem, as I had a very similar script working at one point!

User avatar
freshnet
php-forum Active User
php-forum Active User
Posts: 285
Joined: Tue Feb 22, 2011 8:19 am
Location: Canada

Re: PHP password hash script

Postby freshnet » Sun Sep 09, 2012 3:17 pm

Also make sure php is working. Echo some text back to your screen and make sure that works.

ms4sman
New php-forum User
New php-forum User
Posts: 8
Joined: Sat Sep 08, 2012 7:24 pm

Re: PHP password hash script

Postby ms4sman » Thu Sep 13, 2012 7:33 pm

I don't know what I am doing wrong, but now I can't even get it to echo any text! PHP is running through XAMPP and everything!
Using this as my test code (got it from the internet):

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"><title>PHP Password Hash Script</title>

</head><body>
<?php
echo "Hello World";

echo "This spans
multiple lines. The newlines will be
output as well";

echo "This spans\nmultiple lines. The newlines will be\noutput as well.";

echo "Escaping characters is done \"Like this\".";

// You can use variables inside of an echo statement
$foo = "foobar";
$bar = "barbaz";

echo "foo is $foo"; // foo is foobar

// You can also use arrays
$baz = array("value" => "foo");

echo "this is {$baz['value']} !"; // this is foo !

// Using single quotes will print the variable name, not the value
echo 'foo is $foo'; // foo is $foo

// If you are not using any other characters, you can just echo variables
echo $foo;          // foobar
echo $foo,$bar;     // foobarbarbaz

// Some people prefer passing multiple parameters to echo over concatenation.
echo 'This ', 'string ', 'was ', 'made ', 'with multiple parameters.', chr(10);
echo 'This ' . 'string ' . 'was ' . 'made ' . 'with concatenation.' . "\n";

echo <<<END
This uses the "here document" syntax to output
multiple lines with $variable interpolation. Note
that the here document terminator must appear on a
line with just a semicolon. no extra whitespace!
END;

// Because echo does not behave like a function, the following code is invalid.
($some_var) ? echo 'true' : echo 'false';

// However, the following examples will work:
($some_var) ? print 'true' : print 'false'; // print is also a construct, but
                                            // it behaves like a function, so
                                            // it may be used in this context.
echo $some_var ? 'true': 'false'; // changing the statement around
?>
</body></html>


Return to “PHP Scripts”

Who is online

Users browsing this forum: Bing [Bot] and 1 guest