![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: May 2007
Posts: 52
Rep Power: 2
![]() |
isset() help
im just wondering but why won't this isset() function not working? it still inerts the values nito my MySQL database even if the comment box isnt filled out. and thanks!
here's my code: <?php
if (!isset($_POST['comment'])
{
die("Please out whole form.");
}
else
$con = mysql_connect("localhost","kishou","0973059457");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("aaabatt_mainwebsite", $con);
$name = mysql_real_escape_string($_POST['name']);
$email = mysql_real_escape_string($_POST['email']);
$comment = mysql_real_escape_string($_POST['comment']);
$sql=("INSERT INTO Comments (name, email, comment)
VALUES
('$name','$email','$comment')");
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
mysql_close($con)
?>
<?php
//Redirect Browser
header("Location: http://www.kishouvision.com/tutorials/commentshow.php");
?>
<html>
<head>
<title>
</title>
</head>
<body>
</body>
</html> |
|
|
|
|
|
#2 | |
|
Professional Programmer
Join Date: May 2006
Location: UK - London
Posts: 333
Rep Power: 3
![]() |
Re: isset() help
The variable is set but it's empty. Try using the is_empty function
__________________
Quote:
|
|
|
|
|
|
|
#3 |
|
Programming Guru
![]() ![]() |
Re: isset() help
Someone should probably edit his post to censor his MySQL password. Just because it's localhost doesn't necessarily mean its safe.
|
|
|
|
|
|
#4 |
|
Programmer
Join Date: May 2007
Posts: 52
Rep Power: 2
![]() |
Re: isset() help
|
|
|
|
|
|
#5 |
|
Programming Guru
![]() ![]() |
Re: isset() help
Thank goodness. ^_^
You had me worried. And while I'm here, to elaborate on kruptof's well-spotted catch: isset only checks to see if the variable exists. It's useful to stop a user from directly accessing the .php script (where no post data is being sent). In such an event, isset will return false for any corresponding $_POST keys. |
|
|
|
|
|
#6 | |
|
Programmer
Join Date: May 2007
Posts: 52
Rep Power: 2
![]() |
Re: isset() help
Quote:
ok now wth? i cant use print,echo, or die... ![]() |
|
|
|
|
|
|
#7 |
|
Programmer
Join Date: May 2007
Posts: 52
Rep Power: 2
![]() |
Re: isset() help
ok i figured out why lol. all i had to do was just change it to: if ($_POST['comment']==false)
hahhah wow. |
|
|
|
|
|
#8 |
|
Expert Programmer
|
Re: isset() help
|
|
|
|
|
|
#9 |
|
Programmer
Join Date: May 2007
Posts: 52
Rep Power: 2
![]() |
Re: isset() help
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| BH Hotkeys | brownhead | Visual Basic | 1 | Apr 27th, 2006 6:42 PM |