Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How do I pass parameters in PHP?

Posted on 2009-07-03
6
Medium Priority
?
308 Views
Last Modified: 2012-05-07
Hi there, I'm a newbie with php and not much of a programmer, I let Dreamweaver do most of the work. I am trying to pass parameters through the URL to load a page within a page for example
aboutus.php?pageid=1 sort of thing.
I have defined the recordset and want to load the content of the page with the corresponding id.
How do I do it?
0
Comment
Question by:cokefour
6 Comments
 
LVL 11

Accepted Solution

by:
BrianMM earned 630 total points
ID: 24771358
OK something like;

if(isset($_REQUEST['pageid']) {
  // code to get the content for that page i.e. do your query with something like SELECT * from table WHERE id = $_REQUEST['pageid']
} else {
  // get some default content i.e. no pageid was passed...
}
0
 
LVL 5

Author Comment

by:cokefour
ID: 24771534
the '{' is throwing errors after [pageid]
0
 
LVL 28

Assisted Solution

by:gamebits
gamebits earned 60 total points
ID: 24771620
if(isset($_REQUEST['pageid']) {

should be

if(isset($_REQUEST['pageid'])) {  

was missing a bracket )
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 4

Assisted Solution

by:stevepicks
stevepicks earned 60 total points
ID: 24771661
try this also
<?php
$pageid= $_GET['pageid']; // or $_POST['pageid']; if u used a form to post variable
switch ($pageid) {
    case 1:
        echo "page = 1";
        break;
    case 2:
        echo "page = 2";
        break;
    default:
       echo "not a known page";
}
?>
0
 
LVL 11

Assisted Solution

by:BrianMM
BrianMM earned 630 total points
ID: 24771908
doh :) typing too quickly as usual :|
0
 
LVL 5

Author Closing Comment

by:cokefour
ID: 31599514
thanks guys
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question