Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 23rd, 2008, 10:23 AM   #1
kishou
Programmer
 
Join Date: May 2007
Posts: 52
Rep Power: 2 kishou is on a distinguished road
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>
kishou is offline   Reply With Quote
Old Jan 23rd, 2008, 10:29 AM   #2
kruptof
Professional Programmer
 
kruptof's Avatar
 
Join Date: May 2006
Location: UK - London
Posts: 333
Rep Power: 3 kruptof is on a distinguished road
Re: isset() help

The variable is set but it's empty. Try using the is_empty function
__________________
Quote:
When I was young it seemed that life was so wonderful,a miracle, oh it was beautiful, magical.
Now watch what you say or they'll be calling you a radical,a liberal, oh fanatical, criminal. Oh won't you sign up your name,we'd like to feel you're acceptable, respectable, oh presentable, a vegetable
kruptof is offline   Reply With Quote
Old Jan 23rd, 2008, 1:06 PM   #3
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 2,034
Rep Power: 6 Sane will become famous soon enough
Send a message via MSN to Sane
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.
Sane is online now   Reply With Quote
Old Jan 23rd, 2008, 1:30 PM   #4
kishou
Programmer
 
Join Date: May 2007
Posts: 52
Rep Power: 2 kishou is on a distinguished road
Re: isset() help

Quote:
Originally Posted by Sane View Post
Someone should probably edit his post to censor his MySQL password. Just because it's localhost doesn't necessarily mean its safe.
oh thats no my username or password.
kishou is offline   Reply With Quote
Old Jan 23rd, 2008, 1:37 PM   #5
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 2,034
Rep Power: 6 Sane will become famous soon enough
Send a message via MSN to Sane
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.
Sane is online now   Reply With Quote
Old Jan 23rd, 2008, 4:45 PM   #6
kishou
Programmer
 
Join Date: May 2007
Posts: 52
Rep Power: 2 kishou is on a distinguished road
Re: isset() help

Quote:
Originally Posted by Sane View Post
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.
lol. i think i'll just use if (empty ($_POST['comment')
ok now wth? i cant use print,echo, or die...
kishou is offline   Reply With Quote
Old Jan 23rd, 2008, 8:26 PM   #7
kishou
Programmer
 
Join Date: May 2007
Posts: 52
Rep Power: 2 kishou is on a distinguished road
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.
kishou is offline   Reply With Quote
Old Jan 23rd, 2008, 8:50 PM   #8
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 908
Rep Power: 3 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
Re: isset() help

Quote:
Originally Posted by kishou View Post
oh thats no my username or password.
It's not his, it's his client's.
titaniumdecoy is offline   Reply With Quote
Old Jan 23rd, 2008, 9:03 PM   #9
kishou
Programmer
 
Join Date: May 2007
Posts: 52
Rep Power: 2 kishou is on a distinguished road
Re: isset() help

Quote:
Originally Posted by titaniumdecoy View Post
It's not his, it's his client's.
uh oh speghatti ohs!
kishou is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
BH Hotkeys brownhead Visual Basic 1 Apr 27th, 2006 6:42 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:10 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC