Correct.Originally Posted by Dylannn
| SitePoint Sponsor |
Correct.Originally Posted by Dylannn
- Nathan


that first one is a nightmare! But Ive seen the same in Java .... now this one is funny because Id do the EXACT opposite in Java:Originally Posted by Young Twig
funny --- so Im starting to get it, do everything exactly opposite from what I would do in Java!Code:sb.append("<div class='asdf'><label for='price'>Price: $</label><input type='text' name='price' value='"+price+"' />");![]()
Yeah, but you should use double quotes in HTML. You can do the same in PHP (double quote the string, single quote the attributes).
- Nathan


Hate to disagree with you there Nathan but there is NO difference between a ' or a " around an attribute in HTML ... none whatsoever. The specs and standards state either delimiter will work the same... Ive been using 's for 6 years now with no problem at all!Originally Posted by someonewhois
![]()
I realize that they're both valid, it's just double quotes look better on attributes.And single on PHP.
![]()
- Nathan


Don't worry DC. I am just learning PHP too, and constantly ask Jon for clarification.
God I hate not being able to tab.PHP Code:<?php
$dan = 'Bad at PHP';
$jon = 'Good at PHP';
$knowledge = 0;
$errors = 1000;
if($dan == 'Talks to Jon'){
$knowledge++;
$errors--;
} else {
$errors++;
}
?>


You do that too? Ill be sitting here writing an example piece of code and hit tab, start typing and then look up and say "you idiot!"Originally Posted by DM3Dan


Originally Posted by dc dalton
. I used to try and code in cPanel's 'Edit' form. I would always hit tab, and change my filename to something like if($it == 'value').php
. Now I use notepad.
Yeah, whenever I do examples for SP, I open a new [unsaved] file in my editor. It happens that my editor is open every minute that my computer is on, regardless of whether I'm using it or not, so.
- Nathan


OK Im STUCK!
Im trying to get a site together and AS PROMISED, Im using PHP... here's whats confusing me:
I have a main index.php that grabs the variable pageName as such:
Now the header.php is really nothing more than an html file BUT I want to use that pageName variable in it (titles etc) ... so I did this:PHP Code:<?php
if ($pageName == "") {
$pageName = 'main';
}
include 'header.php';
readfile("pageText/" . $pageName . ".txt");
include 'footer.php';
?>
But the variable isnt there when I test it .. what the heck am I missing here or is it not possible to pass this variable like this?Code:<html> <head> <meta http-equiv='content-type' content='text/html; charset=iso-8859-1' /> <title> <?php $pageName ?> </title>
Originally Posted by dc dalton
PHP Code:<title> <?php echo $pageName; ?> </title>![]()


Thanks Dylann ... figured it was something stupid... Im off to my next silly problem. As I said Im gonna learn this or else!
Story of my lifeOriginally Posted by dc dalton
:P


OK, believe it or not I have managed to get this site running, even doing a redirect or two going ... Im actually having some fun here!
BUT I have another question! Is there an indexOf type function in PHP? What Im trying to do is look at the referrer of the page and make sure its coming from Paypal .. if not I want to give them an error page .... I looked thru the php.net manual but didnt find one...... in Java I would just try to find the index of paypal.com in the referrer something like this:
if (referrer.indexOf("paypal.com") != -1) {
// good screen
}
else {
// screw you screen
}
thanks folks ... I think Im starting to get the hang of this stuff!





Your better off using regular expressions for this, but to answer your question, it is possible, for example
PHP Code:// $string = 'http://www.paypal.com';
$string = 'www.paypal.com?arg1=hello&arg2=world&arg3=abc123xyz';
if( strstr( $string, 'paypal.com' ) || strstr( $string, 'paypal' ) ) {
// good message
} else {
// bog off message
}





I think so, too. I believe strpos is identical to indexOf, but it returns false if needle is not found. (indexOf returns -1, correct?)
Originally Posted by php.net
PHP Code:// $string = 'http://www.paypal.com';
$string = 'www.paypal.com?arg1=hello&arg2=world&arg3=abc123xyz';
if(strpos($string,'paypal.com')!==false)
{
// good message
}
else
{
// bog off message
}
I've gotten good at the 5 space thing. It sounds like someone's getting shot.Originally Posted by DM3Dan


OK, a minor problem here and I dont know if its my code (probably) or something else... what Im doing is trying to lock donw a page so that it will ONLY display the contents if the referrer was paypal... Ive tried the strpos but when I tested it I get the "illegal access page" not the downloads page .... here's the code:
The other thing I was wondering about was about the fact that paypal is running under an ssl - but I didnt know (and couldnt find) anything about an HTTPS_REFERER .... anyone see what IM screwing up here ... I know its pretty basic but ya gotta start somewhere!PHP Code:<?php
include 'header.php';
$ref = getenv('HTTP_REFERER');
$pos = strpos($ref, 'paypal.com');
if (!$pos) {
readFile("downloads/paypal/illegal.txt");
}
else {
readfile("downloads/paypal/downloads.txt");
}
include 'pageText/sidebar.txt';
include 'footer.php';
?>
I also tried this:
PHP Code:<?php
include 'header.php';
$ref = getenv('HTTP_REFERER');
$pos = strpos($ref, 'paypal.com');
if ($pos) {
readfile("downloads/paypal/downloads.txt");
}
else {
readFile("downloads/paypal/illegal.txt");
}
include 'pageText/sidebar.txt';
include 'footer.php';
?>
If you echo $ref, what do you get? You should also use if ($pos !== false). Oh, and you have a horrible combination of single and double quoets -- keep it consistant!
- Nathan


whoops, thats the java slipping back in .... the minute I type a ( Im used to following it with a "Originally Posted by someonewhois
I tried echo $ref and got NOTHING .... I did look at the source from Paypal on their "Return to merchant" button and its nothing more than a form using a get method, no variables to try and grab at all ..... thats why I was trying to grab the referer ..Originally Posted by someonewhois
Ill try it again with the !== false and see what happens, pain in the BUTT cause with PP you have to test live! NO DAMN DEMO MODE!
They have a demo mode -- it's under the developers network.
Also, are you using the IPN or the return to mercant button. The IPN is a LOT safer, and will probably be better.
- Nathan


Ill have to go find that ... I try to stay away from using Paypal but now that you dont have to have a paypal account Im using them. I usually use some kind of membership login app but this thing is so simple (a download after paying) I figure I try to keep it simple!Originally Posted by someonewhois


well we can skip that developer central CRAP with those idiots today .... WHERE IN THE HELL did those MORONS at ebay (paypal same same) learn to program! 4 times Ive reset the password after confirming my developer account and every stinking time it tells me "you login does not match our records" ..... IDIOTS! ...... worst damn programmers I have EVER seen in my life!
* sorry just needed to vent! *
Haha. Yeah, they've got issues. I think the developers should hang out in their own developer network... it could help.
- Nathan


all right I tried the code again with the changes you recommended and still no go ....
Is it because its coming from a secure line that the PHP isnt picking up the referrer?PHP Code:<?php
include 'header.php';
$ref = getenv('HTTP_REFERER');
$pos = strpos($ref, 'paypal.com');
if ($pos !== false) {
readfile('downloads/paypal/downloads.txt');
}
else {
readFile('downloads/paypal/illegal.txt');
}
include 'pageText/sidebar.txt';
include 'footer.php';
?>
Bookmarks