Web Design Forum: retrieving and displaying mysql information on page - Web Design Forum

Jump to content

WDF
WDF Premium Memberships Reseller Hosting
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

retrieving and displaying mysql information on page Rate Topic: -----

#1 User is offline   lukey 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 11
  • Joined: 01-February 12
  • Reputation: 0

Posted 01 February 2012 - 10:16 PM

maybe my previous post was confusing. I have simplified it.

basically the person logs in with username and password.
In mysql there is name1, name2, which are filled in. I want the name1 and name 2 to be displayed on the webpage.
Beside name1 and name2 I will have colour1 and colour2 respectively which is a drop down menu where each user selects a colour and once submitted it saves it to the database beside in the same column as name1 and name2 are in.

the code below shows the login page.

<?php

// Inialize session
session_start();

// Include database connection settings
include('config.inc');

// Retrieve username and password from database according to user's input
$login = mysql_query("SELECT * FROM user WHERE (username = '" . mysql_real_escape_string($_POST['username']) . "') and (password = '" . mysql_real_escape_string(md5($_POST['password'])) . "')");

// Check username and password match
if (mysql_num_rows($login) == 1) {
        // Set username session variable
        $_SESSION['username'] = $_POST['username'];
        // Jump to secured page
        header('Location: securedpage.php');
}
else {
        // Jump to login page
        header('Location: login.php');
}

?>



config.inc is the database connection.

So if the username and password is correct it goes to this page:

<?php

// Inialize session
session_start();

// Check, if username session is NOT set then this page will jump to login page
if (!isset($_SESSION['username'])) {
        header('Location: login.php');
}

?>
<html>

<head>
  <title>Secured Page</title>
</head>

<body>

<p>This is secured page with session: <b><?php echo $_SESSION['username']; ?></b>
<br>*********************</p>
<p><a href="logout.php">Logout</a></p>

</body>

</html>


Where the *** I need to insert the code where name1, name2 will be displayed along with their colour selection from drop down menuu which will be saved into the database.

I appreciate your help.

Thanks
0

#2 User is offline   Snicket 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 25
  • Joined: 01-February 12
  • Reputation: 0
  • Gender:Male
  • Experience:Nothing
  • Area of Expertise:Designer

Posted 01 February 2012 - 11:45 PM

Sorry i dont understand what you mean, you want a user to login and select a colour, it then saves the colour to the database so it can be recalled later on?
0

#3 User is offline   Snicket 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 25
  • Joined: 01-February 12
  • Reputation: 0
  • Gender:Male
  • Experience:Nothing
  • Area of Expertise:Designer

Posted 01 February 2012 - 11:46 PM

or on the secured page you could echo the data from your database table which holds the fields you wish to be displayed?

if that makes sense haha
0

#4 User is offline   lukey 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 11
  • Joined: 01-February 12
  • Reputation: 0

Posted 02 February 2012 - 01:28 AM

well once user logs in, I want their name to be displayed which I need code for. Their names where manually entered to the database.
beside their name there will be a drop down menu of colours. when the person picks their colour and hit the submit button i want the colour to be stored to the mysql database

does this make sense?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users