Help - Search - Members - Calendar
Full Version: Unique Members Page, And Edit Details
Zymic Webmaster Forums > Web Design & Development > Server Side Scripting > PHP
uncled1023
Hi, i have a login and registration script already in w/ database and table. I would like a script that would show there details, and would allow them to edit those details. (name, email, username, password, country, ect..)
Banjo
Can you post your SQL query please. So i no what the names are of the fields.
uncled1023
k,

here it is, i did it manually, but it is all here.

CREATE TABLE users (
id int(10) DEFAULT '0' NOT NULL auto_increment,
username varchar(40),
pm_count int(11) DEFAULT '0',
password varchar(50),
regdate varchar(20),
email varchar(100),
website varchar(150),
location varchar(150),
show_email int(2) DEFAULT '0',
last_login varchar(20),
PRIMARY KEY(id))


yea, and my website is www4.99k.org Username: admin Password:dundee1
Banjo
Ok, i don't really have much time at the moment to make it for you because i have my GCSE's next wednesday so i have to revise. But i have a example in a project i made where it retrieves the data and you can also edit it . Iv attatched it below (its a old one i can't remember where i saved the new one i did). Ill try and make what you want if i get time biggrin.gif

Sorry

P.S in your title for this thread it says 'Unique Members Page' does that mean you want a page to show all the members aswell?
uncled1023
thanks for the help! i already have the members only page set up. i just need it to display information that they entered when they registered( already in table). And be able to edit it on a seperate page, (edit.php)
uncled1023
ok, i downloaded the files, and im using the edit file, the config, the upload, and the delete file. There arent any coding problems, but whenever i use it, i check my table from phpadmin, and it never changed... heres the codes, could you see if i changed something wrong?

config.php
CODE
<?php

$host="www4.99k.org";  //Database Host normally localhost
$user="www4_99k_org_xxxxxx";   //Database Username
$pass="xxxxxxxx";       //Database Password
$db_name="www4_99k_org_xxxxxx";//Databse Name
$tbl_name="users";  //Database table

?>


edit.php
CODE
<?php include("config.php");
    error_reporting(0);
    $db = mysql_connect($host, $user, $pass);
    mysql_select_db($db_name,$db);
    $id = $_GET['id'];
    $result = mysql_query("SELECT * FROM  users WHERE id=$id",$db);
    $myrow = mysql_fetch_array($result);
//    echo "Email ".$myrow["email"];
?>
<form action="update.php" method="post" id="editform" >
<table width="75%" border="1" align="center">
<tr>
    <td width="100%">Edit Email</td>

  </tr>
  <tr>
    <td width="19%">New Email:</td>
    <td width="81%"><input type="text" value="<?php echo $myrow['email'] ?>" name="email"></td>
  </tr>
  <tr>
    <td valign="top">Website:</td>
    <td><textarea type="text" name="website" cols=40 rows=1><?php echo $myrow['website'] ?></textarea></td>
  </tr>
<tr>
    <td>&nbsp;</td>
    <td>
    <input type="hidden" name="id" value="<?php echo $id ?>" >
    <input type="submit" name="Submit" value="Save ">
      Click<a href="java script:history.go(-1)"> Here </a>to go back</td>
  </tr>

</table>

</form>


update.php
CODE
<?php include("config.php");
$db = mysql_connect($host, $user, $pass);
mysql_select_db($db_name,$db);
    //    print_r($_POST);

    $id = $_POST['id'];
    $email = $_POST['email'];
    $website = $_POST['website'];



$sql = "UPDATE users SET email='$email',website='$website' WHERE id=$id";

    $query=mysql_query($sql);
    echo "Email and Website has been updated click";
?>
<a href="members.php"> here </a> to go back.


delete.php
CODE
<?php include("config.php"); ?>
Account was deleted click <a href="admin.php"> HERE</a> to go back
<?php
error_reporting(0);
$db = mysql_connect($host, $user, $pass);
mysql_select_db($db_name,$db);
$id = $_GET['id'];
$result = mysql_query("DELETE FROM users WHERE id=$id",$db);

?>

Banjo
How are you finding out what user is logged in?

Ill try and get what you want working for you.
Brandon
Hey about the users online page i have been useing this
call this page "usersonline.php" you need to edit to your needs.
CODE
<title>UsersOnline</title><?php
include("online.php"); //get online configuration and such
$get_online_users = mysql_query("SELECT * FROM `members` WHERE `online` >= '$offline' ORDER BY `userlevel` ASC"); //get all online users
$total_users = mysql_num_rows($get_online_users);
if($total_users == 0){ //see if anyone is logged in
    echo "No Users Online!"; //there isn't =O
}else{ //maybe....
    $i = 1; //the variable 'i' is 1
    while($online = mysql_fetch_array($get_online_users)){ //loop online users
        if(($i > 0) && ($i != $total_users)){ //see if i is the same or not of total online users
            $comma = ', '; //if it isn't then theres a comma
        }else{ //or....
            $comma = ''; //if there isn't theres no comma
        } //end check
        echo "<a href='members.php?user=$online[username]'>$online[username]</a>$comma"; //echo the online users with the comma
    } //end loop
} //end
?>

Now for the "online.php"
CODE
<?php
$logout_time = 300; //mili seconds to stay logged in
$current = time(); //current time
$offline = ($current - $logout_time); //do the math for the logout time
if($logged[username]){ //if they are logged in
    $update = mysql_query("UPDATE `members` SET `online` = '$current' WHERE `username` = '$logged[username]';"); //update their status
} //end the check and such
?>


I hope this helps
uncled1023
sorry crown, but that didnt help... i had a connection file added to it, but it still didnt work. is that the only files it uses??
uncled1023
banjo, i figured out how to post the data from the tables.

CODE
<?php

require 'db_connect.php';


if ($logged_in == 0) {
echo "You are not Logged in!";

    }

else {  

echo "Username: ",$_SESSION['username'];
?>
<br>
<?php
$qry = "SELECT full_name FROM users WHERE username = '".$_SESSION['username']."'";
$full_name = $db_object->query($qry);
$db_full_name = $full_name->fetchRow();
echo "Full Name: ",$db_full_name['full_name'];
?><br><br>
<?php
$qry = "SELECT show_email FROM users WHERE username = '".$_SESSION['username']."'";
$show_email = $db_object->query($qry);
if($show_email == 0) {
  ?>
<p>[You have chosen not to show your email]</p>
<?php      
    } else {
$qry = "SELECT email FROM users WHERE username = '".$_SESSION['username']."'";
$email = $db_object->query($qry);
$db_email = $email->fetchRow();
echo "Email: ",$db_email['email'];
}
?>
<br><br>
<?php
$qry = "SELECT website FROM users WHERE username = '".$_SESSION['username']."'";
$website = $db_object->query($qry);
$db_website = $website->fetchRow();
echo "Website: ",$db_website['website'];
?><br><br>
<?php
$qry = "SELECT regdate FROM users WHERE username = '".$_SESSION['username']."'";
$regdate = $db_object->query($qry);
$db_regdate = $regdate->fetchRow();
echo "Registration Date: ",$db_regdate['regdate'];
?><br><br>
<?php
$qry = "SELECT country FROM users WHERE username = '".$_SESSION['username']."'";
$country = $db_object->query($qry);
$db_country = $country->fetchRow();
echo "Country: ",$db_country['country'];
?><br><br>
<?php
$qry = "SELECT sig FROM users WHERE username = '".$_SESSION['username']."'";
$sig = $db_object->query($qry);
$db_sig = $sig->fetchRow();
echo "Signature: ",$db_sig['sig'];
?><br><br>
<a href="http://www4.99k.org/logout.php">Log Out</a>
<?php

}

?>


now i just need a way to edit them.
uncled1023
ok, heres a code for editing them that i belive should work.. but it doesnt. lol can you tell me whats wrong and how i can fix it?

CODE
<?php
require 'db_connect.php';

if (isset($_POST['submit'])) { // if form has been submitted
    
    if (!preg_match("/.*@.*..*/", $_POST['email']) ||
         preg_match("/(<|>)/", $_POST['email'])) {
        die('Invalid e-mail address.');
    }

  

    if (!get_magic_quotes_gpc()) {
        $_POST['full_name'] = addslashes($POST['full_name']);
        $_POST['email'] = addslashes($_POST['email']);
        $_POST['website'] = addslashes($_POST['website']);
        $_POST['country'] = addslashes($POST['country']);
        $_POST['sig'] = addslashes($POST['sig']);
    }

    $insert = "UPDATE users SET(
            full_name,
            email,
            website,
            country,
            sig)
            VALUES (
            '".$_POST['full_name']."',
            '".$_POST['email']."',
            '".$_POST['website']."',
            '".$_POST['country']."',
            '".$_POST['sig']."',  
            'Never')";

    $add_member = $db_object->query($insert);

    if (DB::isError($add_member)) {
        die($add_member->getMessage());
    }

    $db_object->disconnect();
?>


<p>Thank you, your information has been Updated.  You may now go back to your <a href="members.php" title="members">Profile</a>.</p>

<?php

} else {    // if form hasn't been submitted

?>
<h1>Edit Profile Information</h1>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table align="center" border="1" cellspacing="0" cellpadding="3">
<tr><td>Full Name:</td><td>
<input type="text" name="full_name" maxlength="40">
</td></tr>
<tr><td>E-Mail:</td><td>
<input type="text" name="email" maxlength="100">
</td></tr>
<tr><td>Website:</td><td>
<input type="text" name="website" maxlength="150">
</td></tr>
<tr><td>Country:</td><td>
<input type="text" name="country" maxlength="150">
</td></tr>

<tr><td>Signature:</td><td>
<textarea class='tbox' style='width:99%' name='sig' cols='10' rows='4' onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);'>
</textarea><br />
    <tr><td colspan="2" align="right">
<input type="submit" name="submit" value="Edit">
</td></tr>
</table>
</form>


<?php

}

?>
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2012 Invision Power Services, Inc.