Welcome to WebmasterWorld Guest from 54.159.50.111

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Is this possible with PHP ?

     
7:00 pm on Aug 28, 2009 (gmt 0)

Junior Member

10+ Year Member

joined:May 23, 2002
posts:44
votes: 0


I dont have a whole lot of PHP background but can tinker with it - wanted to know if anyone could point me to a resource where I would test the following:

Need to collect a set of variables on a given page such as "pricing" and "item name", then pass these to a form without any user input. So after these hidden variables are extracted I need to submit them to another page with a form, where they could be sent after standard contact fields were filled in.

The collected data will change from page to page, but the variables will always be the same (about 10 of them). But I was thinking that variable could be represented on the page using custom tags like <price> and <itemname> for example that would surround the content on the page in order to extract it.

7:32 pm on Aug 28, 2009 (gmt 0)

Junior Member

10+ Year Member

joined:Oct 25, 2005
posts:111
votes: 0


I'm having a hard time understanding what it is exactly that you want?... Perhaps you could explain it differently?
8:03 pm on Aug 28, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:June 10, 2008
posts: 1130
votes: 0


Well if you post some code I can give you more help but it would be something like this. Create three pages called page1.php page2.php and page3.php
In page1.php put this
<html>
<?php
//we have to put this in every page
//if you don't your session variables won't work
session_start();
if($_SESSION['var']){

echo("You came from {$_SESSION['var']}<br>");

}
$_SESSION['var'] = "page 1";
?>
<body>
Go to: <a href="page1.php">page 1</a>&nbsp&nbsp
<a href="page2.php">page 2</a>&nbsp&nbsp
<a href="page3.php">page 3</a>&nbsp&nbsp

</body>
</html>

In page2.php put this
<html>
<?php
//we have to put this in every page
//if you don't your session variables won't work
session_start();
if($_SESSION['var']){

echo("You came from {$_SESSION['var']}<br>");

}
$_SESSION['var'] = "page 2";
?>
<body>
Go to: <a href="page1.php">page 1</a>&nbsp&nbsp
<a href="page2.php">page 2</a>&nbsp&nbsp
<a href="page3.php">page 3</a>&nbsp&nbsp

</body>
</html>

in page3.php put this
<html>
<?php
//we have to put this in every page
//if you don't your session variables won't work
session_start();
if($_SESSION['var']){

echo("You came from {$_SESSION['var']}<br>");

}
$_SESSION['var'] = "page 3";
?>
<body>
Go to: <a href="page1.php">page 1</a>&nbsp&nbsp
<a href="page2.php">page 2</a>&nbsp&nbsp
<a href="page3.php">page 3</a>&nbsp&nbsp

</body>
</html>

Now I just used simple static variables however, you could have as many $_SESSION['var']'s as you need i.e. $_SESSION['price'] $_SESSION['itemname'] and then set them to form input. Let me know if you need more help.

3:33 am on Aug 31, 2009 (gmt 0)

Junior Member

5+ Year Member

joined:Feb 6, 2008
posts:94
votes: 0


or you can use a switch statement:

switch(true) {

case isset($_POST['submit1']):
include("page1.php");
break;
case isset($_POST['submit2']):
include("page2.php");
break;
default:
include("home.php");

}

5:29 am on Aug 31, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:May 6, 2008
posts:2011
votes: 0


Sessions are taxing and have a user limit. I'd never suggest them unless you know the traffic level will always stay low.
1:31 pm on Aug 31, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:June 10, 2008
posts: 1130
votes: 0


What should you use over a session variable then?