Jump to content

[SOLVED] Novice SQL Error


Akenatehm

Recommended Posts

Hey guys, somethings wrong with this syntax, I was just trying and experimenting. I am sure it won't be something big thats wrong with it.

 

Here it is:

 

<?php

include "connect.php";

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

{
   $username=$_POST['username'];

   $email=$_POST['email'];

   if(strlen($username)<1)

   {

      print "You did not enter a username.";

   }

   else

   {

      $delete="DELETE FROM users WHERE username = '$username' OR 1=1 OR email = $email";

      mysql_query($delete) or die("Could not delete user" . mysql_error());
  
  echo "User Deleted. <A href''<a href=\"home.html\">Click here</a> To Go Home.";
   }

  }

?>

Link to comment
Share on other sites

It means if someone sneaks a "'" into your textbox, then they can write there own SQL query that could drop, delete, or read your database. Its called SQL Injection and you might want to make your scripts more secure before you get too far into your coding that it would take hours and many errors to get your code secure.

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.