madhungarian Posted May 19, 2003 Posted May 19, 2003 Was trying to take my own current member db and integrate with OS Commerce. Problem I am running into is encryption of the passwords. I have created a generic page where new members to my business can take advantage of a coupon for in store discount and I would like this customer information to be transferred into the Os Commerce app in order to reduce duplications. Problem that I am having is getting the OS Commerce Password Encryption function to work in the coupon page. I have the function in the head on the coupon page and call the function onChange with the text input box. The form submit goes to a seperate handler that sends out an email, inputs the data into the appropirate db & tables, and then creates the coupon for individuals to print & bring into the store. Appropriate code is listed below. Any insight would be greatly appreciated. TIA. <? // This function makes a new password from a plaintext password. function tep_encrypt_password(plain) { password = ''; for ($i=0; $i<10; $i++) { password .= tep_rand(); } $salt = substr(md5($password), 0, 2); password = md5($salt . plain) . ':' . $salt; return password; } ?> //Password Input Row in Form <td width="14%"><input type="text" name="plain" onChange="tep_encrypt_password(plain);" size="15"></td> //Form handler page that is called on submit that inputs into DB $query = "INSERT INTO customers (customers_gender,customers_firstname,customers_lastname,customers_dob,customers _email_address,customers_telephone, customers_password, customers_newsletter) VALUES ('$gender','$firstname','$lastname','$dob','$email_address','$telephone', '$password','$newsletter')";
Silencer Posted May 19, 2003 Posted May 19, 2003 You trying use PHP function in JavaScript code :) <td width="14%"><input type="text" name="plain" onChange="tep_encrypt_password(plain);" size="15"></td> You need accept user input as is and encrypt on server. There is always more than one way to do it. And always Keep It Simple, Stupid.
madhungarian Posted May 19, 2003 Author Posted May 19, 2003 Thanks for the info. However, please bare with me as I'm a novice with PHP & MYSQL. I moved my attempt at encrypting the password into the file I have for entering into the database and removed the reference to javascript event handler on the input page, but I am still experiencing problems. Now instead of my previous problem of entering a non-encrypted password into the database. No value is being entered. Any insight would be helpful. TIA and everyone's patience with my learning curve.
Silencer Posted May 19, 2003 Posted May 19, 2003 Show me code that accept user input from form. There is always more than one way to do it. And always Keep It Simple, Stupid.
madhungarian Posted May 21, 2003 Author Posted May 21, 2003 Once I put down the Bass Ales I was able to see that I had stupidly left out defining the encryption password function. Took care of that and then ran into the problem of having to ensure that both the customers and address_book tables were linked by common customer_id field. Got that hammered away and now I'm golden. A BIG SHOUT OUT to Silencer for the help, as most people dont even take the time to try and shed a little light. Cheers
Recommended Posts
Archived
This topic is now archived and is closed to further replies.