Jump to content

how to secure login form


priyanka

Recommended Posts

Hi,

 

 

I am using following code in login form:

<td><input type="hidden" name="txtURL" value="<?=$_GET['url']?>"><input name="submit" type="submit" value="Submit" class="button" /> <input id="reset" name="reset" type="reset" value="Reset" class="button" /></td>

 

but a coding checker software says that it has security issues in <?=$_GET

 

I have one more form for login check, there i wrote

 

if(!isset($result['evoId'])){
        header('Location: login.php?action=invalid');

 

Software gives error in "IF"

 

and i used this in logi chk

if($txtURL=='reverse'){
                header('Location: ABC=');
            }else{
                header('Location: index.php');

 

It gives error in "if($tx"

 

please help and suggest

 

Priyanka

Link to comment
Share on other sites

You need to sanitize $_GET['url'] because it might contain malicious code.

 

You could do something like this

 

function clean_data($input) {
    $input = trim(htmlentities(strip_tags($input,",")));
 
    if (get_magic_quotes_gpc())
        $input = stripslashes($input);
 
    $input = mysql_real_escape_string($input);
 
    return $input;
}

then you could do this
 

<input type="hidden" name="txtURL" value="<?=clean_data($_GET['url'])?>">
Link to comment
Share on other sites

I would recomend cleaning all data after the form is submitted, not before.

if(isset($_POST['submit'])){

  foreach($_POST as $k => $v){
     ${$k} = some_safeclean_function($v);
  }

  // input name 'myinput' is now clean as $myinput along with all the other posted inputs

}
Edited by alpine
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.