Jump to content

[SOLVED] sql injection


ngreenwood6

Recommended Posts

i tried what you said but it did not work. It just gave me my error. I try the username in the database and it works.

 

my login page looks like this:

 

<?php

$username = $_POST['username'];

$conn = mysql_connect("localhost", "root", "");

mysql_select_db("tests");

$query = "SELECT * FROM users WHERE username='$username'";

$results = mysql_query($query);

$num_rows = mysql_num_rows($results);

if($num_rows == 1)
{
$row = mysql_fetch_assoc($results);
}

if($row['username'] != $username)
{
echo "That username is incorrect.";
}
else
{
session_start();
$_SESSION['logged_in'] = TRUE;
$_SESSION['username'] = $username;
header("location:logged_in.php");
}

?>

Link to comment
Share on other sites

what the heck does that mean?

If inserted into your SQL, it should give

$query = "SELECT * FROM users WHERE username=''; delete from users";

 

 

Potentially, that can then execute both statements against your database at the line in your code that says

$results = mysql_query($query);

 

First:

SELECT * FROM users WHERE username='''

returning no valid results

 

Then:

delete from users

 

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.