Jump to content

Check out our Community Blogs

Register and join over 40,000 other developers!

Recent Topics

Recent Status Updates

View All Updates

- - - - -

Password variable not working with md5


  • Please log in to reply
2 replies to this topic

#1 alex1


    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 97 posts

Posted 23 May 2012 - 06:03 AM

I have this code:


//Connect To Database

$connect = mysql_connect("localhost","parkingc_php","123");
if (!$connect)
die("MySQL could not connect!");

$DB = mysql_select_db('parkingc_php');

die("My SQL could not select Database!");

//Declare Variables

$name = $_POST['name'];
$email = $_POST['email'];
$email1 = "@";
$email_Check = strpos($email,$email1);
$password = $_POST['password'];
$passencr = md5($password);
$AFM = $_POST['AFM'];
$ADT = $_POST['ADT'];
$tel = $_POST['tel'];

//Check To See If some of the Information Is Correct

if($name == "")
die("Opps! You don't enter a username!");

if($password == "")
die("Opps! You didn't enter one of your passwords!");

if($Email_Check === false)
die("Opps! That's not an email!");

// Insert Information Into MySQL Database

if(!mysql_query("INSERT INTO Customer (Name, Surname, ADT, AFM, Tel, email, password,IP)
VALUES ('$name', '$surname', '$ADT', '$AFM', '$tel', '$email', '$passencr', '$email1')"))


My problem is regarding - "$passencr = md5($password);"

When I'm running the query with the normal password variable everything is ok,but when I cange it to "$passencr" It can't run... I'm 100% sure that it's a super small problem,but my main language is not php,but I would like to learn it also. :)
Please don't mind the IP - I have not made the script getting it yet.
Any help is highly appreciated!
  • 0

#2 gregwarner


    Obi Wan of Programming

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1586 posts
  • Location:Arkansas
  • Programming Language:C, Java, C++, C#, PHP, Transact-SQL

Posted 23 May 2012 - 08:36 AM

It looks fine to me. Can you please elaborate on "when I cange it to "$passencr" It can't run..."
  • 0

Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid

#3 papabear


    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 472 posts
  • Location:DarkSide

Posted 23 May 2012 - 05:39 PM

please kindly check the field type on where you are storing the $passencr it might be a incompatible type error.
Is this giving you some sort of error when inserting? also you might want to take a look at this tutorial for hashing/encrypting password in PHP5

Creating A Simple Yet Secured Login/registration With Php5

  • 0
Life has no CTRL+Z
Never Forget To HIT "LIKE" If I Helped

Also tagged with one or more of these keywords: md5

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download