Support Forums
Simple Login and Search - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: PHP The Hypertext Preprocessor (https://www.supportforums.net/forumdisplay.php?fid=21)
+---- Thread: Simple Login and Search (/showthread.php?tid=3926)



Simple Login and Search - nevets04 - 12-24-2009

I took a script Master of the Universe gave me to connect to a database ad display information to make these two tools.

Login
http://www.mediafire.com/file/jiwmmntlynh/Login.zip

Search
http://www.mediafire.com/file/5gd2dz0mzmz/Search.zip

Although my login does work I'm confused. I figured when you registered it would be saved to login.sql, however it is not. Where is it saved to?


RE: Simple Login and Search - Gaijin - 12-24-2009

In the registered.php you have a error.
After you definde $sql add this
It will execute the SQL command.
PHP Code:
$query mysql_query($sql) or die (mysql_error()); 

And in the script I've gave you, add this after the while function. (loggedin.php)
PHP Code:
mysql_free_result($query); // it will free up the memory 

Then the line (loggedin.php)
PHP Code:
if(!$query mysql_query($sql)) {
// to
if(!$query mysql_query(mysql_real_escape_string($sql))) {
// mysql_real_escape_string will clean $username and $password from malicious input 

To keep the connection, you'll need to set cookie or an session
http://php.net/manual/en/features.cookies.php
http://php.net/manual/en/features.sessions.php

Now to search...
Perfect, you did a best query... I was expecting to see "WHERE" but you used "LIKE", nice!!!