Jump to content

string question


simonp

Recommended Posts

Hi all,

I'm using the code below to check that a user is coming from the correct page before allowing them to go on.

It works for all but one page which passes a string in the URL, eg>

[a href=\"https://www.mywebsite.com/page4.php?name=william\" target=\"_blank\"]https://www.mywebsite.com/page4.php?name=william[/a] etc

How can I make the code check that the first part is correct but ignore everything after page4.php?

Cheers

Simon

[code]<?php
if ($_SERVER['HTTP_REFERER'] != "https://www.mywebsite.com/page5.php") {
        header("Location: https://www.mywebsite/page1.php");
    break; // END case 'OK'
}
?>[/code]
Link to comment
https://forums.phpfreaks.com/topic/9855-string-question/
Share on other sites

Try:
[code]<?php
    $refurl = $_SERVER['HTTP_REFERER'];
    $parsed = parse_url($refurl));
    foreach($parsed as $key => $value)
          echo '$parsed[' . $key . '] = ' . $value . "<br>\n";
?>[/code]

The [b]scheme[/b] is in [!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]$parsed['scheme'][!--colorc--][/span][!--/colorc--]
The [b]host[/b] is in [!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]$parsed['host'][!--colorc--][/span][!--/colorc--]
The [b]path[/b] is in [!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]$parsed['path'][!--colorc--][/span][!--/colorc--]

You really should learn to use arrays as they are very powerful in PHP and other programming languages.

Ken
Link to comment
https://forums.phpfreaks.com/topic/9855-string-question/#findComment-36711
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.