FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Hopiing for some leads as to what may be wrong in this code
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Hopiing for some leads as to what may be wrong in this code [message #182248] Wed, 24 July 2013 23:27 Go to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
Hi all,

I have a seemingly strange thing happening here. I have a contact form
on one website that works perfectly and that same form with appropriate
changes, results in an error message during a check of a random number
(created with mt_rnd() ) on the other site. Both sites are located on
the same remote servers.

Win 7, PHP 5.3.5, XAMPP local server, standard Unix remote server:

Please consider the following:

Complete form consists of three .PHP pages; no HTML. Entry form, check
page, mailto() page; pretty standard stuff in that way:

================
WORKING CODE ON REMOTE SERVER:

Setting the code on landing page:
$_SESSION["d"] = $d;
--------------------

$code= $_POST["code"];
if($_SESSION["d"] !== $code) {
echo "<br />You did not enter the correct code: Script halted, ALL
data destroyed.<br /> you'll have to go back to the website and start
over.<br />";
die("Script HALTED, data destroyed");
session_destroy();
exit();
}
RESULT:
page throws no error either with local or remote server: Message is sent
successfully.

===============================

NON-WORKING CODE ON REMOTE SERVER BUT WORKS ON LOCAL HOST:

Setting the code on previous page:
$_SESSION["d"] = $d;
----------------------
Page with problem:
$code= $_POST["code"];
if($_SESSION["d"] !== $code) {
echo "<br />You did not enter the correct code: Script halted, ALL
data destroyed.<br /> you'll have to go back to the website and start
over.<br />";
die("Script HALTED, data destroyed");
session_destroy();
exit();
}

RESULT:
[Gets stuck on the second page of the form where PHP sanitize/validation
happens; never makes it to last page with the mail() function]:

using code : 487-535175 <----------- WHICH IS CORRECT CODE
You did not enter the correct code: Script halted, ALL data destroyed.
you'll have to go back to the website and start over.
Script HALTED, data destroyed
================

Can you spot any differences there? The local server throws NO error,
notices or warnings. But the Remote Server stops cold on the second
page, indicating the code is wrong. But it's not; I can see the code;
it's correct. But it seems to never be seen as correct by my Remote
Server while my Local Server accepts it perfectly.

What really gets me is it works on one site and not the one I'm trying
to perpetuate the code to. OH, and both sites are on the same Remote
Servers at Netfirms.com. Separate accounts of course.
I'm not using rewrites, no php changes on the Remote Server; both
sites are on the same server.
Any thoughts or ideas what I might be doing wrong or where else I
should be looking?

TIA,

twayne`
Re: Hopiing for some leads as to what may be wrong in this code [message #182249 is a reply to message #182248] Thu, 25 July 2013 03:04 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 7/24/2013 7:27 PM, Twayne wrote:
> Hi all,
>
> I have a seemingly strange thing happening here. I have a contact form
> on one website that works perfectly and that same form with appropriate
> changes, results in an error message during a check of a random number
> (created with mt_rnd() ) on the other site. Both sites are located on
> the same remote servers.
>
> Win 7, PHP 5.3.5, XAMPP local server, standard Unix remote server:
>
> Please consider the following:
>
> Complete form consists of three .PHP pages; no HTML. Entry form, check
> page, mailto() page; pretty standard stuff in that way:
>
> ================
> WORKING CODE ON REMOTE SERVER:
>
> Setting the code on landing page:
> $_SESSION["d"] = $d;
> --------------------
>
> $code= $_POST["code"];
> if($_SESSION["d"] !== $code) {
> echo "<br />You did not enter the correct code: Script halted, ALL
> data destroyed.<br /> you'll have to go back to the website and start
> over.<br />";
> die("Script HALTED, data destroyed");
> session_destroy();
> exit();
> }
> RESULT:
> page throws no error either with local or remote server: Message is sent
> successfully.
>
> ===============================
>
> NON-WORKING CODE ON REMOTE SERVER BUT WORKS ON LOCAL HOST:
>
> Setting the code on previous page:
> $_SESSION["d"] = $d;
> ----------------------
> Page with problem:
> $code= $_POST["code"];
> if($_SESSION["d"] !== $code) {
> echo "<br />You did not enter the correct code: Script halted, ALL
> data destroyed.<br /> you'll have to go back to the website and start
> over.<br />";
> die("Script HALTED, data destroyed");
> session_destroy();
> exit();
> }
>
> RESULT:
> [Gets stuck on the second page of the form where PHP sanitize/validation
> happens; never makes it to last page with the mail() function]:
>
> using code : 487-535175 <----------- WHICH IS CORRECT CODE
> You did not enter the correct code: Script halted, ALL data destroyed.
> you'll have to go back to the website and start over.
> Script HALTED, data destroyed
> ================
>
> Can you spot any differences there? The local server throws NO error,
> notices or warnings. But the Remote Server stops cold on the second
> page, indicating the code is wrong. But it's not; I can see the code;
> it's correct. But it seems to never be seen as correct by my Remote
> Server while my Local Server accepts it perfectly.
>
> What really gets me is it works on one site and not the one I'm trying
> to perpetuate the code to. OH, and both sites are on the same Remote
> Servers at Netfirms.com. Separate accounts of course.
> I'm not using rewrites, no php changes on the Remote Server; both
> sites are on the same server.
> Any thoughts or ideas what I might be doing wrong or where else I
> should be looking?
>
> TIA,
>
> twayne`

Without posting the entire code, any answer would be just a guess.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: Hopiing for some leads as to what may be wrong in this code [message #182250 is a reply to message #182248] Thu, 25 July 2013 03:42 Go to previous messageGo to next message
Scott Johnson is currently offline  Scott Johnson
Messages: 196
Registered: January 2012
Karma: 0
Senior Member
On 7/24/2013 4:27 PM, Twayne wrote:
> Hi all,
>
> I have a seemingly strange thing happening here. I have a contact form
> on one website that works perfectly and that same form with appropriate
> changes, results in an error message during a check of a random number
> (created with mt_rnd() ) on the other site. Both sites are located on
> the same remote servers.
>
> Win 7, PHP 5.3.5, XAMPP local server, standard Unix remote server:
>
> Please consider the following:
>
> Complete form consists of three .PHP pages; no HTML. Entry form, check
> page, mailto() page; pretty standard stuff in that way:
>
> ================
> WORKING CODE ON REMOTE SERVER:
>
> Setting the code on landing page:
> $_SESSION["d"] = $d;
> --------------------
>
> $code= $_POST["code"];
> if($_SESSION["d"] !== $code) {
> echo "<br />You did not enter the correct code: Script halted, ALL
> data destroyed.<br /> you'll have to go back to the website and start
> over.<br />";
> die("Script HALTED, data destroyed");
> session_destroy();
> exit();
> }
> RESULT:
> page throws no error either with local or remote server: Message is sent
> successfully.
>
> ===============================
>
> NON-WORKING CODE ON REMOTE SERVER BUT WORKS ON LOCAL HOST:
>
> Setting the code on previous page:
> $_SESSION["d"] = $d;
> ----------------------
> Page with problem:
> $code= $_POST["code"];
> if($_SESSION["d"] !== $code) {
> echo "<br />You did not enter the correct code: Script halted, ALL
> data destroyed.<br /> you'll have to go back to the website and start
> over.<br />";
> die("Script HALTED, data destroyed");
> session_destroy();
> exit();
> }
>
> RESULT:
> [Gets stuck on the second page of the form where PHP sanitize/validation
> happens; never makes it to last page with the mail() function]:
>
> using code : 487-535175 <----------- WHICH IS CORRECT CODE
> You did not enter the correct code: Script halted, ALL data destroyed.
> you'll have to go back to the website and start over.
> Script HALTED, data destroyed
> ================
>
> Can you spot any differences there? The local server throws NO error,
> notices or warnings. But the Remote Server stops cold on the second
> page, indicating the code is wrong. But it's not; I can see the code;
> it's correct. But it seems to never be seen as correct by my Remote
> Server while my Local Server accepts it perfectly.
>
> What really gets me is it works on one site and not the one I'm trying
> to perpetuate the code to. OH, and both sites are on the same Remote
> Servers at Netfirms.com. Separate accounts of course.
> I'm not using rewrites, no php changes on the Remote Server; both
> sites are on the same server.
> Any thoughts or ideas what I might be doing wrong or where else I
> should be looking?
>
> TIA,
>
> twayne`

What is the error message as well?
What specific behavior where you expecting that you are not getting?
Re: Hopiing for some leads as to what may be wrong in this code [message #182251 is a reply to message #182248] Thu, 25 July 2013 08:28 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
On 25/07/13 00:27, Twayne wrote:
> Hi all,
>
> I have a seemingly strange thing happening here. I have a contact form
> on one website that works perfectly and that same form with
> appropriate changes, results in an error message during a check of a
> random number (created with mt_rnd() ) on the other site. Both sites
> are located on the same remote servers.
>
> Win 7, PHP 5.3.5, XAMPP local server, standard Unix remote server:
>
> Please consider the following:
>
> Complete form consists of three .PHP pages; no HTML. Entry form, check
> page, mailto() page; pretty standard stuff in that way:
>
> ================
> WORKING CODE ON REMOTE SERVER:
>
> Setting the code on landing page:
> $_SESSION["d"] = $d;
> --------------------
>
> $code= $_POST["code"];
> if($_SESSION["d"] !== $code) {
> echo "<br />You did not enter the correct code: Script halted,
> ALL data destroyed.<br /> you'll have to go back to the website and
> start over.<br />";
> die("Script HALTED, data destroyed");
> session_destroy();
> exit();
> }
> RESULT:
> page throws no error either with local or remote server: Message is
> sent successfully.
>
> ===============================
>
> NON-WORKING CODE ON REMOTE SERVER BUT WORKS ON LOCAL HOST:
>
> Setting the code on previous page:
> $_SESSION["d"] = $d;
> ----------------------
> Page with problem:
> $code= $_POST["code"];
> if($_SESSION["d"] !== $code) {
> echo "<br />You did not enter the correct code: Script halted,
> ALL data destroyed.<br /> you'll have to go back to the website and
> start over.<br />";
> die("Script HALTED, data destroyed");
> session_destroy();
> exit();
> }
>
> RESULT:
> [Gets stuck on the second page of the form where PHP
> sanitize/validation happens; never makes it to last page with the
> mail() function]:
>
> using code : 487-535175 <----------- WHICH IS CORRECT CODE #
I wonder if that's being evaluated as a numerical expression..
> You did not enter the correct code: Script halted, ALL data destroyed.
> you'll have to go back to the website and start over.
> Script HALTED, data destroyed
> ================
>
> Can you spot any differences there? The local server throws NO error,
> notices or warnings. But the Remote Server stops cold on the second
> page, indicating the code is wrong. But it's not; I can see the code;
> it's correct. But it seems to never be seen as correct by my Remote
> Server while my Local Server accepts it perfectly.
>
> What really gets me is it works on one site and not the one I'm trying
> to perpetuate the code to. OH, and both sites are on the same Remote
> Servers at Netfirms.com. Separate accounts of course.
> I'm not using rewrites, no php changes on the Remote Server; both
> sites are on the same server.
> Any thoughts or ideas what I might be doing wrong or where else I
> should be looking?
>
> TIA,
>
> twayne`
When I have had similar issues running phpinfo() on both sites usually
reveals a different php envoironment and gives a clue as to where it's
being set as well.


--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to lead are elected by the least capable of producing, and where the members of society least likely to sustain themselves or succeed, are rewarded with goods and services paid for by the confiscated wealth of a diminishing number of producers.
Re: Hopiing for some leads as to what may be wrong in this code [message #182252 is a reply to message #182251] Thu, 25 July 2013 17:24 Go to previous messageGo to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
On 2013-07-25 4:28 AM, The Natural Philosopher wrote:
> On 25/07/13 00:27, Twayne wrote:
>> Hi all,
....
>>
>> Win 7, PHP 5.3.5, XAMPP local server, standard Unix remote server:
>>
....
>>
>> Complete form consists of three .PHP pages; no HTML. Entry form, check
>> page, mailto() page; pretty standard stuff in that way:
>>
>> ================
>> WORKING CODE ON REMOTE SERVER:
>>
>> Setting the code on landing page:
>> $_SESSION["d"] = $d;
>> --------------------
>>
>> $code= $_POST["code"];
>> if($_SESSION["d"] !== $code) {
>> echo "<br />You did not enter the correct code: Script halted,
>> ALL data destroyed.<br /> you'll have to go back to the website and
>> start over.<br />";
>> die("Script HALTED, data destroyed");
>> session_destroy();
>> exit();
>> }
>> RESULT:
>> page throws no error either with local or remote server: Message is
>> sent successfully.
>>
>> ===============================
>>
>> NON-WORKING CODE ON REMOTE SERVER BUT WORKS ON LOCAL HOST:
>>
>> Setting the code on previous page:
>> $_SESSION["d"] = $d;
>> ----------------------
>> Page with problem:
>> $code= $_POST["code"];
>> if($_SESSION["d"] !== $code) {
>> echo "<br />You did not enter the correct code: Script halted,
>> ALL data destroyed.<br /> you'll have to go back to the website and
>> start over.<br />";
>> die("Script HALTED, data destroyed");
>> session_destroy();
>> exit();
>> }
>>
>> RESULT:
>> [Gets stuck on the second page of the form where PHP
>> sanitize/validation happens; never makes it to last page with the
>> mail() function]:
>>
>> using code : 487-535175 <----------- WHICH IS CORRECT CODE #
> I wonder if that's being evaluated as a numerical expression..
>> You did not enter the correct code: Script halted, ALL data destroyed.
>> you'll have to go back to the website and start over.
>> Script HALTED, data destroyed
>> ================
>>
>> Can you spot any differences there? The local server throws NO error,
>> notices or warnings. But the Remote Server stops cold on the second
>> page, indicating the code is wrong. But it's not; I can see the code;
>> it's correct. But it seems to never be seen as correct by my Remote
>> Server while my Local Server accepts it perfectly.
>>
>> What really gets me is it works on one site and not the one I'm trying
>> to perpetuate the code to. OH, and both sites are on the same Remote
>> Servers at Netfirms.com. Separate accounts of course.
>> I'm not using rewrites, no php changes on the Remote Server; both
>> sites are on the same server.
>> Any thoughts or ideas what I might be doing wrong or where else I
>> should be looking?
>>
>> TIA,
>>
>> twayne`
> When I have had similar issues running phpinfo() on both sites usually
> reveals a different php envoironment and gives a clue as to where it's
> being set as well.

I'm not very good at reading PHPinfo() but the two PHPinfo() displays
(my local Apache server and Remote Server) are the same in all the areas
that would seemingly have anything to do with PHP; same paths, same
dates, same revs, etc. and in its entirety also. I purposely keep my
local PHP version the same as my Servers.

Thanks ... I ran thru the effort again, just to be sure.

Twayne`


>
>
Re: Hopiing for some leads as to what may be wrong in this code [message #182253 is a reply to message #182250] Thu, 25 July 2013 17:37 Go to previous messageGo to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
On 2013-07-24 11:42 PM, Scott Johnson wrote:
> On 7/24/2013 4:27 PM, Twayne wrote:
>> Hi all,
>>
>> I have a seemingly strange thing happening here. I have a contact form
>> on one website that works perfectly and that same form with appropriate
>> changes, results in an error message during a check of a random number
>> (created with mt_rnd() ) on the other site. Both sites are located on
>> the same remote servers.
>>
>> Win 7, PHP 5.3.5, XAMPP local server, standard Unix remote server:
>>
>> Please consider the following:
>>
>> Complete form consists of three .PHP pages; no HTML. Entry form, check
>> page, mailto() page; pretty standard stuff in that way:
>>
>> ================
>> WORKING CODE ON REMOTE SERVER:
>>
>> Setting the code on landing page:
>> $_SESSION["d"] = $d;
>> --------------------
>>
>> $code= $_POST["code"];
>> if($_SESSION["d"] !== $code) {
>> echo "<br />You did not enter the correct code: Script halted, ALL
>> data destroyed.<br /> you'll have to go back to the website and start
>> over.<br />";
>> die("Script HALTED, data destroyed");
>> session_destroy();
>> exit();
>> }
>> RESULT:
>> page throws no error either with local or remote server: Message is sent
>> successfully.
>>
>> ===============================
>>
>> NON-WORKING CODE ON REMOTE SERVER BUT WORKS ON LOCAL HOST:
>>
>> Setting the code on previous page:
>> $_SESSION["d"] = $d;
>> ----------------------
>> Page with problem:
>> $code= $_POST["code"];
>> if($_SESSION["d"] !== $code) {
>> echo "<br />You did not enter the correct code: Script halted, ALL
>> data destroyed.<br /> you'll have to go back to the website and start
>> over.<br />";
>> die("Script HALTED, data destroyed");
>> session_destroy();
>> exit();
>> }
>>
>> RESULT:
>> [Gets stuck on the second page of the form where PHP sanitize/validation
>> happens; never makes it to last page with the mail() function]:
>>
>> using code : 487-535175 <----------- WHICH IS CORRECT CODE
>> You did not enter the correct code: Script halted, ALL data destroyed.
>> you'll have to go back to the website and start over.
>> Script HALTED, data destroyed
>> ================
>>
>> Can you spot any differences there? The local server throws NO error,
>> notices or warnings. But the Remote Server stops cold on the second
>> page, indicating the code is wrong. But it's not; I can see the code;
>> it's correct. But it seems to never be seen as correct by my Remote
>> Server while my Local Server accepts it perfectly.
>>
>> What really gets me is it works on one site and not the one I'm trying
>> to perpetuate the code to. OH, and both sites are on the same Remote
>> Servers at Netfirms.com. Separate accounts of course.
>> I'm not using rewrites, no php changes on the Remote Server; both
>> sites are on the same server.
>> Any thoughts or ideas what I might be doing wrong or where else I
>> should be looking?
>>
>> TIA,
>>
>> twayne`
>
> What is the error message as well?
> What specific behavior where you expecting that you are not getting?

There is no Server message; the error is my own code taking the "bad
code" path and halting the script, so it's my own code that's the
problem, OE something different at the Server. I just did a PHPinfo()
comparison to my local server and they're darned near identical, so why
it succeeds in the other script and not in this current script on a
different sit on the SAME server is beyond me!
Yesterday I ported the complete, untouched code from the working
site to the problem site, and got the same identical problem of the
script halting due to taking the wrong fork in the IF statement! I'm at
a complete loss. Guess I'll have to go thru it more and look for copy
problems et al.

I'm no guru with PHP but this still has me real confused.
The reason I don't post complete codes are, I'm not allowed to for
security reasons. Changing them around to be able to post them would
destroy their integrity for posting here due to the stuff I'd have to do
to be able to post it in the clear. It's also a LOT of code; every page!

Any thoughts, comments are still welcome.

Regards,

Twayne`
Re: Hopiing for some leads as to what may be wrong in this code [message #182254 is a reply to message #182249] Thu, 25 July 2013 17:39 Go to previous messageGo to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
On 2013-07-24 11:04 PM, Jerry Stuckle wrote:
<snip>
>
> Without posting the entire code, any answer would be just a guess.
>
>
See my response to Scott if you're interested in why the complete post
isn't included.
Re: Hopiing for some leads as to what may be wrong in this code [message #182255 is a reply to message #182248] Thu, 25 July 2013 17:51 Go to previous messageGo to next message
Christoph Michael Bec is currently offline  Christoph Michael Bec
Messages: 207
Registered: June 2013
Karma: 0
Senior Member
Twayne wrote:

> $code= $_POST["code"];
> if($_SESSION["d"] !== $code) {
> echo "<br />You did not enter the correct code: Script halted, ALL
> data destroyed.<br /> you'll have to go back to the website and start
> over.<br />";
> die("Script HALTED, data destroyed");
> session_destroy();
> exit();
> }

You may consider checking the actual values of $code and $_SESSION['d']
immediately before the if statement (if you don't have a debugger at
hand, just use a simple var_dump()).

BTW: calling session_destroy() after die() was executed doesn't have any
effect. You'll want to swap both lines and remove the exit().

--
Christoph M. Becker
Re: Hopiing for some leads as to what may be wrong in this code [message #182256 is a reply to message #182255] Thu, 25 July 2013 18:11 Go to previous messageGo to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
On 2013-07-25 1:51 PM, Christoph Michael Becker wrote:
> Twayne wrote:
>
>> $code= $_POST["code"];
>> if($_SESSION["d"] !== $code) {
>> echo "<br />You did not enter the correct code: Script halted, ALL
>> data destroyed.<br /> you'll have to go back to the website and start
>> over.<br />";
>> die("Script HALTED, data destroyed");
>> session_destroy();
>> exit();
>> }
>
> You may consider checking the actual values of $code and $_SESSION['d']
> immediately before the if statement (if you don't have a debugger at
> hand, just use a simple var_dump()).

It's interesting, but I did. A rev back I had an echo for "code" and
Session(... and it prints them just before it throws the error message.
>
> BTW: calling session_destroy() after die() was executed doesn't have any
> effect. You'll want to swap both lines and remove the exit().
>

THAT is wise advice! Thanks I'll do just that; thanks for pointing it out.
Re: Hopiing for some leads as to what may be wrong in this code [message #182257 is a reply to message #182252] Thu, 25 July 2013 18:18 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
On 25/07/13 18:24, Twayne wrote:
> On 2013-07-25 4:28 AM, The Natural Philosopher wrote:
>> On 25/07/13 00:27, Twayne wrote:
>>> Hi all,
> ...
>>>
>>> Win 7, PHP 5.3.5, XAMPP local server, standard Unix remote server:
>>>
> ...
>>>
>>> Complete form consists of three .PHP pages; no HTML. Entry form, check
>>> page, mailto() page; pretty standard stuff in that way:
>>>
>>> ================
>>> WORKING CODE ON REMOTE SERVER:
>>>
>>> Setting the code on landing page:
>>> $_SESSION["d"] = $d;
>>> --------------------
>>>
>>> $code= $_POST["code"];
>>> if($_SESSION["d"] !== $code) {
>>> echo "<br />You did not enter the correct code: Script halted,
>>> ALL data destroyed.<br /> you'll have to go back to the website and
>>> start over.<br />";
>>> die("Script HALTED, data destroyed");
>>> session_destroy();
>>> exit();
>>> }
>>> RESULT:
>>> page throws no error either with local or remote server: Message is
>>> sent successfully.
>>>
>>> ===============================
>>>
>>> NON-WORKING CODE ON REMOTE SERVER BUT WORKS ON LOCAL HOST:
>>>
>>> Setting the code on previous page:
>>> $_SESSION["d"] = $d;
>>> ----------------------
>>> Page with problem:
>>> $code= $_POST["code"];
>>> if($_SESSION["d"] !== $code) {
>>> echo "<br />You did not enter the correct code: Script halted,
>>> ALL data destroyed.<br /> you'll have to go back to the website and
>>> start over.<br />";
>>> die("Script HALTED, data destroyed");
>>> session_destroy();
>>> exit();
>>> }
>>>
>>> RESULT:
>>> [Gets stuck on the second page of the form where PHP
>>> sanitize/validation happens; never makes it to last page with the
>>> mail() function]:
>>>
>>> using code : 487-535175 <----------- WHICH IS CORRECT CODE #
>> I wonder if that's being evaluated as a numerical expression..
>>> You did not enter the correct code: Script halted, ALL data destroyed.
>>> you'll have to go back to the website and start over.
>>> Script HALTED, data destroyed
>>> ================
>>>
>>> Can you spot any differences there? The local server throws NO error,
>>> notices or warnings. But the Remote Server stops cold on the second
>>> page, indicating the code is wrong. But it's not; I can see the code;
>>> it's correct. But it seems to never be seen as correct by my Remote
>>> Server while my Local Server accepts it perfectly.
>>>
>>> What really gets me is it works on one site and not the one I'm trying
>>> to perpetuate the code to. OH, and both sites are on the same Remote
>>> Servers at Netfirms.com. Separate accounts of course.
>>> I'm not using rewrites, no php changes on the Remote Server; both
>>> sites are on the same server.
>>> Any thoughts or ideas what I might be doing wrong or where else I
>>> should be looking?
>>>
>>> TIA,
>>>
>>> twayne`
>> When I have had similar issues running phpinfo() on both sites usually
>> reveals a different php envoironment and gives a clue as to where it's
>> being set as well.
>
> I'm not very good at reading PHPinfo() but the two PHPinfo() displays
> (my local Apache server and Remote Server) are the same in all the
> areas that would seemingly have anything to do with PHP; same paths,
> same dates, same revs, etc. and in its entirety also. I purposely keep
> my local PHP version the same as my Servers.
>

I was thinking more of stuff like magic quotes, charsets and other minor
things that might affect how the code was interpreted.

The other place I routinely look, because I can, is apache error logs.
Thats where PHP errors tend to popup up if not displayed onscreen.

> Thanks ... I ran thru the effort again, just to be sure.
>
> Twayne`
>
>
>>
>>
>


--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to lead are elected by the least capable of producing, and where the members of society least likely to sustain themselves or succeed, are rewarded with goods and services paid for by the confiscated wealth of a diminishing number of producers.
Re: Hopiing for some leads as to what may be wrong in this code [message #182258 is a reply to message #182255] Thu, 25 July 2013 18:24 Go to previous messageGo to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
On 2013-07-25 1:51 PM, Christoph Michael Becker wrote:
> Twayne wrote:
>
>> $code= $_POST["code"];
>> if($_SESSION["d"] !== $code) {
>> echo "<br />You did not enter the correct code: Script halted, ALL
>> data destroyed.<br /> you'll have to go back to the website and start
>> over.<br />";
>> die("Script HALTED, data destroyed");
>> session_destroy();
>> exit();
>> }
>
> You may consider checking the actual values of $code and $_SESSION['d']
> immediately before the if statement (if you don't have a debugger at
> hand, just use a simple var_dump()).
>
> BTW: calling session_destroy() after die() was executed doesn't have any
> effect. You'll want to swap both lines and remove the exit().
>

HUH! You seem to have driven something home! I fixed up the changes you
recommended, tried it, and drew a 500 Error from the server. Put it back
the way it was and still getting a 500 error. It's not definitive, but
it suggest something went seriously wrong.
Thanks for even that much,

Twayne`
Re: Hopiing for some leads as to what may be wrong in this code [message #182259 is a reply to message #182256] Thu, 25 July 2013 18:31 Go to previous messageGo to next message
Christoph Michael Bec is currently offline  Christoph Michael Bec
Messages: 207
Registered: June 2013
Karma: 0
Senior Member
Twayne wrote:

> On 2013-07-25 1:51 PM, Christoph Michael Becker wrote:
>> Twayne wrote:
>>
>>> $code= $_POST["code"];
>>> if($_SESSION["d"] !== $code) {
>>> echo "<br />You did not enter the correct code: Script halted, ALL
>>> data destroyed.<br /> you'll have to go back to the website and start
>>> over.<br />";
>>> die("Script HALTED, data destroyed");
>>> session_destroy();
>>> exit();
>>> }
>>
>> You may consider checking the actual values of $code and $_SESSION['d']
>> immediately before the if statement (if you don't have a debugger at
>> hand, just use a simple var_dump()).
>
> It's interesting, but I did. A rev back I had an echo for "code" and
> Session(... and it prints them just before it throws the error message.

And both had exactly the same value (a leading or trailing space, for
instance, make a big difference here) and the same *type*? Then the
body of the if statement won't be executed.
Re: Hopiing for some leads as to what may be wrong in this code [message #182260 is a reply to message #182256] Fri, 26 July 2013 00:37 Go to previous messageGo to next message
Norman Peelman is currently offline  Norman Peelman
Messages: 126
Registered: September 2010
Karma: 0
Senior Member
On 07/25/2013 02:11 PM, Twayne wrote:
> On 2013-07-25 1:51 PM, Christoph Michael Becker wrote:
>> Twayne wrote:
>>
>>> $code= $_POST["code"];
>>> if($_SESSION["d"] !== $code) {
>>> echo "<br />You did not enter the correct code: Script halted, ALL
>>> data destroyed.<br /> you'll have to go back to the website and start
>>> over.<br />";
>>> die("Script HALTED, data destroyed");
>>> session_destroy();
>>> exit();
>>> }
>>
>> You may consider checking the actual values of $code and $_SESSION['d']
>> immediately before the if statement (if you don't have a debugger at
>> hand, just use a simple var_dump()).
>
> It's interesting, but I did. A rev back I had an echo for "code" and
> Session(... and it prints them just before it throws the error message.
>>
>> BTW: calling session_destroy() after die() was executed doesn't have any
>> effect. You'll want to swap both lines and remove the exit().
>>
>
> THAT is wise advice! Thanks I'll do just that; thanks for pointing it out.
>

$code= $_POST["code"];
echo "<pre>";
var_dump($_SESSION["d"]);
var_dump($code);
echo "</pre>";
if($_SESSION["d"] !== $code) {
echo "<br />You did not enter the correct code: Script halted, ALL
data destroyed.<br /> you'll have to go back to the website and start
over.<br />";
die("Script HALTED, data destroyed");
session_destroy();
exit();


You need to make sure that both variables are of the same *value* and
*type*. Another way to check would be to change !== to != (or <>). The
only way your branch gets executed is if they do not match both *value*
and *type*.

--
Norman
Registered Linux user #461062
-Have you been to www.php.net yet?-
Re: Hopiing for some leads as to what may be wrong in this code [message #182276 is a reply to message #182260] Sat, 27 July 2013 10:17 Go to previous messageGo to next message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
Senior Member
Norman Peelman wrote:

> On 07/25/2013 02:11 PM, Twayne wrote:
>> On 2013-07-25 1:51 PM, Christoph Michael Becker wrote:
>>> Twayne wrote:
>>>> $code= $_POST["code"];
>>>> if($_SESSION["d"] !== $code) {
>>>> echo "<br />You did not enter the correct code: Script halted,
>>>> ALL
>>>> data destroyed.<br /> you'll have to go back to the website and start
>>>> over.<br />";
>>>> die("Script HALTED, data destroyed");
>>>> session_destroy();
>>>> exit();
>>>> }
>>>
>>> You may consider checking the actual values of $code and $_SESSION['d']
>>> immediately before the if statement (if you don't have a debugger at
>>> hand, just use a simple var_dump()).
>>
>> It's interesting, but I did. A rev back I had an echo for "code" and
>> Session(... and it prints them just before it throws the error message.
>>>
>>> BTW: calling session_destroy() after die() was executed doesn't have any
>>> effect. You'll want to swap both lines and remove the exit().
>>>
>>
>> THAT is wise advice! Thanks I'll do just that; thanks for pointing it
>> out.
>>
>
> $code= $_POST["code"];
> echo "<pre>";
> var_dump($_SESSION["d"]);
> var_dump($code);
> echo "</pre>";
> if($_SESSION["d"] !== $code) {

if ($_SESSION["d"] !== $code) {

(it is not a call)

> echo "<br />You did not enter the correct code: Script halted, ALL
> data destroyed.<br /> you'll have to go back to the website and start
> over.<br />";
> die("Script HALTED, data destroyed");
> session_destroy();
> exit();
>
>
> You need to make sure that both variables are of the same *value* and
> *type*. Another way to check would be to change !== to != (or <>). The
> only way your branch gets executed is if they do not match both *value*
> and *type*.

What are you getting at? I do not see how a $_POST element could ever be
*not* a string, and the result of “!==” can be false even when the two
operands *are* of the same type. And the code must be a string here (it
contains “-”), so $_SESSION['d'] would be a string.

The difference is perhaps in the session not being started or recognized on
one PHP host, but on the other. If the session is not started, it could be
that session information cannot be written to the filesystem; if the session
is not recognized, it could be that the session cookie is not set on the
client-side due to user settings.

ISTM there still is not enough information in the posting; for example, the
part that *sets* $_SESSION['d'] is missing.

The OP should take heed of

<http://www.catb.org/~esr/faqs/smart-questions.html>

and stop wasting everybody's time with guessing games.


PointedEars
--
Sometimes, what you learn is wrong. If those wrong ideas are close to the
root of the knowledge tree you build on a particular subject, pruning the
bad branches can sometimes cause the whole tree to collapse.
-- Mike Duffy in cljs, <news:Xns9FB6521286DB8invalidcom(at)94(dot)75(dot)214(dot)39>
RESOLVED Re: Hopiing for some leads as to what may be wrong in this code [message #182292 is a reply to message #182248] Sat, 27 July 2013 15:05 Go to previous messageGo to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
GOT IT! Finally.

Turns out my php.ini for my remote site was damaged. I've been running
around the pole for a week or more with them, getting various answers,
including it was my own fault and they won't help people with coding.
Jeezum Crow!
Everything was pointing to my server host, and not me, so: Today I
got fed up enough to try a chat, and a phone call if that didn't help.
Just goes to show: The chat tech asked me to hold while he checked
my accounts and a few seconds later was back, problem solved!! I
learned long ago to not give Support departments a chance to push things
back on me and just keep trying until you get the right tech or
supervisor or whatever. How one guy could look at whatever he looked at
and fix it right away and the others couldn't, well, speaks volumes
about support departments.

Thanks for all the excellent responses and attempts to assist. This is a
great ng!

Best Regards,

Twayne`




On 2013-07-24 7:27 PM, Twayne wrote:
> Hi all,
>
> I have a seemingly strange thing happening here. I have a contact form
> on one website that works perfectly and that same form with appropriate
> changes, results in an error message during a check of a random number
> (created with mt_rnd() ) on the other site. Both sites are located on
> the same remote servers.
>
> Win 7, PHP 5.3.5, XAMPP local server, standard Unix remote server:
>
> Please consider the following:
>
> Complete form consists of three .PHP pages; no HTML. Entry form, check
> page, mailto() page; pretty standard stuff in that way:
>
> ================
> WORKING CODE ON REMOTE SERVER:
>
> Setting the code on landing page:
> $_SESSION["d"] = $d;
> --------------------
>
> $code= $_POST["code"];
> if($_SESSION["d"] !== $code) {
> echo "<br />You did not enter the correct code: Script halted, ALL
> data destroyed.<br /> you'll have to go back to the website and start
> over.<br />";
> die("Script HALTED, data destroyed");
> session_destroy();
> exit();
> }
> RESULT:
> page throws no error either with local or remote server: Message is sent
> successfully.
>
> ===============================
>
> NON-WORKING CODE ON REMOTE SERVER BUT WORKS ON LOCAL HOST:
>
> Setting the code on previous page:
> $_SESSION["d"] = $d;
> ----------------------
> Page with problem:
> $code= $_POST["code"];
> if($_SESSION["d"] !== $code) {
> echo "<br />You did not enter the correct code: Script halted, ALL
> data destroyed.<br /> you'll have to go back to the website and start
> over.<br />";
> die("Script HALTED, data destroyed");
> session_destroy();
> exit();
> }
>
> RESULT:
> [Gets stuck on the second page of the form where PHP sanitize/validation
> happens; never makes it to last page with the mail() function]:
>
> using code : 487-535175 <----------- WHICH IS CORRECT CODE
> You did not enter the correct code: Script halted, ALL data destroyed.
> you'll have to go back to the website and start over.
> Script HALTED, data destroyed
> ================
>
> Can you spot any differences there? The local server throws NO error,
> notices or warnings. But the Remote Server stops cold on the second
> page, indicating the code is wrong. But it's not; I can see the code;
> it's correct. But it seems to never be seen as correct by my Remote
> Server while my Local Server accepts it perfectly.
>
> What really gets me is it works on one site and not the one I'm trying
> to perpetuate the code to. OH, and both sites are on the same Remote
> Servers at Netfirms.com. Separate accounts of course.
> I'm not using rewrites, no php changes on the Remote Server; both
> sites are on the same server.
> Any thoughts or ideas what I might be doing wrong or where else I
> should be looking?
>
> TIA,
>
> twayne`
Re: Hopiing for some leads as to what may be wrong in this code [message #182317 is a reply to message #182276] Sun, 28 July 2013 05:01 Go to previous messageGo to next message
Fiver is currently offline  Fiver
Messages: 35
Registered: July 2013
Karma: 0
Member
On 2013-07-27 12:17, Thomas 'PointedEars' Lahn wrote:
> I do not see how a $_POST element could ever be *not* a string

<input name="foo[]" value="bar">

regards,
5er
Re: Hopiing for some leads as to what may be wrong in this code [message #182328 is a reply to message #182317] Sun, 28 July 2013 15:48 Go to previous messageGo to next message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
Senior Member
Fiver wrote:

> On 2013-07-27 12:17, Thomas 'PointedEars' Lahn wrote:
>> I do not see how a $_POST element could ever be *not* a string
>
> <input name="foo[]" value="bar">

True, I forgot about that. But in this case you would not use a simple
comparison.


PointedEars
--
> If you get a bunch of authors […] that state the same "best practices"
> in any programming language, then you can bet who is wrong or right...
Not with javascript. Nonsense propagates like wildfire in this field.
-- Richard Cornford, comp.lang.javascript, 2011-11-14
Re: Hopiing for some leads as to what may be wrong in this code [message #182335 is a reply to message #182328] Sun, 28 July 2013 18:17 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
On 28/07/13 16:48, Thomas 'PointedEars' Lahn wrote:

If you get a bunch of authors […] that state the same "best practices"
in any programming language, then you can bet who is wrong or right...

Not with javascript. Nonsense propagates like wildfire in this field.
-- Richard Cornford, comp.lang.javascript, 2011-11-14


I think javascript is probably the ugliest language I have ever had to
program in really. Even worse than PHP.

By trying to make it 'easy for stupes' they make it very hard for people
who understand exactly what they want it to do, by hiding the means by
which it is to be done.

--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to lead are elected by the least capable of producing, and where the members of society least likely to sustain themselves or succeed, are rewarded with goods and services paid for by the confiscated wealth of a diminishing number of producers.
Re: Hopiing for some leads as to what may be wrong in this code [message #182447 is a reply to message #182249] Sun, 04 August 2013 20:24 Go to previous messageGo to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
On 2013-07-24 11:04 PM, Jerry Stuckle wrote:
> On 7/24/2013 7:27 PM, Twayne wrote:
>> Hi all,
>>
>> I have a seemingly strange thing happening here. I have a contact form
>> on one website that works perfectly and that same form with appropriate
>> changes, results in an error message during a check of a random number
>> (created with mt_rnd() ) on the other site. Both sites are located on
>> the same remote servers.
>>
>> Win 7, PHP 5.3.5, XAMPP local server, standard Unix remote server:
>>
....

>>
>> What really gets me is it works on one site and not the one I'm trying
>> to perpetuate the code to. OH, and both sites are on the same Remote
>> Servers at Netfirms.com. Separate accounts of course.
>> I'm not using rewrites, no php changes on the Remote Server; both
>> sites are on the same server.
>> Any thoughts or ideas what I might be doing wrong or where else I
>> should be looking?
>>
>> TIA,
>>
>> twayne`
>
> Without posting the entire code, any answer would be just a guess.
>
>
OR, as another person pointed out, you could have suggested the same
thing he did. But you didn't.

Another post from you with no content.
Re: Hopiing for some leads as to what may be wrong in this code [message #182455 is a reply to message #182447] Mon, 05 August 2013 02:08 Go to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 8/4/2013 4:24 PM, Twayne wrote:
> On 2013-07-24 11:04 PM, Jerry Stuckle wrote:
>> On 7/24/2013 7:27 PM, Twayne wrote:
>>> Hi all,
>>>
>>> I have a seemingly strange thing happening here. I have a contact form
>>> on one website that works perfectly and that same form with appropriate
>>> changes, results in an error message during a check of a random number
>>> (created with mt_rnd() ) on the other site. Both sites are located on
>>> the same remote servers.
>>>
>>> Win 7, PHP 5.3.5, XAMPP local server, standard Unix remote server:
>>>
> ...
>
>>>
>>> What really gets me is it works on one site and not the one I'm trying
>>> to perpetuate the code to. OH, and both sites are on the same Remote
>>> Servers at Netfirms.com. Separate accounts of course.
>>> I'm not using rewrites, no php changes on the Remote Server; both
>>> sites are on the same server.
>>> Any thoughts or ideas what I might be doing wrong or where else I
>>> should be looking?
>>>
>>> TIA,
>>>
>>> twayne`
>>
>> Without posting the entire code, any answer would be just a guess.
>>
>>
> OR, as another person pointed out, you could have suggested the same
> thing he did. But you didn't.
>
> Another post from you with no content.
>

Trolling again, I see.

No, I didn't suggest what someone else said, because his was just a guess.

I prefer to diagnose the problem and give a *CORRECT* answer - not play
guessing games.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Adding (Add - Subtract) values from two different tables to another table
Next Topic: fetch items from a row
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Jul 27 13:06:05 GMT 2024

Total time taken to generate the page: 0.02855 seconds