ympprofile.php



<?php

//--------------------------------------------------------------------
// Set these database parameters appropriately.

$DBNAME  = "ympdata";           // Database name
$DBUSER  = "bacon";             // Database username
$DBPASS  = "bacon";             // Database password
$DBTABLE = "ympmembers";        // Database table name
$DBHOST  = "localhost";         // Database hostname

//--------------------------------------------------------------------

/*
This code assumes the following table format:

create table $DBTABLE (
    id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (id),
    email    TEXT,
    password TEXT,
    bandname TEXT,
    state    TEXT,
    genre    TEXT
);

To run this code, a link similar to the following might be used. "ymp"
would be replaced with  the appropriate folder name and "1"  would  be
replaced with the ID number for  a  database  record that  the  caller
wishes to retrieve.

    http://localhost/ymp/ympprofile.php?id=1
*/

//--------------------------------------------------------------------
// Determine ID number.

if (!isset ($_GET ['id']))      // Did they specify an ID?
{                               // No  - Send them to Error 404 page
    header ("Location: 404.php");
    exit;                       // Exit the script
}

//--------------------------------------------------------------------
// Start talking to MySQL.

                                // Connect to MySQL server
$dblink = mysql_connect ($DBHOST, $DBUSER, $DBPASS);

mysql_select_db ($DBNAME);      // Select appropriate database
                                // Check may be advisable here but may
                                // not be essential

//--------------------------------------------------------------------
// Get user information from MySQL.

                                // Get the ID number
$id = mysql_real_escape_string ($_GET ['id']);

                                // Retrieve database record
$check  = mysql_query
    ("SELECT * FROM `$DBNAME`.`$DBTABLE` WHERE `id`='$id';");

                                // Check the results
if (mysql_num_rows ($check) < 1)
{                               // Error - It didn't work
    mysql_close ($dblink);      // Close the database
                                // Send them to Error 404 page
    header ("Location: 404.php");
    exit;                       // Exit the script
}
                                // Fetch user data
$user = mysql_fetch_object ($check);
mysql_close ($dblink);          // Close the database

//--------------------------------------------------------------------
// Process the information.

// You can  "require" a templated PHP file here,  or include the  HTML
// like so:
?>
<html>
<head>
<title><?php echo $user->bandname;?>s
profile on SITE NAME HERE</title>
</head>
<body>
<?php
    // This is the PHP section
    echo "Your email is: " . $user->email . "<br/>";
    echo "Your band name is: " . $user->bandname . "<br/>";
?>
<!--This is the HTML section -->
</body>
</html>



To continue, press the browser's Back button.