php form data probs

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
mrpaul
-


Joined: 23 Sep 2005
Posts: 18

PostPosted: Sun Sep 25, 2005 12:45 pm    Post subject: php form data probs Reply with quote

Hi, i am haveing probs with this php code here;
it's ment to add news to news.html
[php]

<?php

$addnews = "news.htm";
$news = $_POST['news'];
$name = $_POST['name'];
$pass = $_POST['password'];
$password = "addme";

if ("$pass == $password")
{

$file = fopen ( $addnews, "a+") ;
fwrite ( $file, "Name: <b> $name </b><br><b>Feedback: </b>$news <br><hr>" ) ;
fclose ( $file ) ;
echo ( " <h3>Thank for you feedback $name.<br></h3>your feedback: <br> $news " );
}

else
echo ( " CENSORED OFFF " );
;exit


?>
[/php]
however
1) it adds the news regardlst of the password
2) it adds it to the bottom of the page, is ther a way round that?
Back to top View user's profile Send private message
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Sun Sep 25, 2005 1:33 pm    Post subject: Re: php form data probs Reply with quote

The test below is not correctly written and thus the script does not what you intend to:
Code:

if ("$pass == $password")


It should be:

Code:

if ($pass == $password)


Enclosing the test between two " characters makes a lot of difference and has a different meaning.
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
mrpaul
-


Joined: 23 Sep 2005
Posts: 18

PostPosted: Sun Sep 25, 2005 2:12 pm    Post subject: Reply with quote

Thansk!
Back to top View user's profile Send private message
cmxflash
-


Joined: 11 Dec 2004
Posts: 872

PostPosted: Sun Sep 25, 2005 4:39 pm    Post subject: Reply with quote

Correct me if I'm wrong, but I don't think this is going to work:

Code:

else
echo ( " CENSORED OFFF " );
;exit
Back to top View user's profile Send private message
Tim1681
-


Joined: 17 Jan 2005
Posts: 160
Location: Bristol, CT, USA

PostPosted: Sun Sep 25, 2005 4:51 pm    Post subject: Reply with quote

... i don't think it would work .. but im probably wronggg. I think i would go with something alittle more syntax friendly .. like:
Code:
else{
echo "Bad Words";
}
exit;

_________________
mysql> SELECT * FROM users WHERE clue > 0;
0 rows returned.

Back to top View user's profile Send private message AIM Address
mrpaul
-


Joined: 23 Sep 2005
Posts: 18

PostPosted: Sun Sep 25, 2005 5:31 pm    Post subject: Reply with quote

nope it works fine, it dosent tell tehm to CENSORED off anymroe tho it logs ther ip and then sned then to my error 401 page
Back to top View user's profile Send private message
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Sun Sep 25, 2005 5:42 pm    Post subject: Reply with quote

Still... its not very polite to use that sort of language.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
mrpaul
-


Joined: 23 Sep 2005
Posts: 18

PostPosted: Sun Sep 25, 2005 6:00 pm    Post subject: Reply with quote

bah i'll sleep at night,
i only used it as a example here.
it's also not nice to post try to post news on my site when i never said it was ok.
Back to top View user's profile Send private message
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Sun Sep 25, 2005 6:32 pm    Post subject: Reply with quote

Quote:
it's also not nice to post try to post news on my site when i never said it was ok.


Whats this meant to mean?
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
mrpaul
-


Joined: 23 Sep 2005
Posts: 18

PostPosted: Sun Sep 25, 2005 6:44 pm    Post subject: Reply with quote

Dont get me wrong i aint saying u tryied to post something on my site,
in the code, it only echos CENSORED off if they get the wrong password, so ther must be trying to post news and i think being told to CENSORED off is ok.
Back to top View user's profile Send private message
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Sun Sep 25, 2005 7:33 pm    Post subject: Reply with quote

Well if you intend on keeping your visitors, a simple 'Sorry, the password you entered was incorrect. Please make sure you have access rights to this area' should do just fine.

All I am trying to say is that swearing on the forum is not going to get you replies any quicker. Some people are offended by bad language and may know the answer to the question but not bother to post because of the language you use.

I'd think about it next time.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Mon Sep 26, 2005 10:31 am    Post subject: Reply with quote

The Inquisitor wrote:
Well if you intend on keeping your visitors, a simple 'Sorry, the password you entered was incorrect. Please make sure you have access rights to this area' should do just fine.

All I am trying to say is that swearing on the forum is not going to get you replies any quicker. Some people are offended by bad language and may know the answer to the question but not bother to post because of the language you use.

I'd think about it next time.


I don't think it matters to be honest.
I have worse things lurking on some of my pages.

mrpaul -> header("Location: http://hotmale.com") works better than fuck off.
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group