Jump to content

how to make pages like blah?user=username


rallokkcaz

Recommended Posts

<?php
//##your db script##
include("config.php");

if($_GET['uid'])
{
$id = $_GET['uid'];
$get['userdata'] = mysql_query("SELECT * FROM pokebash_users WHERE id='$id'");

$get['userdata'] = mysql_fetch_array($get['userdata']);

echo 'Username: ' .$get['userdata']['username'] .'<br />';
echo 'E-mail: ' .$get['userdata']['email'] .'<br />';
echo 'fullname: ' .$get['userdata']['fullname'];

}
else
{
//########REDIRECTS TO YOUR HOME PAGE IF UID IS NOT PRESENT IN THE URL#########
echo '<meta http-equiv="refresh" content="0;URL=index.php" />';
}
?>

That'd work I think :)

you should now use something like user.php?id=1  or any id you want
Link to comment
Share on other sites

ok here's the code
when ever i click on the link to view the profile
it sends me back to the same page with a different url
here's the page
[url=http://www.pokebash.com/user.php]http://www.pokebash.com/user.php[/url]
heres the code
[code]<? include ("header.php"); ?>

<?php
  //connect to and select db
  $conn = mysql_connect('localhost','//yes i left these blank for secrurity purposes','') or die(mysql_error());
  $db = mysql_select_db('pokebash_users',$conn) or die(mysql_error());
 
  //get a list of the info from the table to make the linkies
  $sql = "select * from maaking_users";
  $result = mysql_query($sql, $conn) or die(mysql_error());

  // for each row fetched from the results... 
  while ($list = mysql_fetch_array($result)) {
      //make the custom linkie
      echo "<font color='black'><a href= 'http://www.pokebash.com/user.php?id={$list['userid']}'>{$list['username']}</a><br>";
  } // end while

  // if the user clicked on a linkie and therefore an id exists (the is_numeric is a basic security precaution) ...
  if (is_numeric($_GET['username'])) {
      // for easier var syntax handling
      $id = $_GET['userid'];
     
     
      $sql = "select username from maaking_users where video_id = '$id'";
      $result = mysql_query($sql, $conn) or die(mysql_error());

      $videofound = mysql_num_rows($result);
      if ($videofound) {
        $user = mysql_fetch_array($result);
        include ("header.php");
echo "  ";

      } // end if found
  } // end if there was a linkie clicked
?>

<?php
//##your db script##

if($_GET['userid'])
{
$id = $_GET['userid'];
$get['userdata'] = mysql_query("SELECT * FROM pokebash_users WHERE userid='$id'");

$get['userdata'] = mysql_fetch_array($get['userdata']);

echo 'Username: ' .$get['userdata']['username'] .'
';
echo 'E-mail: ' .$get['userdata']['email'] .'
';
echo 'fullname: ' .$get['userdata']['fullname'];

}

?>[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.