Jump to content

Love2c0de

Members
  • Posts

    364
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by Love2c0de

  1. Active only executes during the time that the mouse button is pressed down.

     

    For example, try this example and hold your mouse down on the link, you see that it sets the background to yellow.

    <!DOCTYPE html>
    <html>
    <head>
    <style>
    a:active
    {
    background-color:yellow;
    }
    </style>
    </head>
    <body>
    
    <a href="http://www.w3schools.com">w3schools.com</a>
    <a href="http://www.wikipedia.org">wikipedia.org</a>
    
    <p><b>Note:</b> The :active selector styles the active link.</p>
    
    </body>
    </html>
    

     

    I get the feeling you mean that if you go to a certain page, while you are on that page, the link will have a different style so the user can easily determine the page he's on. Is that right?

     

    Regards,

     

    L2c

  2. Sorry if this is not the correct sub-forum, I just went through most sections and didn't really know the best place.

     

    I want to learn object oriented php but can't seem to find any resources which are written in good english.

     

    I was wondering if someone knows of any reliable resources for learning pdo?

     

    I've already looked on php.net but I wanted more of a tutorial based website written for novices.

     

    I hope someone can throw me a few links.

     

    Kind regards,

     

    L2c

  3. Hey bud, you can give this a try:

    <?php
    
    $textlevel= "Intermédio";
    $words = str_word_count($textlevel,0,"éç");
    
    if($words == 2)
    {
    $textlevel = str_replace("Intermédio avançado","high_intermediate",$textlevel);
    }
    else
    {
    $textlevel = str_replace("Intermédio","intermediate",$textlevel);
    }
    
    echo $textlevel;
    
    ?>
    

     

    Just wrote it works pretty well.

     

    EDIT: LOL just do what jessica said. :pirate:

     

    Hope this helps you,

     

    Regards,

     

    L2c.

  4. Can you explain a little more about the problem, your question is very vague. The image is displaying in the top left corner already. You left out the closing '/>' on your <img> tag and also some of the <input tags. I've added double quotes around your HTML attribute values also. I updated your code:

    <div id="logo"><img src="logo.jpg" alt="yourImg" /></div>
    <div id="login">login page</div>
    
    <table>
    <tr>
    <td >Name</td>
    <td width><input type="text" name="myname"></td>
    </tr>
    <tr>
    <td>Age</td>
    <td><input type="text" name="myage"></td>
    </tr>
    <tr>
    <td> </td>
    <td><input type="submit" value="submit" /><input name="Reset" type="reset" value="Reset" /></td>
    </tr>
    </table>
    </div>
    
    

     

    Also, there is an extra closing div </div> tag, but not opening div. Post your full code please

     

    Regards,

     

    L2c.

  5. You are using the assignment operator '=' instead of the comparison operator '==' in the second if statement, therefore the if statement interprets the 1 as a TRUE value and will always execute the if statement.

     

    Just change the second if to ==.

     

    Kind regards,

     

    L2c

  6. After sending each email, do this:

     

    $message = "";

     

    This will clear the $message variable and set it to an empty string. The reason it was sending the emails was because you are concatenating the $message variable all the way through the script so it's literally just adding the other email to the end of the string for the first email.

     

    Regards,

     

    L2c.

  7. You can use double or single quotes I think, but you definitely need to use one of them. See my edited code above, I just tested it and it returned an error when I used no quotes whatsoever.

     

    Is your error reporting turned on?

     

    Regards,

     

    L2c.

  8. I'm not the best at debugging php code, but just as a rule of thumb I would stick your $_POST indexes in single quotes.

    $_POST['name'];
    

     

    EDIT: I think you do have to explicitly set the double or single quotes and its returning an undefined constant error

     

    That's another great debugging tool - var_dump(). Tells you the type and value of a variable and key/values of arrays.

     

    hope it helps.

     

    Regards,

     

    L2c

  9. Since IDs need to be unique, I generally only apply them to elements that may appear multiple times on a page, but need to be uniquely identified/isolated from other elements of the same type.

     

    You can only apply id's to a single element on any given page. For what you said there, if you have multiple div's which have the same styles (i presume so because you said you were using the id multiple times), you should be giving them a class. It works in pretty much the same way.

     

    For example, I query products from a database, for every row that is found, it prints a div with the information inside for each individual product. I have styled the div's identical so I decided to give the <div> a class when writing the php.

     

    Not sure if you're bothered about this but it won't pass validation neither.

     

    Regards,

     

    L2c

  10. Ok, I've done what it's said and required the file in my script. I notice when I opened up the PasswordHash.php that is it written in PDO. Does this mean i'll have to use PDO to call the functions etc or can I do it in a prodedural way?

     

    Regards,

     

    L2c.

  11. crypt() uses "rounds" to hash. This means that instead of hashing once and done, like sha1() or md5() do, it will recursively hash N times. It also adds the salt to the end result.

     

    But, the big thing is that it supports the Blowfish algorithm, which is very strong and takes a long time to run.

     

    If you don't know what you're doing, use a third-party library from someone who does. One of the more reknowned ones is PHPass, but a few others exist as well.

     

    Is this not something I can just do with PHP native functions? Obviously I'll read up about how to do a basic hash and then improve upon that. Does it become too complicated with just the native PHP functions then?

     

    Regards,

     

    L2c.

  12. http://crackstation....ng-security.htm the last time i checked that site it was down but it has a very good tutorial on how to hash and sal a password.

    i use there sample code but it will be better if you read from him first on how he explains that code.

    public static function create_hash($password) {
     // format: algorithm:iterations:salt:hash
     $salt = base64_encode(mcrypt_create_iv(PBKDF2_SALT_BYTES, MCRYPT_DEV_URANDOM));
     return PBKDF2_HASH_ALGORITHM . ":" . PBKDF2_ITERATIONS . ":" . $salt . ":" .
    		 base64_encode(self::pbkdf2(
    						 PBKDF2_HASH_ALGORITHM, $password, $salt, PBKDF2_ITERATIONS, PBKDF2_HASH_BYTES, true
    				 ));
    }
    private static function pbkdf2($algorithm, $password, $salt, $count, $key_length, $raw_output = false) {
     $algorithm = strtolower($algorithm);
     if (!in_array($algorithm, hash_algos(), true))
    	 die('PBKDF2 ERROR: Invalid hash algorithm.');
     if ($count <= 0 || $key_length <= 0)
    	 die('PBKDF2 ERROR: Invalid parameters.');
     $hash_length = strlen(hash($algorithm, "", true));
     $block_count = ceil($key_length / $hash_length);
     $output = "";
     for ($i = 1; $i <= $block_count; $i++) {
    	 // $i encoded as 4 bytes, big endian.
    	 $last = $salt . pack("N", $i);
    	 // first iteration
    	 $last = $xorsum = hash_hmac($algorithm, $last, $password, true);
    	 // perform the other $count - 1 iterations
    	 for ($j = 1; $j < $count; $j++) {
    		 $xorsum ^= ( $last = hash_hmac($algorithm, $last, $password, true));
    	 }
    	 $output .= $xorsum;
     }
     if ($raw_output)
    	 return substr($output, 0, $key_length);
     else
    	 return bin2hex(substr($output, 0, $key_length));
    }
    public static function validate_password($password, $good_hash) {
     $params = explode(":", $good_hash);
     if (count($params) < HASH_SECTIONS)
    	 return false;
     $pbkdf2 = base64_decode($params[HASH_PBKDF2_INDEX]);
     return self::slow_equals(
    				 $pbkdf2, self::pbkdf2(
    						 $params[HASH_ALGORITHM_INDEX], $password, $params[HASH_SALT_INDEX], (int) $params[HASH_ITERATION_INDEX], strlen($pbkdf2), true
    				 )
     );
    }
    private static function slow_equals($a, $B) {
     $diff = strlen($a) ^ strlen($B);
     for ($i = 0; $i < strlen($a) && $i < strlen($B); $i++) {
    	 $diff |= ord($a[$i]) ^ ord($b[$i]);
     }
     return $diff === 0;
    }
    

     

    Hello 50r

     

    That code is just far too complicated for me to understand right now, I'm very new to PHP.

     

    It seems like it isn't just a simple task then if you want to do it properly?

     

    Regards,

     

    L2c.

  13. Hello, just had a look.

     

    Give this code a try:

    require_once 'myconn.php';
    $sql = "SELECT course_id, course_name FROM course";
    $result = mysql_query($sql);
    
    echo "<label>Select Course</label>";
    echo "<select>";
    
    while($row = mysql_fetch_array($result))
    {
    
    echo "<option value='{$row['course_id']}'>{$row['course_name']}</option>";
    
    }
    echo "</select>";
    

     

    You might also want to check what the query returned before trying to use it's value.

     

    Hope it helps,

     

    Kind regards,

     

    L2c.

  14. Can you post your updated code?

     

    I remember getting that error but I think it was only when I was printing $stmt which is an array.

     

    Rather than doing this:

    $Result1 = mysql_query($insertSQL,$subscribers) or die(mysql_error());
    

     

    do this:

    $Result1 = mysql_query($insertSQL,$subscribers);
    
    $rows = mysql_num_rows($Result1);
    
    if(!$rows)
    {
     echo "Username and/or password already in use.";
    }
    else
    {
    echo "You have successfully registered.";
    }
    
    

     

    If it failed, it returns false. If it is then send an error, if its anything else, it inserted ok. Note if it returns the number of rows, for instance 1 or above, the if statement will interpret that as being TRUE. Just like FALSE can be associated with 0 or -1 in some cases, at least in JS.

     

    Edit: try putting just the $Result1 in the if statement as well and coment out the num_rows and see what you get.

     

    Regards,

     

    l2c

  15. ok well when i comment that section it stops giving any errors.

     

    it also enters valid emails into the database now, but back to the problem, it allows same emails to keep being entered.

     

    Change your email field in your database to be unique. By doing this, if you someone tries to enter an email address which is already in the table, it will return either -1 or 0 for mysql_num_rows(), in which you know it didnt get inserted so you can show an error saying it's already in use.

     

    Regards,

     

    L2c.

  16. What is the best function to use when hashing passwords? I've looked on php.net and they tell you on there to stay away from sha1() and md5().

     

    I read also about hash() and crypt() and from what I read decided to go with crypt().

     

    I don't really understand the hash types of this function though.

     

    Can anyone pelase explain a little on this or even the best way to encrypt your passwords?

     

    Kind regards,

     

    L2c.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.