Jump to content

[SOLVED] any suggestions??


nelquintin

Recommended Posts

I have developed a membership system with help from this site and many a like and all i would like to know if it better to have a database per user or should i use a table for each user. when the user logs in i just want to display his/her contacts that they have added to the database. i have a vague idea about sessions.

Link to comment
https://forums.phpfreaks.com/topic/47220-solved-any-suggestions/
Share on other sites

i would recommend you do not use LIKE in your SQL query. you could run into problems if users have simliar usernames.

 

i.e. if a user has the username "andrew" and another users username is "andrews", when andrew logs in he will also see andrews contacts because of the likeness in usernames.

 

another feature i had was, when one user added another they had to be accepted by the user before he would be visible. i have a similiar table structure to how supermerc recommended, i just had another field "status" where i would change the value in the field to "verified" once the contact had been accepted. so when i (for example) added a contact the status field would be "pending" until the user i added accepted me as their contact.

 

here is the SQL Query i use:

SELECT * FROM `tablename` WHERE `username` = '$username' AND status = "verified";

 

This is to stop users from spamming other users by guessing usernames and sending messages to randomn people.

ok now i have to write the contacts into the right table.so i tried

$result=mysql_query("INSERT INTO users WHERE username = '$username' (name, surname, birthday, mobile, office, home, email, maxprice, minprice, bed, gar) no luck also dont i have to specify the tablename which i would only know once they have signed in?

i do know the structure of my database.Maybe i can try explain a bit better. When a user logs in i want him to retrive his contacts/client that he has submitted. i have a table called user and then i have tables for each of the user that will use this database. So how can i input the table name in

SELECT * FROM `tablename` WHERE `username` = '$username'  when i would only know what the tablename is according to who signs in?hope this helps.

$sql = "SELECT
                *
          FROM
                client
          WHERE
                username = '$user'";

$query = mysql_query($sql) OR die($sql . "<br />\nCaused the following error: ". mysql_error());

 

replace $user with something you KNOW is in the database under the column 'username'.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.