Jump to content

[SOLVED] Session with images


mmarif4u

Recommended Posts

Hi guys...

I have a page where i have 3 pic buttons i store their names in sessions.

Now for example i click the image name(1001), it goes to 2nd page where the session

hold that pic name not other.

1- i want that a specific pic name go to the 2nd where it is stored in sessions.

2- I want to save that pic variable in the db. I mean just to store 1001 for that pic, not 1001.gif or

something other.

 

1stpage.php

<?php
include ('session.php');
echo "<table align=\"center\" >";
echo "<tr>";
echo "<td align=\"center\" ><img src=\"images/logo1.jpg\"></img></td>";

echo "</tr>";
echo "<tr>";
echo "<td align=\"center\" ><img src=\"images/home.gif\"></img></td>"; 

echo "</tr>";
echo "</table>";
echo "<table width=\"73.8%\">";
echo "<tr>";
echo "<td width=\"44.5%\"> </td>";
echo "<td align=\"left\" width=\"9.8%\"><a href=\"user.php\"><img src=\"{$_SESSION['1001']}\" border=\"0\"></img></a></td>";
echo "<td align=\"left\" width=\"9.8%\"><a href=\"user.php\"><img src=\"{$_SESSION['1006']}\" border=\"0\"></img></a></td>"; 
echo "<td align=\"left\" width=\"9.8%\"><a href=\"user.php\"><img src=\"{$_SESSION['1007']}\" border=\"0\"></img></a></td>";  

echo "</tr>";
echo "</table>";

?>

 

2ndpage.php

<?php

include ('session.php');
if ($_SESSION['1006'])){echo "<img src=\"images/1.jpg\">";
}else {}
?>

 

session.php

<?php
Session_start();
$_SESSION['1001']="images/1001.gif";
$_SESSION['1006']="images/1006.gif";
$_SESSION['1007']="images/1007.gif";
?>

 

Any help will be appriciated...

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/45524-solved-session-with-images/
Share on other sites

Yeh he is right.

I use array but still no luck.

Here is my code:

$package=array('1001','1006','1007');
$package[0]="images/subscribe now.gif";
$package[1]="images/subscribe now.gif";
$package[2]="images/subscribe now.gif";
$_Session['1001']=$package[0];
$_Session['1006']=$package[1];
$_Session['1007']=$package[2];

 

In the next page i start like:

session_start();
echo $session['1006'];

 

But if click on any button it doesnot show me anything.

it has to show me 1006.But nothing.

Am i right...

echo "<td align=\"left\" width=\"9.8%\"><a href=\"user.php?pic=1001\"><img src=\"{$_SESSION['1001']}\" border=\"0\"></img></a></td>";

echo "<td align=\"left\" width=\"9.8%\"><a href=\"user.php?pic=1006\"><img src=\"{$_SESSION['1006']}\" border=\"0\"></img></a></td>";

echo "<td align=\"left\" width=\"9.8%\"><a href=\"user.php?pic=1007\"><img src=\"{$_SESSION['1007']}\" border=\"0\"></img></a></td>";  

 

 

file : user.php

 

$_GET['pic'];

 

got selected image $_SESSION[$_GET['pic']];

This is recent update code :

<?php
session_start();
$_GET['pic'];
$_SESSION[$_GET['pic']];
if ($_SESSION[$_GET['pic']]==$_SESSION['1006']){echo "<img src=\"images/1.jpg\">";
}else {}
?>

 

1stpage:

<?php
session_start();
$package=array('1001','1006','1007');
$package[0]="images/subscribe now.gif";
$package[1]="images/subscribe now.gif";
$package[2]="images/subscribe now.gif";
$_SESSION['1001']=$package[0];
$_SESSION['1006']=$package[1];
$_SESSION['1007']=$package[2];

echo "<table align=\"center\" >";
echo "<tr>";
echo "<td align=\"center\" ><img src=\"images/logo1.jpg\"></img></td>";

echo "</tr>";
echo "<tr>";
echo "<td align=\"center\" ><img src=\"images/home.gif\"></img></td>"; 

echo "</tr>";
echo "</table>";
echo "<table width=\"73.8%\">";
echo "<tr>";
echo "<td width=\"44.5%\"> </td>";
echo "<td align=\"left\" width=\"9.8%\"><a href=\"user.php?pic=1001\"><img src=\"{$_SESSION['1001']}\" border=\"0\"></img></a></td>";
echo "<td align=\"left\" width=\"9.8%\"><a href=\"user.php?pic=1006\"><img src=\"{$_SESSION['1006']}\" border=\"0\"></img></a></td>"; 
echo "<td align=\"left\" width=\"9.8%\"><a href=\"user.php?pic=1007\"><img src=\"{$_SESSION['1007']}\" border=\"0\"></img></a></td>";
/*
echo "<td width=\"44.5%\"> </td>";
echo "<td align=\"left\" width=\"9.8%\"><a href=\"user.php\"><img src=\"images/subscribe now.gif\" border=\"0\"></img></a></td>";
echo "<td align=\"left\" width=\"9.8%\"><a href=\"user.php\"><img src=\"images/subscribe now.gif\" border=\"0\"></img></a></td>"; 
echo "<td align=\"left\" width=\"9.8%\"><a href=\"user.php\"><img src=\"images/subscribe now.gif\" border=\"0\"></img></a></td>";  
*/
echo "</tr>";
echo "</table>";

?>
<html><head><title>Subscribe Now</title></head>
<body >
</body>
</html>

 

But still no luck, now it show pic on every button clicked.

 

Thanks u jitesh for ur time and help.

I rearrange it and now working fine.

 

<?php
session_start();
include("include/db.php");
$_GET['pic'];
$_SESSION[$_GET['pic']];
if($_GET['pic'] == 1006){$package='1006';
}
if($_GET['pic'] == 1001){$package='1001';
}
if($_GET['pic'] == 1007){$package='1007';
}
$sql="insert into pack(package)values($package)";
$query= mysql_query($sql) or die( mysql_error()); 
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.