Jump to content

[SOLVED] Hmm.. Im wondering


Xyphon

Recommended Posts

add a user login form and script

 

<a href="whatever.php?id=<?php echo $_POST['id']; ?>">Member <?php echo $_POST['id']; ?></a>

 

<?php
$id = $_GET['id'];
$results = mysql_query("select * from tblName where id='$id'");
while ($row=mysql_fetch_array($results)) {

I get a Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/www/ptcrpg.awardspace.com/top.php on line 141 Error on the link.
// display database contents here
}
?>

Link to comment
Share on other sites

  • there is originally a user login form
  • a script is set-up to validate the username and password
  • the script will check the value of the username and the password; then it will compare these values against values that are already in the database
  • once these values are correct; a server side cookie is set by the login script
  • so that once you come back to the forum you still will be logged in
  • when you comeback to the forum; the forums php and mysql or sql takes the cookie and checks the database to see what the members userid is
  • then it echos/prints our the value of the userid field to the profile link which contains the "userid" query string (ie. viewprofile.php?userid=<?php echo $row['useridfield']; ?>)

Link to comment
Share on other sites

To get the cookie information (if its set) you can use

 

$_COOKIE['name']

 

for example on your login page you would want it to set a cookie

 

$username = $_POST['username'];
setcookie ('username', '$username, time() + (60*60*24));

 

$username is what the user used in the login box. That would set a cookie. Now for finding userid.

 

you would want to try

 

$query = mysql_query("SELECT user_id FROM users WHERE username = '$username'");

 

Not sure if that is what your looking for but thats how I would do it.

 

Link to comment
Share on other sites

To get the cookie information (if its set) you can use

 

$_COOKIE['name']

 

for example on your login page you would want it to set a cookie

 

$username = $_POST['username'];
setcookie ('username', '$username, time() + (60*60*24));

 

$username is what the user used in the login box. That would set a cookie. Now for finding userid.

 

you would want to try

 

$query = mysql_query("SELECT user_id FROM users WHERE username = '$username'");

 

Not sure if that is what your looking for but thats how I would do it.

 

 

I already have setcookie!

 

and Id have $query = mysql_query("SELECT user_id FROM pokemon_info");

 

But I just dont understand ANY of the get thing.

 

Like 1. The link wont work if its in a PHP FILE!!

2. It doent link to the user_id

3. It deosnt display..

 

Look here is my top

 

<?PHP
include('Connect.php');
/* If logged out */
if (!isset($_COOKIE['UserID'])) {
echo "
<html>
<title> Pokemon Trainer's Challenge RPG </title>

<head>
<style type='text/css'>
A:link { color: #AFAFAF; text-decoration: underline; }
A:visited { color: #AFAFAF; text-decoration: underline; }
A:hover { color: #D0D0D0; text-decoration: none; } 

body 
{
background-color: #000000;
background-image: url('Url here if you have a background image');
scrollbar-face-color: #000000;
scrollbar-highlight-color: #000000;
scrollbar-shadow-color: #000000;
scrollbar-darkshadow-color: #545454;
scrollbar-3d-lightcolor: #545454;
scrollbar-arrow-color: #ffffff;
scrollbar-track-color: #545454;
}

.tables
{ border: 1px solid #252525; background-color: #313131;} 
.menus
{ width: 130px; border: 0px solid #575757; background-color: #313131;} 
.content
{ border: 0px solid #707070; background-color: #4F4F4F;} 
.disclaimer
{ border: 1px solid #252525; background-color: #313131;} 

</style>



</head>


<body>
<div align='center'>
<!--BANNER-->
<table class='tables' cellpadding='0' cellspacing='0' width='750' height='180'>
<tr><td>
<center>
<font face='verdana' color='#FFFFFF' size='6'><a href='index.php'>
<img border='0' src='http://i3.tinypic.com/7xaet08.jpg'>

</font>
</tr></td>
</table>
<!--END of BANNER-->

<!--LEFT MENU-->
<table class='tables' cellpadding='4' cellspacing='0' width='750' height='250'>
<tr><td class='menus' valign='top'>
<font color='#AFAFAF' face='verdana' size='1'>
<CENTER>
<b>Main</b><br>
<a href='index.php'>Home</a><br>
<a href='register.php'>Register</a><br>
<a href='login.php'>Log in</a><br>
</CENTER>
</td>
<!--END of LEFT MENU-->


<!--CONTENT-->
<td class='content' valign='top'>
<font color='#AFAFAF' face='verdana' size='1'>
<div align='justify'>
<br>
";
}
if (isset($_COOKIE['UserID'])) {
echo "
<html>
<title> Pokemon Trainer's Challenge RPG </title>

<head>
<style type='text/css'>
A:link { color: #AFAFAF; text-decoration: underline; }
A:visited { color: #AFAFAF; text-decoration: underline; }
A:hover { color: #D0D0D0; text-decoration: none; } 

body 
{
background-color: #000000;
background-image: url('Url here if you have a background image');
scrollbar-face-color: #000000;
scrollbar-highlight-color: #000000;
scrollbar-shadow-color: #000000;
scrollbar-darkshadow-color: #545454;
scrollbar-3d-lightcolor: #545454;
scrollbar-arrow-color: #ffffff;
scrollbar-track-color: #545454;
}

.tables
{ border: 1px solid #252525; background-color: #313131;} 
.menus
{ width: 130px; border: 0px solid #575757; background-color: #313131;} 
.content
{ border: 0px solid #707070; background-color: #4F4F4F;} 
.disclaimer
{ border: 1px solid #252525; background-color: #313131;} 

</style>



</head>


<body>
<div align='center'>
<!--BANNER-->
<table class='tables' cellpadding='0' cellspacing='0' width='750' height=<tr><td>'180'>

<center>
<font face='verdana' color='#FFFFFF' size='6'><a href='index.php'>
<img border='0' src='http://i3.tinypic.com/7xaet08.jpg'>

</font>
</tr></td>
</table>
<!--END of BANNER-->

<!--LEFT MENU-->
<table class='tables' cellpadding='4' cellspacing='0' width='750' height='250'>
<tr><td class='menus' valign='top'>
<font color='#AFAFAF' face='verdana' size='1'>
<CENTER>
<b>Main</b><br>
<a href='index.php'>Home</a><br>
<a href='logout.php'>Logout</a><br>
<a href=''>Link Here</a><br><br>

<b>Catergory</b><br>
<a href=''>Link Here</a><br>
<a href=''>Link Here</a><br>
<a href=''>Link Here</a><br>
<a href=''>Link Here</a><br><br>

<b>Catergory</b><br>
<a href=''>Link Here</a><br>
<a href=''>Link Here</a><br>
<a href=''>Link Here</a><br>
<a href=''>Link Here</a><br>
</CENTER>
</td>
<!--END of LEFT MENU-->


<!--CONTENT-->
<td class='content' valign='top'>
<font color='#AFAFAF' face='verdana' size='1'>
<div align='justify'>
<br>
";
}
$ID= $_COOKIE['UserID'];

$BannedResult= mysql_query("SELECT * FROM users WHERE id='$ID'");
$BannedRows= mysql_fetch_array($BannedResult);

if($BannedRows['Banned']=='Yes')
{
echo "Sorry, you are banned. You will now be logged out, please go <a href='index.php'>back</a>.";
$usercheck = addslashes($_POST['username']);
    $passcheck = md5(addslashes($_POST['password']));
$Result1 = mysql_query("SELECT * FROM users WHERE username='$usercheck' AND password='$passcheck'");
    $Rows1 = mysql_fetch_array($Result1);
    

    $UserID = $Rows1['ID'];
setcookie("UserID", "$UserID", time() - 9999999);

include("bottom.php");
exit;
}

?>

 

Heres my viewparty so far

<?php
include('Connect.php');
include('top.php');
$userID = $_COOKIE['UserID'];
$result = mysql_query("SELECT * FROM pokemon_info");

if($row = mysql_fetch_array($result))
{
echo "<table border='1'>";
echo "<br /><br />";
echo "<tr>";
echo "<td><center>" . $row['pokemon_name'] .  "<br /><img border='0' src='" . $row['pokemon_image'] .  "'></center></td></table>";
}
include('bottom.php');
?>

Can you edit those and tell me where you put stuff so I can know for future refrences?

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.