/    Sign up×
Community /Pin to ProfileBookmark

undefined constant ???

Here is another problem:

This script

[code]<?php
if ($ime == Petar and $prezime == Petrovic) {
echo (“Welcome, $ime $prezime !” ); }
else { echo “NOt this time” ;}
?>[/code]

and html page:

[code]<FORM ACTION=”http://127.0.0.1/home/Druga.php” METHOD=GET> Ime:

<INPUT TYPE=TEXT NAME=”ime”><BR> Prezime: <INPUT TYPE=TEXT

NAME=”prezime”> <INPUT TYPE=SUBMIT VALUE=”GO”> </FORM>[/code]

produce the following output:

[quote]

Notice: Use of undefined constant Petar – assumed ‘Petar’ in c:program fileseasyphp1-8homedruga.php on line 2

Notice: Use of undefined constant Petrovic – assumed ‘Petrovic’ in c:program fileseasyphp1-8homedruga.php on line 2
Welcome, Petar Petrovic !

[/quote]

register_globals is set to “On”.

I`m confused ?? ?

Thanks

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@CharlesDec 29.2006 — [code=php]<?php
echo $ime == 'Petar' && $prezime == 'Petrovic' ? "Welcome, $ime $prezime !" : "NOt this time"
?>[/code]
Copy linkTweet thisAlerts:
@teadzukelaauthorDec 29.2006 — Charles, you're the king. ?

But, i'm wondering what's wrong with my "if" code ??

Thanks a lot

P.S.

How do I open certain url instead of "else echo message"?
Copy linkTweet thisAlerts:
@pcthugDec 29.2006 — The strings in your original if expression were not encased within quotes, therefore they were treated as constants.
[code=php]if ($ime == Petar and $prezime == Petrovic) {[/code]Becomes...[code=php]if ($ime == 'Petar' and $prezime == 'Petrovic') {[/code]
To redirect to a diferent URL, use the header Location function:
[code=php]
<?php
$location = ($ime == 'Petar' && $prezime == 'Petrovic') ? "http://foo.bar/welcome/" : "http://foo.bar/notwelcome/"

header("Location: $location");
?>[/code]
Copy linkTweet thisAlerts:
@teadzukelaauthorDec 29.2006 — Many thanks pcthug. ?
×

Success!

Help @teadzukela spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...