954,591 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Error: "Use of undefined constant" Help!



    Administrator Login

auto2.pngLoginUsername: Password:

Can't remember your password?

nathanpacker
Posting Whiz in Training
234 posts since May 2005
Reputation Points: 10
Solved Threads: 0
 

Try adding quotes"

setcookie("ID_my_site", $_POST['username'], $hour);

setcookie("Key_my_site", $_POST['pass'], $hour);

stymiee
He's No Good To Me Dead
Moderator
3,360 posts since May 2006
Reputation Points: 161
Solved Threads: 38
 

Thanks. That seemed to do the trick. I'm confused then as to why it broke all of the sudden, when it was working before without the quotes. Perhaps a user was created that had a space in the password or something? Curious.

nathanpacker
Posting Whiz in Training
234 posts since May 2005
Reputation Points: 10
Solved Threads: 0
 

That is a good question. Might be a configuration change on the server as well.

stymiee
He's No Good To Me Dead
Moderator
3,360 posts since May 2006
Reputation Points: 161
Solved Threads: 38
 
Thanks. That seemed to do the trick. I'm confused then as to why it broke all of the sudden, when it was working before without the quotes. Perhaps a user was created that had a space in the password or something? Curious.

Just a comment on the code structure.

Your code as it is could be prone to hacking.

You should escape any values passed to a query with sqlesc or any1 who is that way inclined could hack your login script and bypass the login process. by manipulating either cookie information or the POST values.

You should also sanitise your POST and the variables they use also.

The following lines are HIGHLY unsafe and need sorting.

[php]
$check = mysql_query("SELECT * FROM mytable WHERE username = '$username'")or die(mysql_error())

$check = mysql_query("SELECT * FROM mytable WHERE username = '".$_POST['username']."'")or die(mysql_error());
[/php]

I recommend reading up on php and database security and go through all your code checking for things like the above. Its better to be safe than sorry as they say

devdan
Newbie Poster
3 posts since Jun 2007
Reputation Points: 10
Solved Threads: 0
 

Thanks for the tips, but it's taken a lot of reading up on PHP just to get scripts like this to work. I'm a long way from making my scripts totally secure. Just getting them to work is a bonus for me. I promise I'll look into security later on. Besides, none of the scripts I write are business critical or anything, they're all just personal stuff.

nathanpacker
Posting Whiz in Training
234 posts since May 2005
Reputation Points: 10
Solved Threads: 0
 

Mission critical or not, it's actually possible to delete your entire database with one carefully formed query.

Unless you want to lose all your hard work it might be an idea to read up, as Devdan mentioned. It's not a big job, at all.

leelee
Junior Poster in Training
77 posts since Aug 2005
Reputation Points: 31
Solved Threads: 1
 

quotes works for me too ! ! ! ! THANKS!!!!!!

codezilla
Newbie Poster
1 post since Oct 2009
Reputation Points: 10
Solved Threads: 0
 

Quotes did the trick! Thanks guys! You rock!

daydah
Newbie Poster
1 post since Dec 2010
Reputation Points: 10
Solved Threads: 0
 

I know this is a old thread but their is a receint post..

I suspect the reason you find the site breaks for no reson, is that php has been updated, Newer versions are trying to prevent you from using unsecure code.


Their are really easy things you can do to fix the security problems shown here, as stated, the script shown here would indeed alow any of us telling you its unsafe to mess with youre data base, steal / destroy your data, and bypass the log in.


BTW: the quotes worked for me too :)

Regards Pat.

patmaherjfm
Newbie Poster
3 posts since Feb 2010
Reputation Points: 10
Solved Threads: 0
 

Hello am new too daniweb much more php coding but this 'quotes' thing worked for me too!! thanks guys.

fasins
Newbie Poster
1 post since Oct 2011
Reputation Points: 10
Solved Threads: 0
 

Yaaap. The quote works. Now, I'm ready to venture further into the world of PHP and MYsql. Thanks a lot,guys - Art

Art_95148
Newbie Poster
2 posts since Oct 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You