nav33n 472 Purple hazed! Team Colleague Featured Poster

No probs man.. But the sad thing is, the problem has not been solved. Anyways, break down the code and debug them. All the best..

Cheers,
Naveen

nav33n 472 Purple hazed! Team Colleague Featured Poster

Yep. Sure.. How did you do it ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

I dont see any html tag or an echo statement above session_start. I cant see why it isn't working. ob_start isn't working either. I don't know. We need to wait for someone else to see where the error is or you have to break down your code and start debugging part by part.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Its expensive, but the features are good. Some features are Syntax highlighting,easy debugging, automatic end tag insertion, analysing the code, etc.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Yep. But you don't need a br. AND you need to keep it like this. echo <a href=\"details.php?firstname=$first&lastname=$last\">$first." ".$last</a>";

nav33n 472 Purple hazed! Team Colleague Featured Poster

dang.. There is a blank space on line 7. Remove it and try again.

Edit: Remove all the blank spaces.

nav33n 472 Purple hazed! Team Colleague Featured Poster

what ? test and user ARE the values for firstname and lastname.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Huh! why does it work when you click the back button and enter again ? Strange. Anyway, Check if this will solve the error.

<?php
ob_start();
mysql_connect('localhost','root','');
mysql_select_db('administration');
session_name ('YourVisitID');
session_start();

if (isset($_POST['username'])) {
  $loginUsername=$_POST['username'];
  $loginPassword=$_POST['password']; 
  $MM_redirectLoginSuccess = "test2.php";
  //$MM_redirectLoginSuccess = "validated.php";
  $MM_redirectLoginFailed = "admin.php";
  $MM_redirecttoReferrer = true;
  
  $errors = array();
  
	 if(empty($_POST['username'])) {
		$errors[] = 'You think whom going to fill up the USERNAME for you?';
	 }	
	 if(empty($_POST['password'])) {
		$errors[] = 'You think whom going to fill up the PASSWORD for you?';
	 }	
	if (empty($errors)) {
	
  $loginUsername = get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername);
  $password = get_magic_quotes_gpc() ? $password : addslashes($password);
  $LoginRS_query = "SELECT user_id, first_name FROM adminprofile WHERE username='$loginUsername' AND password='$loginPassword'";
  $LoginRS = mysql_query($LoginRS_query) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  $record_row = mysql_fetch_array($LoginRS);
  
  if ($loginFoundUser) {
    
	//session_name ('YourVisitID');
	//session_start();
	$_SESSION['user_id'] = $record_row['user_id'];
	$_SESSION['first_name'] = $record_row['first_name'];

    echo "<script type='text/javascript'>location.href='$MM_redirectLoginSuccess';</script>";
	exit();
	}
  else {
  
    echo "<script type='text/javascript'>location.href='$MM_redirectLoginFailed';</script>";
}
}
mysql_close();
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
		
<html>
<head>
	<title>Cycle Tracks Portal - Administrator's Page</title>
		<style type="text/css" media="all">@import "images/style.css";
</style>
	<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="rss/" />
</head>

<body>
<div class="content">
	<div class="topmenu">
		<div class="date_"><? echo date('l dS \of F Y'); ?></div>
	</div>
	
	<div id="submenu">
	</div>
		
	<div class="cycle">
		<div class="title" style="text-align: center; width: 179px">
			<sup>
			<span class="copynresv">©</span></sup>CYCLE TRACKS<sup><span class="copynresv">®</span></sup></div>
		<div class="slogan" style="width: 223px; height: 11px">&quot;We are ONE of the BEST and NOT like the REST!</div>
	</div>
	
	<div class="nav">
		<ul>
			<li><a href="#">HOME</a> | </li> 
			<li><a href="#">INSTRUCTIONS</a> | </li>
			<li><a href="#">FIND</a> | </li> 
			<li><a href="#">DISPLAY</a> | </li>
			<li><a href="#">ADMIN</a> | …
nav33n 472 Purple hazed! Team Colleague Featured Poster

for example, If you have a hyperlink, <a href="page1.php?firstname=test&lastname=user">Click here</a>. When you click it, in page1.php, you need to write,

$firstname = $_GET['firstname'];
$lastname = $_GET['lastname'];
nav33n 472 Purple hazed! Team Colleague Featured Poster

