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 11-20-2006, 09:13 PM   PM User | #1
jl9148
New Coder

 
Join Date: Nov 2006
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
jl9148 is an unknown quantity at this point
changing all '&id=' to '&sn=' in php script

hello.

i have a php member script and whenever you view other members' profile, the url is member/member&id=usernamehere.

how can i change all &id= to &sn= for html validation sake?

below is the PHP code i use for member.php
PHP Code:
<?php

$id 
mysql_real_escape_string $_GET['id'] );

if ( isset ( 
$id ) ) {
$result mysql_query "SELECT * FROM users WHERE username='$id'" );
$member mysql_fetch_array $result );
}

$file_title "Member Profile:split:$member[username]";

function 
DisplayInfo$header$content ) {
global 
$sitetitle$member;

echo 
"<tr><td><b>$header</b></td><td width='3'></td><td>";

if ( empty ( 
$member[$content] ) ) {
echo 
"Not Available";
} else {

switch ( 
$content ) {
case 
"registered_on":
echo 
DisplayDate"$member[registered_on]""M d Y, h:i A""1" );
break;

case 
"last_activity_time":
echo 
DisplayDate"$member[last_activity_time]""M d Y, h:i A""1" );
break;

case 
"timezone":
if ( 
$member[dst] == ) {
$timezone = ($member[timezone]+date("I"));
} elseif ( 
$member[dst] == ) {
$timezone $member[timezone];
}
$zone 3600*($timezone-2);
echo 
gmdate 'h:i A'time() + $zone );
break;

case 
"last_activity_url":
if ( ( 
time() - $member[last_activity_time] ) <= 300 ) {
echo 
"<font color='green'>Online</font>";
} else {
echo 
"<font color='red'>Offline</font>";
}
break;

case 
"email_address":
echo 
"<a href='mailto: $member[email_address]'>Send an Email</a>";
break;

case 
"website":
if ( 
ereg "www.|http://."$member['website'] ) ) {
echo 
"<a href='$member[website]' target='_blank'>Visit</a>";
} else {
echo 
"<a href='http://$member[website] target='_blank'>Visit</a>";
}
break;

case 
"aim":
$user_aim str_replace " ""+"$member[aim] );
$aim_site_name str_replace " ""+"$sitetitle );
echo 
"<a href='aim:goim?screenname=$user_aim&message=Hi!+I+saw+you+from+$aim_site_name'>$member[aim]</a>";
break;

case 
"gender":
if ( 
$member[gender] == "m" ) {
echo 
"Male";
} elseif ( 
$member[gender] == "f" ) {
echo 
"Female";
} else {
echo 
"Not Telling";
}
break;

case 
"bday_month":
if ( ( 
$member[bday_month] == "-" && $member[bday_day] == "-" ) || ( $member[bday_month] != "-" && $member[bday_day] == "-" ) ) {
echo 
"Not Available";
} elseif ( 
$member[bday_month] == "-" && $member[bday_day] != "-" ) {
echo 
$member[bday_month];
} else {
echo 
"$member[bday_month] $member[bday_day]";
}
if ( !empty ( 
$member[bday_year] ) ) {
echo 
", $member[bday_year]";
}
break;

default:
echo 
"$member[$content]";

echo 
"</td></tr>";
}

}

if ( isset ( 
$id ) && !empty ( $id ) && mysql_num_rows $result ) > && ( eregi "^[a-z0-9\-_\.]+$"$id ) ) ) {
echo 
"<center><b>Viewing Profile: $member[username]</b><p>";
if ( empty ( 
$member[avatar] ) ) {
echo 
"<img src='$site_url/$script_folder/images/avatars/none.gif' width='60' height='60'>";
} else {
list ( 
$avatar_width$avatar_height ) = getimagesize "$member[avatar]" );
if ( 
$avatar_width 60 || $avatar_height 60 ) {
echo 
"<img src='$member[avatar]'>";
} else {
echo 
"<img src='$member[avatar]'>";
}
}
echo 
"<p></center>";
?>
<table width="100%" cellpadding="0" cellspacing="0"><tr>
<td width="49%">

