Jump to content

Recommended Posts

I don't understand how you use it. Here are the scripts that I would like to use it one:

 

<?php
$con = mysql_connect("localhost","My_Username","Password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("My_DB", $con);

printf("Last inserted record has id %d\n", mysql_insert_id());

$sql="INSERT INTO users (id,username,password,userlevel)
VALUES
('$_POST[id]','$_POST[username]','$_POST[password]','$_POST[userlevel]')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "<strong>User Added to Database!</strong>";

mysql_close($con)
?> 

 

<?php
$con = mysql_connect("localhost","My_Username","Password");
mysql_select_db("My_DB", $con);
$username = mysql_real_escape_string($_POST["username"]);
if (isset($_POST['edit'])) {
$sql = "UPDATE users SET username = '{$_POST['username']}', password = '{$_POST['password']}', userlevel = '{$_POST['userlevel']}'
WHERE `username` = '$username' LIMIT 1";
mysql_query($sql)
or die (mysql_error());
}  
?>

 

Also, how else could I make these scripts more secure? Thanks!!

I just read it.

 

i can't count how many times reading the manual about a function solves a thread, and could have done so even before the thread was posted. i hope you've learned a lesson - the PHP manual is your friend.

I also learned that the protection script that I am using (X-Protection) is not secure :-\

 

So, now I guess I will work on making it secure.  :'(

 

There are a multitude of tools that you can get via plug-in for your browser (i.e. - SQL Inject ME), to test your applications with.

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.