Does no one know what I'm talking about?
Surely this would have came up with someone else before...
Thanks
- Adam
Does no one know what I'm talking about?
Surely this would have came up with someone else before...
Thanks
- Adam
Sorry, should have turned off the auto parse URL thing.
This is the sort of redirect I'm trying to do:
header("location: http://www.mysite.com/page.php?var=something#bookmark");
Hi,
I've found what I think is a bug in Internet Explorer, which I really need to be able to get around.
Here's the problem:
header("location: [url]http://www.mysite.com/page.php?var=something#bookmark[/url]");
This redirect in internet explorer will redirect to page.php, BUT the $_GET["var"] variable will equal this:
echo $_GET["var"];
//produces: something#bookmark
For some reason in IE, the bookmark is tacked onto the end of the variable! This is so anoying, and it doesn't happen in other browsers like mozilla.
If I now hit refresh in IE, the page will reload but the bookmark won't be tacked on the end:
echo $_GET["var"];
//produces: something
I don't even know what's causeing this? I suppose it must be a IE bug, but how? Why when I refresh the page is it ok?
I hate IE!! But I have to get this working, so if you know what can be done to get around this please let me know. Thanks.
Also the version IE I have tested this on is 6.0.2800.1106. I am sure it has worked before on IE maybe another version, but I can't remember.
Thank you,
-Adam
Hi,
I'm trying to replace all characters between two words in a string. If someone could help me out it would be much appreciated.
This is what I want to do:
$sString1 = " select field, field2, field 3
from table
where field1 = 'something'
union(
select field, field 2, field 3
from table
where field2 = 'somethingelse'
)";
See how there are two select clauses in the query? Well what I want to do is replace both with "select count(*) from"
This is what the first string should look like after I perform the replace:
$sString2 = " select count(*)
from table
where field1 = 'something'
union(
select count(*)
from table
where field2 = 'somethingelse'
)";
So, how can I make the 1st string equal the 2nd string using regular expressions?
I can't seem to find a way to Not find a word. Because the only way I can think of doing it is replacing 'select' and all words that are not 'from' up untill I come to the word 'from'.
How do I do this?
I've been trying things like this to no avail:
$sSQL = preg_replace("/select(.*)from/is","select count(*) from",$sSQL);
But that will of course not work as it will eat up the first 'from' and go untill it reaches the last 'from'
Why is it there is a ^ for negating a single character in a class [] blut not a way to negate a whole series of characters? Or is there?
I hate regular expressions!
If you can help that would be great.
Thanks.
-Adam
You don't have to decode URL encoded values....
If a PHP script is passed some data through GET or POST (i.e. in a form or in the query string) then php will automatically decode that data when the script runs, and the decoded data will be available in the either the $GET or $POST arrays. You shouldn't have to touch that at all.
If you want to check whether data is being passed between scripts, just do this:
print_r($POST); or print_r($GET)
That will show all the data that was passed from the previous script through a form or the query string.
Unless you've fixed up your code too as I mentioned before of course it won't be working anyway. You were still using ASP and not PHP in a lot of spots, esp concerning the Challange variable.
That's most likely your problem.
Take your time...read through the code and make sure it's all correct...
k, good luck man
- Adam
You don't have to decode URL encoded values....
If a PHP script is passed some data through GET or POST (i.e. in a form or in the query string) then php will automatically decode that data when the script runs, and the decoded data will be available in the either the $GET or $POST arrays. You shouldn't have to touch that at all.
If you want to check whether data is being passed between scripts, just do this:
print_r($POST); or print_r($GET)
That will show all the data that was passed from the previous script through a form or the query string.
Unless you've fixed up your code too as I mentioned before of course it won't be working anyway. You were still using ASP and not PHP in a lot of spots, esp concerning the Challange variable.
That's most likely your problem.
Take your time...read through the code and make sure it's all correct...
k, good luck man
- Adam
You don't have to decode URL encoded values....
If a PHP script is passed some data through GET or POST (i.e. in a form or in the query string) then php will automatically decode that data when the script runs, and the decoded data will be available in the either the $GET or $POST arrays. You shouldn't have to touch that at all.
If you want to check whether data is being passed between scripts, just do this:
print_r($POST); or print_r($GET)
That will show all the data that was passed from the previous script through a form or the query string.
Unless you've fixed up your code too as I mentioned before of course it won't be working anyway. You were still using ASP and not PHP in a lot of spots, esp concerning the Challange variable.
That's most likely your problem.
Take your time...read through the code and make sure it's all correct...
k, good luck man
- Adam
You don't have to decode URL encoded values....
If a PHP script is passed some data through GET or POST (i.e. in a form or in the query string) then php will automatically decode that data when the script runs, and the decoded data will be available in the either the $GET or $POST arrays. You shouldn't have to touch that at all.
If you want to check whether data is being passed between scripts, just do this:
print_r($POST); or print_r($GET)
That will show all the data that was passed from the previous script through a form or the query string.
Unless you've fixed up your code too as I mentioned before of course it won't be working anyway. You were still using ASP and not PHP in a lot of spots, esp concerning the Challange variable.
That's most likely your problem.
Take your time...read through the code and make sure it's all correct...
k, good luck man
- Adam
Some of code looks a bit dodgy. Can't run it cause i don't have PHP on this machine.
Also, you left some ASP still in there:
<input type="hidden" name="challenge" value ="<%=Challenge"%>
You need to convert it to PHP:
<input type="hidden" name="challenge" value ="<?=$Challenge?>">
Also note that you messed up the HTML... the " and > weren't closed properlly.
As as security measure you shouldn't do all your validation client side... I.e. with JavaScript... anyone can bypass that. Make sure you check server side too before processing the data.
Double check your HTML too... there's unclosed tags everywhere... you don't want to leave <b> tags unclosed... will make your page look quite silly...
Anyway, I guess the rest looks alright... can't you test to to see what it does?
k, cya man.
-Adam
... "If I run the following line only, I get a blank page, no output: "
<?
echo $_SERVER["HTTP_REFERER"];
?>
Well of course! lol. Don't you know what a referer is? The $_SERVER["HTTP_REFERER"] variable is only created if the script you are running has was started by someone clicking a hyperlink.
I.e. If I am on page "script1.php" and I click a link on that page that goes to "script2.php" then the $_SERVER["HTTP_REFERER"] will be the URL to the "script1.php" page.
If I just run the "script2.php" page on it's own without having came from somewhere, $_SERVER["HTTP_REFERER"] will be empty.
So of course if you just run that script that's what will happen. I meant try the echo after you've clicked a link to get to the script...
So, if you are on the page https://ssl.paytrack.com/cbank/4.cgi and you click a link to get to this script you are working on, it shouldn't redirect as that is the referer you are testing against.
Otherwise the page should redirect to http://www.translation.academy-life.com/index.htm. If it doesn't redirect for some reason (maybe there's a problem in the URL) then the page will just stop. (That's what the exit; statement does)
So that's why your page is producing no output if you are not coming from the https://ssl.paytrack.com/cbank/4.cgi page.
Make sense?
Good luck man.
-Adam
I think you might be spelling referer right...or wrong depending on how you look at it.
It's spelt like this in PHP anyway:
$_SERVER["HTTP_REFERER"]
So that is why the condition could be failing even when the referer is https://ssl.paytrack.com/cbank/4.cgi.
Just do simple test: echo $_SERVER["HTTP_REFERER"] in your script and see what it produces... it should produce "https://ssl.paytrack.com/cbank/4.cgi" when coming from that page.
If not you've prolly spelling the variable wrong or are using some really odd version of PHP
Don't worry, it trips me up all the time too... fancy them spelling it wrong!
cya
-Adam
I went to http://www.translation.academy-life.com/index.htm and the page loaded... of course that's a just a HTML page, and not the php script with the code in it so I don't know what that shows....
What's the script you're working on? Maybe post some more of the code.
In anycase the code that people have posted in these replies are not working solutions... you need to still use the ideas to code your own function.
Anyway, if you know what the valid referers should be, then just compare them to $_SERVER["HTTP_REFERER"], which is the current referer.
$validreferer = "http://www.site.com/jfkdls";
if($_SERVER["HTTP_REFERRER"] != $validreferer){
Header("Location: http://www.translation.academy-life.com/index.htm");
exit;
}
Come up with your own way of implementing it which suits what you're trying to accomplish... the important details are $_SERVER["HTTP_REFERRER"] is the current referrer, and Header() can be used to redirect.
k, good luck.
-Adam
You were on the right track. The equivalent of your ASP example in PHP is this:
ASP:
Challenge = Request.Form(βChallengeβ)
PHP
$Challenge = $_POST["Challenge"];
The Request.QueryString() or whatever it is in ASP is this in PHP:
$Challenge = $_GET["Challenge"];
The equvialent of just Request("Challenge") in PHP is $_REQUEST["Challenge"] in php.
Then do what you want with the variables as you were doing.
There are some other differences too, such as how PHP handles arrays passed between pages, but I'll leave that up to you to check out.
K, cya.
-Adam
The $_SERVER['HTTP_REFERRER'] variable is a fully qualified URL. This means that is will not ever equal "source.html', which could be causing your script to loop continuously.
Instead use:
if(!eregi("source.html",$_SERVER['HTTP_REFERRER']) {
Header("Location: http://www.translation.academy-life.com/index.htm");
exit();
}
or better yet check against the whole path to source.html.
Don't bother using the Meta refresh tag. Just redirect with a header...
k, cya man.
-Adam
Use regular expressions.
$domain = $SERVER["SERVER_NAME"];
preg_match("/([A-Za-z0-9])./i", $domain, $aMatches);
echo $matches[0];
Something like that anyway.
if the current domain is "subdomain.domain.com", then that should match "subdomain".
Or maybe there's allready a php function for it? wouldn't surprise me, I forget half the functions that are available.
cya
-Adam
Well, maybe there's something wrong with this statement:
if ($res = send_sql($db,$sql))
it looks correct to me, but that's all I can think of
Try this instead:
$res = send_sql($db,$sql);
if($res){
//do stuff
Otherwise the error must be in the verbind.php file, as the rest of it looks correct.
good luck
-Adam
I don't think you can log out of HTTP based authentication unless you close the browser.
If you are going to use HTTP based authentication though, you will need a password file... else what are you authenticating against? That's why you're able to enter anything and it says authentication successful.
What you are after though, is not HTTP based authentication... you want to use a database, and php and sessions, to code up a authentication script.
There's squillions of threads and tutorials on this throughout the site... have a look around, and there's more then enough info to get you going.
good luck.
-Adam
I'm not sure what you mean... do you want a HTML select box as the navigation control?
Just use some basic HTML and javascript:
<select onChange="document.location.href=this.options[this.selectedIndex].value">
<option value="http://www.mysite/page1.html">Page 1</option>
<option value="http://www.mysite/page2.html">Page 2</option>
<option value="http://www.mysite/page3.html">Page 3</option>
<option value="http://www.mysite/page4.html">Page 4</option>
</select>
something like that is pretty simple...
is that what you were after?
You left off a semi colon on this line:
include("verbind.php")
I don't know if that's just a typo on your part or not.
Otherwise... the error may be in the verbind.php file... the rest looks ok though.
cya
-Adam
No functions have to be called right, just include it?
Oh yeah, I meant to say that's correct as well. PHP will call the ErrorHandler() function automatically once it is set to.
The other functions can be called though in your scripts for debugging purposes if you like. I use them all the time for information on variables.
Eg:
//Print information on all php variables
printGlobals($GLOBALS, true);
//Print information on an object. Make sure it exists first, unlike here
objectInfo($oMyObject);
cya
-Adam