<fieldset>
<legend class="main">Statistics</legend>
<table cellpadding="0" cellspacing="5" class="main" align="center">
<?php 
DisplayInfo
$header="Joined"$content="registered_on" ); 
DisplayInfo$header="Posts"$content="posts" ); 
DisplayInfo$header="Last Active"$content="last_activity_time" ); 
DisplayInfo$header="User's Time"$content="timezone" ); 
DisplayInfo$header="Status"$content="last_activity_url" ); 
?>
</table>
</fieldset>

</td>
<td width="5"></td>
<td width="49%">

<fieldset>
<legend class="main">Contact Information</legend>
<table cellpadding="0" cellspacing="5" class="main" align="center">
<?php 
DisplayInfo
$header="Email"$content="email_address" ); 
DisplayInfo$header="Website"$content="website" ); 
DisplayInfo$header="MSN"$content="msn" ); 
DisplayInfo$header="AIM"$content="aim" ); 
echo 
"<tr><td><b>PM</b></td><td width='3'></td><td><a href='$site_path/pm_compose&to=$member[username]'>Send PM</a><td></tr>";
?>
</table>
</fieldset>

</td>
</tr></table>


<table height="7"><tr><td></td></tr></table>


<table width="100%" cellpadding="0" cellspacing="0"><tr>
<td width="49%">

<fieldset>
<legend class="main">Personal Information</legend>
<table cellpadding="0" cellspacing="5" class="main" align="center">
<?php 
DisplayInfo
$header="Gender"$content="gender" ); 
DisplayInfo$header="Birthday"$content="bday_month" ); 
DisplayInfo$header="Location"$content="location" ); 
?>
</table>
</fieldset>

</td>
<td width="5"></td>
<td width="49%" valign="top">

<fieldset>
<legend class="main">Additional Information</legend>
<table height="55" cellpadding="0" cellspacing="5" class="main" align="center">
<?php 
if ( empty ( $member[biography] ) ) {
echo 
"<tr><td style='text-align: justify'>$member[username] has not written anything about ";
if ( 
$member[gender] == "m" ) {
echo 
"himself";
} elseif ( 
$member[gender] == "f" ) {
echo 
"herself";
} else {
echo 
"himself/herself";
}
echo 
".</td></tr>";
} else {
echo 
"<tr><td style='text-align: justify'>$member[biography]<td></tr>";
}
?>
</table>
</fieldset>

</td>
</tr></table>
<?php
} else {
echo 
"<center>There are no users in our database with that username</center>";
}
?>
jl9148 is offline   Reply With Quote
Old 11-21-2006, 07:23 AM   PM User | #2
SeeIT Solutions
Regular Coder

 
Join Date: May 2005
Posts: 563
Thanks: 0
Thanked 3 Times in 3 Posts
SeeIT Solutions is on a distinguished road
PHP Code:
$id mysql_real_escape_string $_GET['sn'] ); 
Then use member/member&sn=usernamehere. as the url.
__________________
Design Portfolio
SeeIT Solutions is offline   Reply With Quote
Old 11-21-2006, 09:36 AM   PM User | #3
GJay
Senior Coder

 
Join Date: Sep 2005
Posts: 1,791
Thanks: 5
Thanked 36 Times in 35 Posts
GJay is on a distinguished road
the validator will be complaining about the use of literal &s, not the 'id' after it. Instead of &, you should use &amp;
GJay is offline   Reply With Quote
Old 11-22-2006, 01:11 AM   PM User | #4
jl9148
New Coder

 
Join Date: Nov 2006
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
jl9148 is an unknown quantity at this point
Quote:
Originally Posted by GJay View Post
the validator will be complaining about the use of literal &s, not the 'id' after it. Instead of &, you should use &amp;
omg that made my errors from 27 to 2 in the validation checker
jl9148 is offline   Reply With Quote
Old 11-22-2006, 05:07 AM   PM User | #5
SeeIT Solutions
Regular Coder

 
Join Date: May 2005
Posts: 563
Thanks: 0
Thanked 3 Times in 3 Posts
SeeIT Solutions is on a distinguished road
Having a site validate isn't all that good. Don't live by the validation.
__________________
Design Portfolio
SeeIT Solutions is offline   Reply With Quote
Reply

Bookmarks

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:05 AM.


Advertisement
Log in to turn off these ads.