Jump to content

Fitness Website


prcollin

Recommended Posts

How do i get a personalized display page for when a person logs in.  Basically it is an excercise and calorie counting page.  When the person logs in with their unique id and password I want their personal page to show up. 

 

The clients sign up, and their home page is reflective of the information that they input on the original form.  Then they have a form that they fill otu each day with calories taken in and calories burned off due to excercise.  I want their home page to reflect the update form also.  So that the values update as they enter the form basically.

 

Is there an easy way to have a page update with a form like this. Basically just want their homepage to reflect a calculation of results.  I know how to do the calcuations dont know how to get the page to reflect the most recent submittal.

Link to comment
Share on other sites

Yes, you just use a database to show specific information for that user wherever you like.

 

I am very new to this update form stuff can you give me an example.  Mayeb just like a short example

 

If I sign up with

 

User name:  abcde

Password : abcde

 

First Name : Hello

 

Basically for this example the user would sign in and his home page would say hello

 

I would have a form that would allow him to change the message to whatever and the home page would reflect the new message

 

can you help me with a script just for this simple example then i can work it out from threr

Link to comment
Share on other sites

very basic sample of what you can do.

<?php
/* This scritp requires you to have a db setup, and to have rows on the table
that are named "user_id", "username", "password", "first_name", "last_name", etc
*/
if (isset($_POST['username']) && !(isset($_SESSION['username']))){
//db connection stuff here
$username = mysql_real_escape_string($_POST['username']);
$password = mysql_real_escape_string($_POST['password']);
$sql = "SELECT * FROM `table` WHERE `username` = {$username} AND `password`= {$password} LIMIT 1";
$result = mysql_query($sql);
if (mysql_num_rows($result) > 0){
	$row = mysql_fetch_assoc($result);
	$_SESSION['username'] = $row['username'];
	$_SESSION['user_id'] = $row['user_id'];
	$_SESSION['first_name'] = $row['first_name'];
	$_SESSION['last_name'] = $row['last_name'];
	$_SESSION['is_valid'] = true;
}

}
if ($_SESSION['is_valid']){
print "Hello, ".$_SESSION['first_name']." ".$_SESSION['last_name'];
}
else{
echo<<<END
<html>
	<head>
		<title>Login</title>
	</head>
	<body>
		<form method="POST" action="?">
			<center>
				<table border="0">
					<tr>
						<td>Username:</td>
						<td><input type="text" name="username"></td>
					</tr>
					<tr>
						<td>Password</td>
						<td><input type="password" name="password"></td>
					</tr>
				</table>
			</center>
		</form>
	</body>
</html>
END;
}

Link to comment
Share on other sites

Do you have access to a Database?   You'll need to understand CSS, HTML, PHP and MySQL (if that's your DB) in order to do this easily.

 

Yeah i write CSS, been using HTML for a while, new to PHP but have php5 on my server and Mysql also

Link to comment
Share on other sites

I'm really new to PHP as well. The poeple here are great, but I have found that if you show them that you are trying and can show them some code they are more likely to help. Jonsjava's example is great, but you might want to run through a few of the tutorials first.  PHP get's complicated really fast so in my opinion you'll want to understand how to write to a db first. 

Link to comment
Share on other sites

Get a book.  Even if it only tells you the basics, it will help.  I have learned quite a few things here, and I have only read one simple book.  Of course, I look at the PHP manual when I need to know how to do something, so that is a must too.

Link to comment
Share on other sites

Get a book.  Even if it only tells you the basics, it will help.  I have learned quite a few things here, and I have only read one simple book.  Of course, I look at the PHP manual when I need to know how to do something, so that is a must too.

 

YEha i have php and mysql for dummies and the manual but for this type of project i could not find what I was looking for with the resources I had so I figured I would scratch the pros' brains.  Thanks for all the help by the way guys!

Link to comment
Share on other sites

I dont want the informaiton to be only available for that session.  I want it so its like a profile basically.  So that it can be updated and all that good stuff.  Basically these are the fields I am goign to have

 

Name

Age

Height

Weight

Estimated Calorie Intake (Maintain Weight)

Estimated Calorie Intake (Lose 1lb per week)

 

Breakfast (foods eaten)

Breakfast Calories

Lunch - Dinner

Total Calories

Exercise Done

Duration

Total Calories Burned

Total Intake

Total Burned

Net Calories

Average Time to lose 1 lb

 

I know how to generate all the forms, the equations and all that but I want those fields to be on a permanent page that can be updated each day.  And the values that are currently there are replaced by new ones once the submit button is hit. 

Todays Caloric Intake

 

Link to comment
Share on other sites

I cant just do a replace the page with a new one thing because the only fields that are going to change are the ones being updated at that time.  Not all fields have to be updated at once.  So i just need the ones tha are updated to change.  And at the end of the day when they click "End Day" it files it away in a directory and loads a blank page with all those fields empty. 

 

When they click day done I want the title of the file to be the Date that they enter in the date field.html

 

Is there a way to do that also??

 

Sorry complete newb to this type of php work

Link to comment
Share on other sites

The easy way to do it is to just load in the current values into the form.  When they hit update it writes it all back, but since the data itself hasn't changed, it writes back the same value.  It's either that or have updates to each field, which would be a pain.

Link to comment
Share on other sites

Get a book.  Even if it only tells you the basics, it will help.  I have learned quite a few things here, and I have only read one simple book.  Of course, I look at the PHP manual when I need to know how to do something, so that is a must too.

 

YEha i have php and mysql for dummies and the manual but for this type of project i could not find what I was looking for with the resources I had so I figured I would scratch the pros' brains.  Thanks for all the help by the way guys!

 

good book, its what i used to start me off. it gives you a good idea on member systems and databases i thought. try the example aplications. (the pet store?)

Link to comment
Share on other sites

Get a book.  Even if it only tells you the basics, it will help.  I have learned quite a few things here, and I have only read one simple book.  Of course, I look at the PHP manual when I need to know how to do something, so that is a must too.

 

YEha i have php and mysql for dummies and the manual but for this type of project i could not find what I was looking for with the resources I had so I figured I would scratch the pros' brains.  Thanks for all the help by the way guys!

 

good book, its what i used to start me off. it gives you a good idea on member systems and databases i thought. try the example aplications. (the pet store?)

 

Just pulled it out.  Actually i might be able to figure it out kinda from that.  Ill post if i need more hlep unless osmeone wants to direct me a bit more!!

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.