Page 1 of 1

Login using cookies and validation for forms

Posted: Tue Nov 08, 2005 11:48 am
by waradmin
This may sound very strange but ill try to explain it the best i can.

I want to create a simple community site system. Like say for example myspace, it will use a common page layout, and database for users and their information.

I have a registration form and login form for the users. What i want to be able to do is have a newentry.php file that will put new blog entries into the database for that user. The table will have 5 fields being:
ID, uname, title, content, time

The username that goes in the uname box is the one the user used to login and its stored in a cookie. Now if possible, how would i get the value from the username cookie into the form automaticly as a hidden field so it will put the entry into the database under that persons name. That way when they go to user.php?user=uberamd (for example) it will only pull up entries from the database where uname = uberamd. I know how to pull values like that, but getting the username to post into the database i dont now how to do,

And a last question, how do i make blank database values not display as a space. at my demo of this for my user http://www.myopenspace.net/user.php?user=uberamd i have made about 3 blog entries (they arent displayed on the main page tho) and the way the DB is currently layed out, login information as well as profile information you see on the main page are in the same database.

The values in the database for the First name and last name field are only put in once, so all other fields for that username have First name and Last name with NULL values, and those display as spaces. So how do i run a query that makes NULL database values not display as a space. Or if i cant do that how do i run a query so after it finds one result that matches the value in the database it stops and doesnt loop through any more records. Thanks.

(to see the DB layout view this image) values are only placed in Fname and Lname once the rest are null and that creates the spaces.

So questions are:
How do i pull a uname from a cookie and put it as a hidden field in a form?
How do i make null values not display as spaces? or how do i only get a value once from a db?
Thanks.

Posted: Tue Nov 08, 2005 12:04 pm
by Grim...
1)

Code: Select all

<input type=\"hidden\" name=\"cookieinfo\" value=\"".$cookiename."\" />
2)

Code: Select all

if (strlen($database_information) > 1)
{
    print $database_information;
}
3) Do you mean LIMIT or SELECT DISTINCT?

Posted: Tue Nov 08, 2005 10:34 pm
by waradmin
So this is how the call to the cookie looks on the top of the pages that require it. How would i put it into the form:

Code: Select all

if($_SESSION['Uname'] == '' || $_SESSION['lp'] == '')
{
header("Location: login.php");
exit;
}
Thanks