okay so, i'm a total newbie at php but i've been learning for a while. just recently i began to try my hand at writing scripts based off of other scripts, and then building up from there. so i based a user management script off of a registration/login script, and everything seems to work well except for two things:
1. When you view an individual user's profile, their information doesn't show up - only the information of the user thats logged in.
2. The profile information won't update even after a user edits it.
i think its something to do with the database not being able to call the information, or getting confused. i'm not quite sure. :/ but i have it all in a few different pages.
uviewscript.php:
(this is the script used to view the user pages)
PHP Code:
<?php
include_once('comerror.php');
include_once('db.php');
function user() {
echo "";
}
//dbConnect('user');
$sql_query = "SELECT * FROM user WHERE id = '".$_GET['id']."'";
$sql_id = mysql_query($sql) or die(mysql_error('A database error occurred in processing your submission.'));
$user = mysql_fetch_row($sql_id);
// $chname = $user['chname'];
// $gender = $user['gender'];
$choice=$_GET['id'];
switch($choice)
{
case "$id":
include_once ("user.php");
break;
default:
user();
}
?>
and i call the information using <?=$user['chname']?>, etc on the users' page, user.php?id=*
* = the id of the user whos page is being viewed.
aaand ueditscript.php:
(this is the script used for editing the profile)
PHP Code:
<?php
include_once('comerror.php');
include_once('db.php');
function umenu() {
echo "";
}
$ucp[0] = "charedit";
$ucp[1] = "useredit";
$choice=$_GET['ucp'];
switch($choice)
{
case "$ucp[0]":
include_once ("charedit.php");
break;
case "$ucp[1]":
include_once ("useredit.php");
break;
default:
umenu();
}
if (!isset($_POST['submit'])):
// display user editttt;
else:
// processingggg lawl
dbConnect('user');
$_SESSION['logid'] = $logid;
$_SESSION['password'] = $password;
$sql = "SELECT * FROM user WHERE
logid = '$logid' AND password = '$password'";
if (strlen($_POST['chname'])>'50') {
error('Your character name is too long.');
}
$sql = "UPDATE user SET
chname = '".$_POST['chname']."',
gender = '".$_POST['gender']."',
age = '".$_POST['age']."',
species = '".$_POST['species']."'
WHERE 'id' ='$id'";
if (!mysql_query($sql))
error('A database error occurred in processing your '.
'submission.\\nIf this error persists, please '.
'contact admin@soundtrack-howl.net.');
$chname = $_POST['chname'];
$gender = $_POST['gender'];
$age = $_POST['age'];
$species = $_POST['species'];
$cheditsuccess = " <b>You have successfully editted your character!</b> <br /> <br /> ";
endif
?>
i'm aware that i'm lacking the age and species variables in uviewscript.php XD so um yeah. again, i'm a complete newb so i might be totally overlooking something... and if you need a closer look at the other scripts or the pages themselves, take a look here:
v1.soundtrack-howl.net
if you need to log in, just PM me and I'll give you info to the test account.
feel free to point out anything that looks like it should be changed. i'm in dire need of assistance xP