0

How to add value through the update? This code copies the value in the registration id to the url. For example, if id=1 then url=1. How to order update id=1 then url=id1, id=2 then url=id2. Thanks in advance!

I need this kind of

url = 'id+".$last_id."'

function register_user($register_data) {
    global $con;

   $con = mysqli_connect('Localhost','social','social','social');

    array_walk($register_data, 'array_sanitize');
    $register_data['password'] = md5($register_data['password']);

    $fields = '`' . implode('`, `', array_keys($register_data)) . '`';
    $data = '\'' . implode('\', \'', $register_data) . '\'';

    $insert = "INSERT INTO users($fields) VALUES ($data) ";
    mysqli_query($con,$insert);
    $last_id = mysqli_insert_id($con);
    $update = "UPDATE users SET url = '".$last_id."' WHERE id = ".$last_id." ";
    mysqli_query($con,$update );
}
  • Sidenote: Is this intended for a live site, or is this temporary or for educational purposes? You've a major security issue here. – Funk Forty Niner May 23 '15 at 15:07
  • Is this intended for a live site – Узбек Баха May 23 '15 at 15:10
  • I recommend you put that on hold and for a few reasons. You've a major [**SQL injection**](http://stackoverflow.com/q/60174/) issue, as well as using MD5 for password storage. That method is no longer considered safe to use for that. – Funk Forty Niner May 23 '15 at 15:12
  • @Fred-ii-, Thank you! I understand I am a novice and I'm 16 years old. Now I need to build a website from scratch. First I need to skillet site and Pat I take (security). – Узбек Баха May 23 '15 at 15:36

1 Answers1

1

Try this:

$update = "UPDATE users SET url = 'id".$last_id."' WHERE id = ".$last_id." ";

Or did not I get the question?

Richard
  • 2,840
  • 3
  • 25
  • 37