1

I have made a makegroup.php site which is supposed to create a group, and put the person in the connection table between UserID and GroupID.

..but I am not sure how to go on. The logged in user is saved in session variable $usid, but how what about GroupID? How do I fetch that right after on another page? Need I make this in steps? Including quick DB scheme.

Thanks in advance.

Algernop K.
  • 477
  • 2
  • 19
  • Use http://php.net/manual/en/mysqli.insert-id.php. You are open to SQL injections with this code. – chris85 Nov 26 '15 at 14:11

1 Answers1

0

I guess GrouID is autonumeric?

So you leave db create the id for you.

Also loos like you are trying to concat the $groupname value

 $sql = "INSERT INTO group (Groupname) VALUES ('".$groupname."') ";

But you dont want do that because that method is vulnerable to SQL Injection attack

Use parametrized values instead

How can I prevent SQL injection in PHP?

Community
  • 1
  • 1
Juan Carlos Oropeza
  • 47,252
  • 12
  • 78
  • 118