...

View Full Version : PHP/MYSQL overwrite HELP



terter2000
01-12-2010, 08:06 PM
-code copyright-

shadowmaniac
01-12-2010, 08:58 PM
Is the code you're writing part of the registration process?
If so, have you even considered what would happen if somebody tries to register on your site using either "Username" or "jacson" (from your DB snippet) as their username when some other registered user already registered with those exact usernames?

mlseim
01-12-2010, 09:23 PM
not to mention sql injections.

but I just don't have the time right now to give him/her the correct code,
so i won't rip into it too much.

Terter,
You'll have to explain more about what your script is all about.

terter2000
01-13-2010, 02:28 AM
Is the code you're writing part of the registration process?
If so, have you even considered what would happen if somebody tries to register on your site using either "Username" or "jacson" (from your DB snippet) as their username when some other registered user already registered with those exact usernames?

thats what i want?
its like basically a script to update?
if someone typed jacson in the username field and some data in the data field , it will overwrite.

terter2000
01-13-2010, 02:29 AM
not to mention sql injections.

but I just don't have the time right now to give him/her the correct code,
so i won't rip into it too much.

Terter,
You'll have to explain more about what your script is all about.

i am actually working on a shopping directory ,
you enter your name and data,
it will update the exisiting data.

mlseim
01-13-2010, 03:53 AM
So there's way more to the script than what you show?
There must be something there that makes sure the person
is already logged in?

And you're coding the whole thing from scratch?

terter2000
01-13-2010, 05:27 AM
-code copyright-

terter2000
01-13-2010, 05:29 AM
So there's way more to the script than what you show?
There must be something there that makes sure the person
is already logged in?

And you're coding the whole thing from scratch?

no need , just replace with the text field
the username textfield will check if there is identical , if there is just replace without any warning or what soever

i know what i am doing , i am like combining 5 kinds of script together , this is 1 of the part.

PappaJohn
01-13-2010, 05:50 AM
To replace an existing record or insert a new record if none exists, look at REPLACE (MySQL) (http://dev.mysql.com/doc/refman/5.1/en/replace.html)

terter2000
01-13-2010, 08:05 AM
To replace an existing record or insert a new record if none exists, look at REPLACE (MySQL) (http://dev.mysql.com/doc/refman/5.1/en/replace.html)

don't think i can do that with flash as3?

terter2000
01-13-2010, 01:23 PM
please help experts !

terter2000
01-13-2010, 05:42 PM
now i thought of a better example
imagine if i login as "hellokitty"
i decided to change the username to "hellopanda"

how am i going to achieve that , because the above thingy is like what i wanted to do.

isnt that using REPLACE in mysql using php?

mlseim
01-13-2010, 06:17 PM
$name=$_POST['username'];
$entry=$_POST['entryname'];
$query="UPDATE entries SET entry_name=`$entry` WHERE user_name=$name";
$result = mysql_query($query) or die( "An error has ocured: " .mysql_error (). ":" .mysql_errno ());

terter2000
01-14-2010, 01:28 AM
+rep +thank , thanks a lot it works !

mlseim
01-14-2010, 02:07 AM
Terter ...

You should also "sanitize" all variables that go into an SQL query ...
as a minimum, to avoid SQL injections.

See this example:


$name = mysql_real_escape_string($_POST['username']);
$entry = mysql_real_escape_string($_POST['entryname']);
$query = "UPDATE entries SET entry_name=`$entry` WHERE user_name=$name";
$result = mysql_query($query) or die( "An error has ocured: " .mysql_error (). ":" .mysql_errno ());



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum