homepage Welcome to WebmasterWorld Guest from 54.197.183.230
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Is this possible with PHP ?
moomelman

10+ Year Member



 
Msg#: 3980200 posted 7:00 pm on Aug 28, 2009 (gmt 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.

 

smatts9

5+ Year Member



 
Msg#: 3980200 posted 7:32 pm on Aug 28, 2009 (gmt 0)

I'm having a hard time understanding what it is exactly that you want?... Perhaps you could explain it differently?

andrewsmd

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 3980200 posted 8:03 pm on Aug 28, 2009 (gmt 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.

tr8er8

5+ Year Member



 
Msg#: 3980200 posted 3:33 am on Aug 31, 2009 (gmt 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");

}


StoutFiles

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 3980200 posted 5:29 am on Aug 31, 2009 (gmt 0)

Sessions are taxing and have a user limit. I'd never suggest them unless you know the traffic level will always stay low.

andrewsmd

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 3980200 posted 1:31 pm on Aug 31, 2009 (gmt 0)

What should you use over a session variable then?

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved