<?php
// create short names for variables
$name = $POST['name'];
$password = $POST['password'];
if (empty($name) || empty($password)) {
// Visitor needs to enter a name and password
?>
<h1>Please Log In</h1>
This page is secret.
<form method="post" action="secret.php">
<table border="1">
<tr>
<th>Username</th>
<td><input type="text" name="name" /></td>
</tr>
<tr>
<th>Password</th>
<td><input type="password" name="password" /></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="Log In" />
</td>
</tr>
</table>
</form>
<?php
}
else if ($name=='user'&&$password=='pass') {
//visitor's name and passowrd combination are correct.
echo '<h1>Here it is!</h1>';
echo 'I bet you are glad you can see this secret page.';
}
else {
//visitor's name ansd password combination are not correct
echo '<h1>Go Away!';
echo 'You are not authorized to view this resource.';
}
?>
Form not working
Whether you're a seasoned veteran or a struggling beginner, Web Radiance is the web development and web design forum for you. You'll find answers to all your HTML, CSS, SEO, and Programming needs. Pull up a chair and stay awhile.
Page 1 of 1
Form not working
#1
Posted 15 January 2009 - 10:39 AM
I even went and grabbed the code that came with the book and the author's version isn't working either. Offhand not seeing anything that sticks out as being wrong. The post variables seem to be obviously not getting passed as it always displays the form.
#2
Posted 15 January 2009 - 11:03 AM
This:
You need to use:
It's quite worrying that a book would contain such a fundamental error...
$POST['name'];is not valid!
You need to use:
$_POST['name'];
It's quite worrying that a book would contain such a fundamental error...
QUOTE(benbramz @ Aug 17 2007, 07:44 AM) Ive noticed that quite a few people are now adding quotes from the board into their signature. I think its started an new web-radiance craze.. :P
#3
Posted 15 January 2009 - 09:53 PM
Sirkent, on Jan 15 2009, 12:03 PM, said:
This:
You need to use:
It's quite worrying that a book would contain such a fundamental error...
$POST['name'];is not valid!
You need to use:
$_POST['name'];
It's quite worrying that a book would contain such a fundamental error...
Actually, the missing underscore was my error. The book's downloaded version of the code doesn't even use the POST variables. It was just using this...
if(!isset($name)&&!isset($password))
Which again, didn't seem to work.
I do have two different editions of the same book, so I'm wondering if the CD I grabbed the code from was from the older edition.
#4
Posted 16 January 2009 - 04:00 AM
Possibly - just using $name involves having PHP's register_global's setting set to 'on', which has been regarded as a dangerous thing to do for the past several years.
QUOTE(benbramz @ Aug 17 2007, 07:44 AM) Ive noticed that quite a few people are now adding quotes from the board into their signature. I think its started an new web-radiance craze.. :P
#5
Posted 17 January 2009 - 08:35 AM
And on that note, I would recommend scrapping that book. Any book that is relying on outdated, non-secure methods is probably not a good book to be learning from.
<a href="http://www.jaypan.com" target="_blank">Jaypan</a>
<a href="http://www.dudes-japan.com" target="_blank">Dudes Japan</a>
<a href="http://www.dudes-japan.com" target="_blank">Dudes Japan</a>
#6
Posted 17 January 2009 - 04:51 PM
haku, on Jan 17 2009, 08:35 AM, said:
And on that note, I would recommend scrapping that book. Any book that is relying on outdated, non-secure methods is probably not a good book to be learning from.
FYI, the book is "PHP and MySQL Web Development" which generally gets great reviews. I actually just looked up the old version of the book(2nd ed., 2003) I have and found out that's the CD I used for the code archive. I somewhat moved recently so I have no idea where the CD for the more current book(3rd ed.) is at. The publisher doesn't have a downloadable code archive either.
#7
Posted 19 January 2009 - 04:49 AM
It was a good book when I used it - about 5 years ago. Now I wouldn't be so sure, but if you read up on the newer methods and security suggestions then I think you'll be fine.
QUOTE(benbramz @ Aug 17 2007, 07:44 AM) Ive noticed that quite a few people are now adding quotes from the board into their signature. I think its started an new web-radiance craze.. :P
#9
Posted 14 March 2011 - 01:05 AM
Your support is much appreciated.
It works now !!!
It works now !!!
Share this topic:
Page 1 of 1


Help
This topic is locked
MultiQuote