Is that it ? Can you post the code of admin.php for one last time ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

Welcome to Daniweb Vega ! :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Welcome Pat ! :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Welcome to Daniweb !

nav33n 472 Purple hazed! Team Colleague Featured Poster

Welcome to Daniweb Fred.. And Nancy, Dont advertise!

nav33n 472 Purple hazed! Team Colleague Featured Poster

Welcome to Daniweb!

nav33n 472 Purple hazed! Team Colleague Featured Poster

Welcome!

nav33n 472 Purple hazed! Team Colleague Featured Poster

When somebody clicks on a name, get the name using $_GET. Then use it in the query. But, I don't recommend using firstname to get the details, because there can be more than 1 people with the same first name.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Cool.. atleast there is some progress.. Well, Don't redirect to the next page if there are any errors. When you say 'there will be errors on the admin.php', what errors are you talking about ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

You are welcome ! :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Thats because theres no value in $first and $last.

nav33n 472 Purple hazed! Team Colleague Featured Poster
<?php
include 'config.php';
include 'opendb.php';

$rowsPerPage = 5;
$pageNum = 1;

if(isset($_GET['page']))
{
$pageNum = $_GET['page'];
}

$offset = ($pageNum - 1) * $rowsPerPage;

$query = " SELECT FName, LName FROM user " .
" LIMIT $offset, $rowsPerPage";
$result = mysql_query($query) or die('Error, query failed');

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$first=$row['FName'];
$last=$row['LName'];
echo "a href=\"Details.php?first=$first&last=$last\">";
if(mysql_num_rows($result)<1){
echo "No Results!";
}
}
include 'closedb.php';
?>
nav33n 472 Purple hazed! Team Colleague Featured Poster

hello,
im a new user :S

and i need help !!

i need to use the hyperlink value as variable

<a href="Details.php"><?php echo "$first" . " " . "$last<br>";?></a>
i need to get $first and $fast
to use them later in the code
so how could i?

plz reply fast

best regards
zanzo

Can you post your code ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

Yeah.. Check if there is a folder called tmp in program files\xampp. Also, change \ to /.

nav33n 472 Purple hazed! Team Colleague Featured Poster

umm.. I m not sure if this will help you. But, check session.save_path exists. And, As I see in my php.ini, its,

session.save_path = "c:/wamp/tmp"

. Notice the forward slashes (and not the path).

nav33n 472 Purple hazed! Team Colleague Featured Poster

I checked your code. I have a table called user and I checked if it works. And it does! Your code works on my computer. Check if cookies are enabled. See, this is what I have. This is admin.php

<?php
session_name ('VisitID');
session_start();

// connection to MySQL server
mysql_connect('localhost','root','');
mysql_select_db('seacon');

if (isset($_POST['username'])) {
  $loginUsername=$_POST['username'];
  $loginPassword=$_POST['password']; 
  //$MM_redirectLoginSuccess = "test2.php";
  $MM_redirectLoginSuccess = "validated.php";
  $MM_redirectLoginFailed = "admin.php";
  $MM_redirecttoReferrer = true;
  
  $errors = array();
  
	 if(empty($_POST['username'])) {
		$errors[] = 'You think whom going to fill up the USERNAME for you?';
	 }	
	 if(empty($_POST['password'])) {
		$errors[] = 'You think whom going to fill up the PASSWORD for you?';
	 }	
	if (empty($errors)) {
	
  $loginUsername = get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername);
  $password = get_magic_quotes_gpc() ? $password : addslashes($password);
  
  $LoginRS_query = "SELECT user_id, first_name FROM user WHERE login_name='$loginUsername' AND password='$loginPassword'";
  $LoginRS = mysql_query($LoginRS_query) or die(mysql_error());
  
  $loginFoundUser = mysql_num_rows($LoginRS);
  $record_row = mysql_fetch_array($LoginRS);
  $user_id = $record_row['user_id'];
  $first_name = $record_row['first_name'];
  
  if ($loginFoundUser) {
   	//session_name ('VisitID');
	//session_start();
	$_SESSION['user_id'] = $record_row['user_id'];
	$_SESSION['first_name'] = $record_row['first_name'];
	
    echo "<script type='text/javascript'>location.href='$MM_redirectLoginSuccess';</script>";
	exit();
	}
  else {
  
    echo "<script type='text/javascript'>location.href='$MM_redirectLoginFailed';</script>";
}
}
mysql_close();
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
		
