Using PHP for Dynamic Landing Pages

by 7 replies
8
Hello Programming Wizards,

I am looking add dynamic keyword insertion on my pages and when i paste this code into the site and test it I get errors, here is the code

<?php
if ($_GET['kw'])
{echo ucwords($_GET['kw']);}
else
{echo ucwords("Default Text");}
?>

I save the site as.php and copy the code in where I want it, but now luck.

Ideally I would like to paste the code in the title tag, website body copy, and at the bottom of the site so the keyword becomes the anchor text for an outbound link on the bottom of the page.

Can someone help with this? Thanks
Eric
#programming #dynamic #landing #pages #php
  • $_GET['kw']

    What's that?? Are they coming to your page from a web form?

    If you're thinking that they are coming from a search engine, it's a lot more difficult. You have to grab the browser (user-agent) and then parse the search parameters.

    I do this kind of thing a lot. I'll send you a PM.
  • You can use either *_REQUEST in exchange with the *_GET or add above a code like

    Sometimes the server settings are different. PM me know if that didn't fixed the error.

    Note: There's a problem when posting this reply so you need to change the * with $ sign.

    Ross
    • [1] reply
    • Without doing lots of checking, running the code above would open you up to lots of security problems. You'd be hacked instantly.
  • If you are sending the variables within an anchor link (dynamically via the url) then you could do something like this.......

    <?php
    $ucwords = $_GET['kw'];
    if (!$ucwords) {$ucwords = "Default Text";}
    echo "<title>".$ucwords."</title>";
    ?>

    Obviously, the title may not appear there, so you may just enter something like the following on the title line.........

    <title><?php echo $ucwords; ?></title>

    Andy
  • I am using this to raise my quality score in Adwords, how could I get hacked using this?
    • [1] reply
    • I was talking about Ross's solution.

      If anyone noticed you were using that method, they could inject malicious code into the request.

      There are bots that endlessly roam the Internet looking for stuff like this. You'd likely be the next celebrity on Zone-H.org - Unrestricted information !!
      • [1] reply

Next Topics on Trending Feed