Jump to content

integration


joyza

Recommended Posts

I currently have a project undergoing, however i need help integrating two scripts:

 

Login script & Comment Script

 

The checking if logged in part is this -

	if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID']) == '')) {
	header("location: access-denied.php");
	exit();
}

 

and i want it so that i can check if the user is logged in the comment script will use there first name from my mysql table of members.

 

The field name in the table for first name is 'firstname' and my comment section script looks like this

 

		echo "<div class=\"commentbody\" id=\"$commentrow[0]\">\n
	<p class=\"postedby\">Posted by ";
	if($commentrow[3]){
        echo "<a href=\"$commentrow[3]\">$commentrow[2]</a> ";
	} else {
	echo "$commentrow[2] ";
	}
	echo "</p> \n
        <p>$commentbb</p>\n\n</div>";
}
echo "</div>";
}

 

Please someone help me, its driving me crazy.

 

Any more info needed just ask :) many thanks in advance!!

 

Link to comment
Share on other sites

You're using this to access data from the record set: $commentrow[3]

 

That is very unreadable, when dealing with a set of fields as you are, use the field name like $commentrow['firstname']. Be sure to use mysql_fetch_assoc() not fetch_row() or fetch_array().

 

Also, it's a good idea to store small pieces of user information in the session such as first name so you can quickly access those details without having to query the db. Take for example a "Welcome John" sort of message shown on all pages.

Link to comment
Share on other sites

$_SESSION['SESS_MEMBER_ID'] = $member['member_id'];

$_SESSION['SESS_FIRST_NAME'] = $member['firstname'];

$_SESSION['SESS_LAST_NAME'] = $member['lastname'];

 

Thats the stuff that is used to check if the login was successful and the variables used.

 

How would i use that to print out "Welcome username".

 

And also how would i make it so that when the guest has logged in, on the comment script it would change the name textfield to the username, could i use an if statement or what??

 

All help appreciated.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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