<html>
<head>
	<title>Cycle Tracks Portal - Administrator's Page</title>
		<style type="text/css" media="all">@import "images/style.css";
</style>
	<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="rss/" />
</head>

<body>
<div class="content">
	<div class="topmenu">
		<div class="date_"><? echo date('l dS \of F Y'); ?></div>
	</div>
	
	<div id="submenu">
	</div>
		
	<div class="cycle">
		<div class="title" style="text-align: center; width: 179px">
			<sup>
			<span class="copynresv">©</span></sup>CYCLE TRACKS<sup><span class="copynresv">®</span></sup></div>
		<div class="slogan" style="width: 223px; height: 11px">&quot;We are ONE of the BEST and NOT like …
nav33n 472 Purple hazed! Team Colleague Featured Poster

Rein
Force
mint

Hexadecimal

nav33n 472 Purple hazed! Team Colleague Featured Poster

As I said earlier, You shouldn't have any output, not an echo/print statement or a html tag before session_start. Do 1 thing. put session_name and session_start on top of the page.

nav33n 472 Purple hazed! Team Colleague Featured Poster

You can't print anything before session_start. Thats why you are getting those errors. And as I see it, its assigning the values to the session variables. Comment the print/echo lines and try redirecting it to a dummy page. If that doesn't work, I dunno what else to try/recommend.

nav33n 472 Purple hazed! Team Colleague Featured Poster

ah! then thats not a problem. Just get the image name from the table and then concat it with $path="PEOPLE/".$peopleid."/".$imagename !

nav33n 472 Purple hazed! Team Colleague Featured Poster

When you upload the file, you get the path. For, eg,
folder/test/image.jpg. Upload that to the table. You can keep the image name for your reference though.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Nope. You need to open php.ini file. Look for smtp and enter a valid smtp server address. If you don't have one, contact your system administrator or your ISP.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Yep! and also replace while($monster[monster_id]) with while($monster['monster_id'])

nav33n 472 Purple hazed! Team Colleague Featured Poster

If you had stored the path, it would have been easy to unlink that file. Just get the path from the table and unlink that 'path'.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Strange. Its storing the values in the session variable. But its not passing it to the next page ? I am lost !

