Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-14-2009, 09:11 AM   PM User | #1
mfriedman24
New Coder

 
Join Date: Mar 2009
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
mfriedman24 has a little shameless behaviour in the past
need help creating member profiles

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
mfriedman24 is offline   Reply With Quote
Old 03-14-2009, 09:17 AM   PM User | #2
milanchheda
New Coder

 
Join Date: Feb 2009
Posts: 38
Thanks: 0
Thanked 1 Time in 1 Post
milanchheda is an unknown quantity at this point
Quote:
Originally Posted by mfriedman24 View Post
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.
milanchheda is offline   Reply With Quote
Old 03-14-2009, 09:25 AM   PM User | #3
mfriedman24
New Coder

 
Join Date: Mar 2009
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
mfriedman24 has a little shameless behaviour in the past
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);
mfriedman24 is offline   Reply With Quote
Old 03-14-2009, 09:33 AM   PM User | #4
milanchheda
New Coder

 
Join Date: Feb 2009
Posts: 38
Thanks: 0
Thanked 1 Time in 1 Post
milanchheda is an unknown quantity at this point
Quote:
Originally Posted by mfriedman24 View Post
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
PHP Code:
$userid $_REQUEST['id'];
$query_Recordset1 "SELECT * FROM Signup where usreid = $userid"
milanchheda is offline   Reply With Quote
Old 03-14-2009, 09:42 AM   PM User | #5
mfriedman24
New Coder

 
Join Date: Mar 2009
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
mfriedman24 has a little shameless behaviour in the past
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 is offline   Reply With Quote
Old 03-14-2009, 09:58 AM   PM User | #6
mfriedman24
New Coder

 
Join Date: Mar 2009
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
mfriedman24 has a little shameless behaviour in the past
and now it also says unknown T_IF in line 77 (the first line under where i declare $userid)
mfriedman24 is offline   Reply With Quote
Old 03-14-2009, 10:18 AM   PM User | #7
milanchheda
New Coder

 
Join Date: Feb 2009
Posts: 38
Thanks: 0
Thanked 1 Time in 1 Post
milanchheda is an unknown quantity at this point
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
Code:
where useridcolumnname = $userid
milanchheda is offline   Reply With Quote
Old 03-14-2009, 10:32 AM   PM User | #8
mfriedman24
New Coder

 
Join Date: Mar 2009
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
mfriedman24 has a little shameless behaviour in the past
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 is offline   Reply With Quote
Old 03-14-2009, 10:35 AM   PM User | #9
mfriedman24
New Coder

 
Join Date: Mar 2009
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
mfriedman24 has a little shameless behaviour in the past
sorry i'm really new at this and i'm using dreamweaver
mfriedman24 is offline   Reply With Quote
Reply

Bookmarks

Tags
member profile, member profiles, php, php member profiles, profiles

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:25 PM.


Advertisement
Log in to turn off these ads.