Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Help me. Check php code. Need SHA1.
Old 08-07-2008, 11:32 PM Help me. Check php code. Need SHA1.
Novice Talker

Posts: 8
Name: dummie dude
Trades: 0
Okay- this script was coded for PHP4. I'm now on PHP 5.

I've searched and read many different tutorials, forums, blogs, etc about php security (password, addslashes,....) and am very confused because many people say this, others say no, this. Some say magic quotes must be ON, others say OFF. Good, bad, good, bad... blah blah blah.

I'M LOST.

Many examples I have seen is like this:
PHP Code:
$username $_POST['username'];
$password sha1($_POST['password']);

$DB->query('INSERT INTO users (username, password) VALUES (?, ?)', array($username$password)); 
Below is the signup/register php code. As you can see, nothing below have $_POST or like the way many examples have shown.

So what need to be changed? Am I doing it wrong? To be honest, I don't know what is right or wrong since I'm confused thanks to many people.
PHP Code:
<?php
  $newusername 
preg_replace("/[^a-zA-Z0-9]/"""$username);
  
$newegold preg_replace("/[^0-9]/"""$egold);

 if (isset(
$signup)){
  
$err "";
  if ((!
$username) or (!$password) or (!$email)) { $err.="All fields are required!"
  } else {
    if (
strlen($username)<4) { $err.="4+ characters required!<br />"; }
    if (
strlen($password)<6) { $err.="6+ characters required!<br />"; }
    if ((
substr_count($email"@")==0) or (strlen($email)<3)) { $err.="Invalid e-mail address.<br />"; }
    if (
strlen($egold)<1) { $err.="The minimum length of the egold id# is 1 number.<br />"; }
    if (
strlen($pp)<1) { $err.="The minimum length of the PayPal email is 1 number.<br />"; }
    
$eredm mysql_query("SELECT * FROM `aff` WHERE username='$username'") or die(mysql_error());
    if (
mysql_num_rows($eredm)>0) { $err.="This username is already taken.<br />"; }
  }
  if (
$err) { errormess($err); print("<br />"); 
  } else {
   
$eredm mysql_query("INSERT INTO aff(username,password,email,egold,pp) VALUES('$newusername','$password','$email','$newegold','$pp')") or die(mysql_error());
   
infomess("You've successfully registered an account."); print("<br />");
   
$username=""$password=""$email=""$egold=""$pp="";
  }
 }
?>
__________________
Dummie Dude

Last edited by dummie84; 08-07-2008 at 11:33 PM..
dummie84 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-08-2008, 04:27 AM Re: Help me. Check php code. Need SHA1.
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
It works? Dont touch it!
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 08-08-2008, 04:28 AM Re: Help me. Check php code. Need SHA1.
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
But in fact it is very bad when computer decides something for you until you asked it to. I mean those "automatic" quotes substitution, data recoding and so on. They all should be turned off.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 08-08-2008, 12:10 PM Re: Help me. Check php code. Need SHA1.
Novice Talker

Posts: 8
Name: dummie dude
Trades: 0
Quote:
Originally Posted by mtishetsky View Post
But in fact it is very bad when computer decides something for you until you asked it to. I mean those "automatic" quotes substitution, data recoding and so on. They all should be turned off.
Can you enlighten me about that?

I forgot to mentions that both register_globals and magic quotes are OFF. I don't know if that what you meant "automatic quotes substitution".
__________________
Dummie Dude
dummie84 is offline
Reply With Quote
View Public Profile
 
Old 08-11-2008, 05:11 AM Re: Help me. Check php code. Need SHA1.
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
What is your question?
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 08-11-2008, 01:53 PM Re: Help me. Check php code. Need SHA1.
Novice Talker

Posts: 8
Name: dummie dude
Trades: 0
Never mind- I've figured it out myself.
__________________
Dummie Dude
dummie84 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Help me. Check php code. Need SHA1.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.23158 seconds with 12 queries