$_GET problem. Please help?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
UCC_Achilles
Forum Newbie
Posts: 2
Joined: Wed Mar 25, 2009 9:45 pm

$_GET problem. Please help?

Post by UCC_Achilles »

Having problem with the following. Help would be amazing:

Code: Select all

 
<html>
<head>
<title>Untitled Document</title>
</head>
 
<body>
 
<?php
$uct = 'Hello, welcome to the home page';
$services = 'Our services include the following';
$portfolio = 'portfolio is the following';
$resources = 'resources are Here!';
$about = 'This is what we about.';
$contact = 'check it if u wanna contact';
 
?>
 
<?php
 
echo '<a href="index.php?uct=home">Index | </a>';
echo '<a href="index.php?uct=services">Services | </a>';
echo '<a href="index.php?uct=portfolio">Portfolio | </a>';
echo '<a href="index.php?uct=resources">Resources | </a>';
echo '<a href="index.php?uct=about">About | </a>';
echo "<a href='index.php?uct=contact'>Contact | </a>";
 
?>
 
<?php
 
echo $_GET['.uct.'];
 
?>
 
</body>
</html>
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: $_GET problem. Please help?

Post by Christopher »

Code: Select all

echo $_GET['uct'];
(#10850)
UCC_Achilles
Forum Newbie
Posts: 2
Joined: Wed Mar 25, 2009 9:45 pm

Re: $_GET problem. Please help?

Post by UCC_Achilles »

Code: Select all

 
<html>
<head>
<title>Untitled Document</title>
</head>
 
<body>
 
<?php
$uct = 'Hello, welcome to the home page';
$services = 'Our services include the following';
$portfolio = 'portfolio is the following';
$resources = 'resources are Here!';
$about = 'This is what we about.';
$contact = 'check it if u wanna contact';
 
?>
 
<?php
 
echo '<a href="index.php?uct=home">Index | </a>';
echo '<a href="index.php?uct=services">Services | </a>';
echo '<a href="index.php?uct=portfolio">Portfolio | </a>';
echo '<a href="index.php?uct=resources">Resources | </a>';
echo '<a href="index.php?uct=about">About | </a>';
echo "<a href='index.php?uct=contact'>Contact | </a>";
 
?>
 
<?php
 
echo $_GET['uct'];
 
?>
 
</body>
</html>
Not working. Anyone else? :S
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: $_GET problem. Please help?

Post by Christopher »

First, you're welcome. Second, yes it does now correctly echo the parameter 'uct' -- unless this page is not named index.php. Third, you really did not ask a question or specify a problem. Forth, the big red letters just make you look bad.
(#10850)
tech603
Forum Commoner
Posts: 84
Joined: Thu Mar 19, 2009 12:27 am

Re: $_GET problem. Please help?

Post by tech603 »

The only time that will display is if the url has the ?uct= parameters otherwise you wont get anything other then maybe an error on your page because you are trying to echo something that has not yet been defined.

You should really be doing something like this instead,

<?php

if(isset($_GET['uct'])){
echo $_GET['uct'];
}

?>

The above will only echo that if it actually exists.

Hope that helps.
Post Reply