...

View Full Version : need help creating member profiles



mfriedman24
03-14-2009, 09:11 AM
Hi, I'm making a website for people to join and i created the registration, login, and logout forms and to test it i have three made up test users and for some reason whenever i log in with each of them and click on the link for their individual profile --> /profile.php?id=... page only shows the first record's information, not what user logged in...how do i fix this?? thanks!

ps i'm using dreamweaver cs4

milanchheda
03-14-2009, 09:17 AM
Hi, I'm making a website for people to join and i created the registration, login, and logout forms and to test it i have three made up test users and for some reason whenever i log in with each of them and click on the link for their individual profile --> /profile.php?id=... page only shows the first record's information, not what user logged in..

It seems the userid is not passed or recieved properly.and thats why the query is always giving u the first result.
it would be better if you provide the query or the code where it is getting stucked.

mfriedman24
03-14-2009, 09:25 AM
This is the code on the profile.php page, thanks for the quick response!


<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

mysql_select_db($database_SH, $SH);
$query_Recordset1 = "SELECT * FROM Signup";
$Recordset1 = mysql_query($query_Recordset1, $SH) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

milanchheda
03-14-2009, 09:33 AM
This is the code on the profile.php page, thanks for the quick response!


<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

mysql_select_db($database_SH, $SH);
$query_Recordset1 = "SELECT * FROM Signup";
$Recordset1 = mysql_query($query_Recordset1, $SH) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

you havent recieved the $userid.

it should be as given below..add first line at top to get the id and replace your query with the query given below


$userid = $_REQUEST['id'];
$query_Recordset1 = "SELECT * FROM Signup where usreid = $userid";

mfriedman24
03-14-2009, 09:42 AM
ok i did that but two things: 1) should i put that in the login page and the profile page? and 2) when i did that for the login page i get this error message "Unknown column 'userid' in 'where clause'"

mfriedman24
03-14-2009, 09:58 AM
and now it also says unknown T_IF in line 77 (the first line under where i declare $userid)

milanchheda
03-14-2009, 10:18 AM
you need to put those 2 lines in the code which you had provided.

Basically first line will get the userid which you have passed.i.e
/profile.php?id=...

and in the query you had only done "select *" which will get you all the details of all the users.but you wanted to have details of only that user whose id is passed so put that condition

where useridcolumnname = $userid

mfriedman24
03-14-2009, 10:32 AM
ok this is my login page's code:
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

mysql_select_db($database_SH, $SH);
$query_Recordset1 = "SELECT * FROM Signup";
$Recordset1 = mysql_query($query_Recordset1, $SH) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>



this is the homepage's code that should display user information:

<?php
$userid = $_REQUEST['id']
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

mysql_select_db($database_SH, $SH);
$query_Recordset1 = "SELECT * FROM Signup where id = $userid";
$Recordset1 = mysql_query($query_Recordset1, $SH) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>

and when i test it out, i log in and it gives me this error:
Parse error: syntax error, unexpected T_IF in /home/socialh1/public_html/home.php on line 77

line 77 is the line in the homepage's code that is under $userid = $_REQUEST['id']

what should i do?

mfriedman24
03-14-2009, 10:35 AM
sorry i'm really new at this and i'm using dreamweaver



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum