simple but not working
Posted: Wed Feb 25, 2009 11:14 am
Hi I'm a newbie and i have a problem this thing i'm doing. Here's the code
This is what I want to achieve:
1. The page loads with the Please enter your name bit
2. If no name is entered, the page should be reloaded and the user presented with the same thing. (echo $_SERVER['PHP_SELF'])
3. When a name is provided, then the else statement should load, that is "Your Name: {URL.Name} and then what follows.
The problem i have is that whether or not i enter a name, I still get the "Your Name:..." part under the else statement. Is my control statement wrong?
Code: Select all
<body>
<?php if (!isset($_GET['name'])): ?>
<!-- No name has been provided so we prompt the user -->
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
<label>Please enter your name:<input type="text" name="name" /></label>
<input type="submit" value="GO"/>
</form>
<?php else: ?>
<p>Your name: <?php echo $_GET['name']; ?></p>
<p>This paragraph contains a <a href="welcome.php?name=
<?php echo urlencode($_GET['name']);?>">link</a> that passes the name
variable on to the next document.
</p>
<?php endif; ?>
</body>1. The page loads with the Please enter your name bit
2. If no name is entered, the page should be reloaded and the user presented with the same thing. (echo $_SERVER['PHP_SELF'])
3. When a name is provided, then the else statement should load, that is "Your Name: {URL.Name} and then what follows.
The problem i have is that whether or not i enter a name, I still get the "Your Name:..." part under the else statement. Is my control statement wrong?