nav33n 472 Purple hazed! Team Colleague Featured Poster
$LoginRS_query = "SELECT user_id, first_name FROM adminprofile WHERE username='$loginUsername' AND password='$loginPassword'";
  $LoginRS = mysql_query($LoginRS_query) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  $record_row = mysql_fetch_array($LoginRS);
  $user_id = $record_row['user_id'];
  $first_name = $record_row['first_name'];
  print "User id is :". $user_id;
  print "First name is :". $first_name;
  
  if ($loginFoundUser) {
    
	session_name ('YourVisitID');
	session_start();
	$_SESSION['user_id'] = $record_row['user_id'];
	$_SESSION['first_name'] = $record_row['first_name'];
echo $_SESSION['first_name'];
echo $_SESSION['user_id'];
	//$_SESSION['agent'] = //md5($_SERVER['HTTP_USER_AGENT']);
	//header( "Location: validated.php" );
    //echo "<script type='text/javascript'>location.href='$MM_redirectLoginSuccess';</script>";
	exit();

Does this print the values ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

Use while($monster['monster_id']) instead of while($monster[monster_id]) .

And something is wrong with this line.

<td width="25%"><?php echo '<img src="'.$monster" alt=".$monster_name.">; ?></td>

nav33n 472 Purple hazed! Team Colleague Featured Poster

See this , Example 2.

nav33n 472 Purple hazed! Team Colleague Featured Poster

hey man untill now i am using the localhost , so i want to know if its possible to send an email from the localhost server (which is Apache server).

You need to configure your apache to send mail. You need a valid smtp server to send a mail. You can get smtp server ip from your Internet service provider (If they are providing any).

nav33n 472 Purple hazed! Team Colleague Featured Poster

Well, It has to work. I don't know/see why its not working. Try replacing location.href with header. See if values are assigned to session variables in page1 itself. Print $_SESSION and $_SESSION in page 1 before redirecting.

nav33n 472 Purple hazed! Team Colleague Featured Poster
$LoginRS_query = "SELECT user_id, first_name FROM adminprofile WHERE username='$loginUsername' AND password='$loginPassword'";
  $LoginRS = mysql_query($LoginRS_query) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  $record_row = mysql_fetch_array($LoginRS);
  //$user_id = $record_row['user_id'];
  //$first_name = $record_row['first_name'];
  //print "User id is :". $user_id;
  //print "First name is :". $first_name;
  
  if ($loginFoundUser) {
    
	session_name ('YourVisitID');
	session_start();
	$_SESSION['user_id'] = $record_row['user_id'];
	$_SESSION['first_name'] = $record_row['first_name'];

Even this not working.

It HAS to work. Is it entering the loop if($loginFoundUser) ? Soon after you assign the values to the session variables print it out. print_r($_SESSION). Tellme if its assigning the values to the session variables. :S

nav33n 472 Purple hazed! Team Colleague Featured Poster

Great.. Now comment this line and assign $user_id and $first_name value to session variables. Then just to check if this works, redirect to a dummy script and just print out the session values in the dummy script.
And, you can't say session doesn't work, because, in the other example you tried out, sessions worked. So, I believe something is wrong with the script.
P.S, Can you post the latest code of both the scripts ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

-706

nav33n 472 Purple hazed! Team Colleague Featured Poster

Drill
Bit
bill

Enterprise

nav33n 472 Purple hazed! Team Colleague Featured Poster

Do one thing. Before assigning it to the session, print out its value. ie.,

$LoginRS_query = "SELECT user_id, first_name FROM adminprofile WHERE username='$loginUsername' AND password='$loginPassword'";
  $LoginRS = mysql_query($LoginRS_query) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  $record_row = mysql_fetch_array($LoginRS);
$user_id = $record_row['user_id'];
$first_name = $record_row['first_name'];
  print "User id is :". $user_id;
print "First name is :". $first_name;

See what it prints ! Then assign $user_id and $first_name to the session.

nav33n 472 Purple hazed! Team Colleague Featured Poster
$LoginRS_query = "SELECT user_id, first_name FROM adminprofile WHERE username='$loginUsername' AND password='$loginPassword'";
  $LoginRS = mysql_query($LoginRS_query) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  $record_row = mysql_fetch_array($LoginRS);
  
  if ($loginFoundUser) {
    
	session_name ('YourVisitID');
	session_start();
	$_SESSION['user_id'] = $record_row[0];
	$_SESSION['first_name'] = $record_row[1];

This is correct. And yes, in validated.php, you just can check if the session variables is set.
So, instead of if (!isset($_SESSION['agent']) OR ($_SESSION['agent'] != md5($_SERVER['HTTP_USER_AGENT'])) ) { , you can check,

if(! isset($_SESSION['user_id']) || ! isset($_SESSION['first_name'])) { // sesssion not set, redirect to error page
}
nav33n 472 Purple hazed! Team Colleague Featured Poster

Display the link only if the user is admin. Don't display the link for normal users.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Welcome to Daniweb mom_of_3 ! php is pretty easy to learn !

nav33n 472 Purple hazed! Team Colleague Featured Poster

:) Welcome to Daniweb!

nav33n 472 Purple hazed! Team Colleague Featured Poster

I see an error in this part of the code.

function getExecTime()
    {
      return round(($this->getMicroTime() - $this->timer) * 1000) / 1000);
    }

Another ) is missing in the return. Check if that solves your problem.

nav33n 472 Purple hazed! Team Colleague Featured Poster

umm.. Are you using php 5+ on apache 2.0+ ? By default, mysql service is disabled in php5. You need to add 2 lines in httpd.conf file in apache/conf.

LoadModule php5_module php5apache2.dll
AddType application/x-httpd-php .php

Open php.ini and uncomment mysql extension. Check the extension_dir folder in php.ini. Specify the right path of ext directory in php. ( eg. c:/php/ext). Copy libmysql.dll from php folder to system32 folder. Thats it. Restart apache.

Cheers,
Naveen