Using PHP for Dynamic Landing Pages

7 replies
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
#dynamic #landing #pages #php
  • Profile picture of the author ehicks727
    $_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.
    {{ DiscussionBoard.errors[633446].message }}
  • Profile picture of the author Ross Dalangin
    You can use either *_REQUEST in exchange with the *_GET or add above a code like

    *_GET=*GLOBALS['HTTP_GET_VARS']; //to get the link variables
    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
    {{ DiscussionBoard.errors[633729].message }}
    • Profile picture of the author ehicks727
      Without doing lots of checking, running the code above would open you up to lots of security problems. You'd be hacked instantly.
      {{ DiscussionBoard.errors[633796].message }}
  • Profile picture of the author AndyBlackSEO
    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
    Signature
    [FREE SEO TOOL] Build 29 Effective, High Authority Backlinks that Will Increase Your Google Rankings in 2020... CLICK HERE ...
    ... Instant backlinks that can get you results within 24-72hrs.
    {{ DiscussionBoard.errors[634193].message }}
  • Profile picture of the author Eric Dick
    I am using this to raise my quality score in Adwords, how could I get hacked using this?
    {{ DiscussionBoard.errors[634451].message }}
    • Profile picture of the author ehicks727
      Originally Posted by Eric Dick View Post

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

      You can use either *_REQUEST in exchange with the *_GET or add above a code like
      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 !!
      {{ DiscussionBoard.errors[634547].message }}
      • Profile picture of the author Ross Dalangin
        Originally Posted by ehicks727 View Post

        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 !!
        You have to make a certain commands to make it secured.

        Andy: Maybe the OP want to convert the first character of each word in a string to uppercase.

        Ross
        {{ DiscussionBoard.errors[634587].message }}

Trending Topics