MySQL / PHP dating site
- Started
- Last post
- 40 Responses
- juhls0
Do you guys think I should have a separate include page for the username and password of existing members? Meaning: the login portion of the site?
Here is the code so far:
http://pastebin.com/m42e4ba92Also, for if($query), how do I add another query to that? is it
if($query && $query2) ?I'm getting an error with querying the database, and I have a feeling it's because of the interests (the code is right before the HTML starts) but I'm not getting any other error message.
"query" is still sent to the "clients" table, but the interests ("query2") are not sent to the interests table.
- nocomply0
Check out http://www.punkmatch.com/ for some good inspiration
- drgss0
Shouldn't it be if($result && $result2)? $query and $query2 are strings
Btw, $result2 returns success boolean only for the last interest insert, which is probably ok. If at least the last one is ok, then the rest are too, and if something is wrong with the client_interests table, the whole row should fail
But to be extra anal about it , to check if all interests are inserted
$result2 = TRUE;
$interests_array = array_map('trim', explode(',', $interests));
foreach ($interests_array as $interest) {
$query2 = "INSERT INTO client_interests(client_id, interest) ". "VALUES ('$insert_id', $interests')";
$result2 = $result2 && mysqli_query($oConn, $query2) or die('Error querying database.');
}Also, it should be "Your last name" on line 57
- BattleAxe0
line 150 you left out a ' on inserting the Vaules ('$insert_id', $interests') should be ('$insert_id', '$interests')
little gotchas like that will do ya
also why not try a SWITCH statement instead of all the if's same logic but more standard
- vaxorcist0
for security, I highly suggest adding a hash reference field to the user table so that you are not doing the following:
edit_user.php?id=321
where user may try to hack and change "321" to anything else, and attempt to edit annother user's info. This can be prevented a number of ways, but seeing a URL like that in any referral logfile is an invitation to somebody to messs with your app....
whereas a hash like:
edit_hash?hash=sdf83767d9d376216...
is much cleaner... I use sha1 for a 40 character char field in the database and add a simple function id=lookup_id_from_hash($hash)
- BattleAxe0
you might have to have a pre-determined list of interest and make them radio buttons each with an ID so they go in separate , if you they are inputting into one field they produce 1 ID
- juhls0
I have them in the same client_id so that I can match up client interests together on a separate page, depending on the sex they are interested in, etc.
- rightly so, but I was referring to interest_id , each intr. should be pre-determined or matching themBattleAxe
- will become a nightmare unless you are checking spelling, and case of each entryBattleAxe
- gotchajuhls
- I made some of the code for the matches page already, so I will work with what I have for now. Your way sounds better in thejuhls
- long run, so I'll definitely keep it in mind. Just wondering though...the dating site would have to be specifically gearedjuhls
- to a certain group of people (like designers) so that the pre-determined list would be short.juhls
- Right? Otherwise you'd have to think of nearly everything in the world.juhls
- PonyBoy0
Maybe I can use your site to attempt to replace my long lost love, Cherry?
- juhls0
I made this earlier so that I wouldn't have as much code to worry about today:
http://pastebin.com/m3a357d8aWhere would be the best place to put that so that the file uploading works correctly or most efficiently?
I know it has to go somewhere after the
$insert_id = mysqli_insert_id($oConn);because the client_photos table uses the same value for its "client_id"
But I'm not sure if I should be separating the code or if I should put it in an include instead.
- juhls0
Here is the updated code with my attempts:
http://pastebin.com/m79bac160The image won't upload at all, let alone in the correct folder. Any ideas?
Also, do I have too many error messages or is the uploading section too complicated for basic use?
- Got it working! The validation still needs some work, but this is good news.juhls
- The mime type is still being weird (I keep getting (Undefined index: file) error, but the basic functionality is there.juhls
- just a simple syntax error, should be fine now.juhls
- Just noticed that the file doesn't get uploaded into any directory. I changed the permissions...juhls
- Got it. Just had to "show invisible files" in Transmitjuhls
- moth0
You can put the login stuff into a separate include if you want to. There's no hard rules on this stuff - whatever helps you keep things organized.
If you find yourself repeating code, you're doing it wrong...
- moth0
This stuff is excellent practice, but if you're really wanting to pursue development, you should also read up on OOP and have a peep at a simple framework like codeignitor.
What you're essentially doing here is the equivalent of chewing pulp to make your own paper to print on. There are a load of frameworks that do all this grunt work for you.
- juhls0
Hey guys, I got half of it working now. Just some querying stuff to do and I also need to figure out how to let someone modify their own profile.
The next thing I am working on is to display some random profiles on the main page.
What can I do to make this work? I looked at various tutorials and information on the internet but all of them seem overly complicated.
http://pastebin.com/m20da394eNot sure if I should do two separate queries...
table: client_photos
column: file_name (or whatever displays the image)table: clients
columns: dob, cityThe client_id has to match from both tables so it's not a random photo being displayed with the dob and city.
I'll have to figure out how to display the age based on the dob later as well.
Thanks for any help again.
- I updated the PHP with some more code that I modified.juhls
- http://pastebin.com/…juhls
- lukus_W0
checkout http://www.kohanaphp.com/ - it might be worth learning if you're into building webapps with php
- juhls0
I have another question (surprise!)
I have a page that displays the user's profile. It's all working, except for when I'm displaying the "interests" for the user.
How can I expand the query to include as many rows as needed from all the rows with the same client_id? Instead of just doing one row.
- moth0
Next one - you want mysql_fetch_array
Look at the samples here; http://php.net/manual/en/functio…
- Solution was mysqli_fetch_assoc and some other stuff...juhls
- juhls0
Not sure if anyone is around right now, but last thing. See anything wrong with this?