/    Sign up×
Community /Pin to ProfileBookmark

Forum account integration on front page

I’ve hit a bit of a wall here. I’ve been creating a website for someone, I’ve already set up the forums along with a MySQL database for said forums. I want to include some sort of front page integration for this, for example:

[img]http://imgur.com/Jfh1l6U[/img]

Obviously creating the actual field isn’t a huge issue, but it’s getting it to connect to my forum database to retrieve the user’s credentials is what’s hindering me. When they log in, it would be nice if it fetched their profile preferences, such as their avatar, forum inbox, etc. Like so:

[img]http://i.imgur.com/GClAqcr.jpg[/img]

Other features I can work in for myself. Otherwise, I’m not sure how to make it so once they log in it displays something like image 2 rather than looping back to the login fields. One workaround I considered is having two separate front pages, and once they log in it will redirect them to front page version 2, with that feature in. But that’s messy and unnecessary. I’m sure there’s a way to check and say something like: “If the user is logged in, then display profile details”, rather than “If user is logged in, then display login field”

If anyone could help me out with this, or at least refer me to a good source of information on this, I would appreciate it.

to post a comment
HTML

2 Comments(s)

Copy linkTweet thisAlerts:
@PrototapeauthorNov 23.2013 — Alright, so this is no longer so much a question as to how to integrate it anymore. I now understand that you need to establish a connection to the MySQL database via php. I've located the database and sub-database I need to connect to. I know how to connect to that now (to a point, I haven't tried to actually do it yet considering most guides run off the premise that you're connecting to a local host). I narrowed my search down and was able to figure out how to do that, I just can't test it yet because I'm developing the front page before launching it to avoid using too much bandwidth.

My question now is more or less how to make the login field change to a profile display field once a user logs in. The standard response most tutorials give is "Once you're logged in, redirect them to a new page", which makes sense for some situations. So, is it possible to say:

"If user is logged in, then: *launch HTML code showing display of profile*" I know that PHP and HTML don't get along with each other in some circumstances, as in, you have to run PHP code before the HTML header. But, is it possible to insert HTML code in PHP? At this point, that's all I really need to know. That, and how to get the PHP to state that once a user is logged in, it should run the HTML code that designates a certain field to change from a login 'widget' to a profile 'widget'.

One last question here: In order to connect to the database, is it right that I'm referring to my domain name "www.mydomain.com" as the host? I've given that particular directory permission to access my database via myPHPadmin. From there, I just need to supply my MySQL database, sub-database, username, and access password.

My problem isn't understanding code, most if it is very straight forward, my problem is understanding the rules. I can read PHP/HTML/whateverwebdevelopmentcode, actually writing it is where I struggle.
Copy linkTweet thisAlerts:
@rtretheweyNov 23.2013 — You need three pieces of information to establish a connection to the MySQL server: 1. the URL of the host server (which could be "localhost" or any other URL), 2. the Username, and 3. the Password. Then you'll also need the name of the database in order to do any actual work.

It's not that "PHP and HTML don't get along". But as a PHP file is being processed by the server, as soon as it encounters any non-PHP code, it sends the HTTP headers to the user. What sometimes happens is that a PHP script will include a call to the header() function to modify the HTTP headers, and if the server has already sent them, this function throws an error. The key is to make sure that there is no plain text (including spaces or blank lines) or HTML code outside of your PHP code before the script calls header(). Otherwise, PHP files can be a freely formatted mix of PHP code and HTML.
×

Success!

Help @Prototape spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...