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

Home » Imported messages » comp.lang.php » Code Stops Working
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Code Stops Working [message #172380] Tue, 15 February 2011 22:06 Go to next message
mrc2323 is currently offline  mrc2323
Messages: 12
Registered: February 2011
Karma: 0
Junior Member
I have assumed ownership of a site that has a lot of PHP code - and I
don't have much experience with the language and environment. The site
is:

www.raceplaceevents.com

The situation is that I've made a small change to one of the sub-
pages that seems to render it not working. The sub-page is:

results_ques_probs.php

and can be accessed from the main page by clicking the "Results
Questions Or Problems" button of the left.
When clicked, the action _appears_ to work. If one fills out the
required fields and clicks the "Submit" button, everything seems okay:
no errors or messages. However, no e-mail is sent to either of the 2
addresses, nor is there a status message sent to the sender's e-mail. 8
<{{
The change I made is in the HTML table code near the bottom of the
code, where I commented out one of the prompts. (You can see the change
I made if you look at the code.) Again, the remaining code appears to
function, but no e-mail is sent and no error is reported by the browsers
I've tested. Please advise. TIA
Re: Code Stops Working [message #172381 is a reply to message #172380] Tue, 15 February 2011 22:35 Go to previous messageGo to next message
Captain Paralytic is currently offline  Captain Paralytic
Messages: 204
Registered: September 2010
Karma: 0
Senior Member
On Feb 15, 10:06 pm, mrc2...@cox.net (Mike Copeland) wrote:
>    I have assumed ownership of a site that has a lot of PHP code - and I
> don't have much experience with the language and environment.  The site
> is:
>
>        www.raceplaceevents.com
>
>    The situation is that I've made a small change to one of the sub-
> pages that seems to render it not working.  The sub-page is:
>
>         results_ques_probs.php
>
> and can be accessed from the main page by clicking the "Results
> Questions Or Problems" button of the left.
>    When clicked, the action _appears_ to work.  If one fills out the
> required fields and clicks the "Submit" button, everything seems okay:
> no errors or messages.  However, no e-mail is sent to either of the 2
> addresses, nor is there a status message sent to the sender's e-mail.  8
> <{{
>    The change I made is in the HTML table code near the bottom of the
> code, where I commented out one of the prompts.  (You can see the change
> I made if you look at the code.)  Again, the remaining code appears to
> function, but no e-mail is sent and no error is reported by the browsers
> I've tested.  Please advise.  TIA

You are confusing HTML and PHP. We cannot see the php code, only the
HTML rendered by it.
Re: Code Stops Working [message #172382 is a reply to message #172380] Tue, 15 February 2011 23:02 Go to previous messageGo to next message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma: 0
Senior Member
In article <MPG(dot)27c4a6b086a6d5169896a5(at)news(dot)eternal-september(dot)org>,
mrc2323(at)cox(dot)net (Mike Copeland) wrote:

> I have assumed ownership of a site that has a lot of PHP code - and I
> don't have much experience with the language and environment. The site
> is:
>
> www.raceplaceevents.com
>
> The situation is that I've made a small change to one of the sub-
> pages that seems to render it not working. The sub-page is:
>
> results_ques_probs.php
>
> and can be accessed from the main page by clicking the "Results
> Questions Or Problems" button of the left.
> When clicked, the action _appears_ to work. If one fills out the
> required fields and clicks the "Submit" button, everything seems okay:
> no errors or messages. However, no e-mail is sent to either of the 2
> addresses, nor is there a status message sent to the sender's e-mail. 8
> <{{
> The change I made is in the HTML table code near the bottom of the
> code, where I commented out one of the prompts. (You can see the change
> I made if you look at the code.) Again, the remaining code appears to
> function, but no e-mail is sent and no error is reported by the browsers
> I've tested. Please advise. TIA

Hmmm, how are we supposed to see the PHP source? All I can see is the
HTML resulting from the PHP script running. Personally I've never used
these <!-- comments so I'm not sure what they do.

I'd suspect that the PHP code is looking for the "tag_collected" element
and not finding it, is giving up. Have you looked through the PHP code
to see where that is used?

By the way, there's a typo on this page in "Did you finish near of with
anyone you know?"

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
Re: Code Stops Working [message #172383 is a reply to message #172380] Tue, 15 February 2011 23:24 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
On 15/02/11 22:06, Mike Copeland wrote:

> I have assumed ownership of a site that has a lot of PHP code - and I
> don't have much experience with the language and environment. The site
> is:
>
> www.raceplaceevents.com
>
> The situation is that I've made a small change to one of the sub-
> pages that seems to render it not working. The sub-page is:
>
> results_ques_probs.php
>
> and can be accessed from the main page by clicking the "Results
> Questions Or Problems" button of the left.
> When clicked, the action _appears_ to work. If one fills out the
> required fields and clicks the "Submit" button, everything seems okay:
> no errors or messages. However, no e-mail is sent to either of the 2
> addresses, nor is there a status message sent to the sender's e-mail. 8
> <{{
> The change I made is in the HTML table code near the bottom of the
> code, where I commented out one of the prompts. (You can see the change
> I made if you look at the code.) Again, the remaining code appears to
> function, but no e-mail is sent and no error is reported by the browsers
> I've tested. Please advise. TIA

Unfortunately we can't see the php code, just the html that it generates.

However, I see the following conflict when I look at the page html:

<form name="form_name" ....... onclick="check(this)">

<input name="name" .... >

</form>

and the javascript:

function check(form) {
name = form.name;
if (trim(name.value) == "") /* barf gently */;
}

If form.name is the name attribute of the form, then it has no value
attribute, so I'm wondering what trim which I assume is a locally
defined function will do when given an undefined value ....

Whether this is related to your problem or not I don't know.

Rgds

Denis McMahon
Re: Code Stops Working [message #172384 is a reply to message #172382] Tue, 15 February 2011 23:53 Go to previous messageGo to next message
sheldonlg is currently offline  sheldonlg
Messages: 166
Registered: September 2010
Karma: 0
Senior Member
On 2/15/2011 6:02 PM, Tim Streater wrote:
> Personally I've never used these <!-- comments so I'm not sure what they
> do.

They are comment beginnings in HTML. The comment ends with -->

They serve the same purpose as the pair /* */ serves in php.

--
Shelly
Re: Code Stops Working [message #172385 is a reply to message #172383] Wed, 16 February 2011 00:36 Go to previous messageGo to next message
mrc2323 is currently offline  mrc2323
Messages: 12
Registered: February 2011
Karma: 0
Junior Member
In article <4d5b0bf7$0$8054$bed64819(at)gradwell(dot)net>,
denis(dot)m(dot)f(dot)mcmahon(at)googlemail(dot)com says...
> On 15/02/11 22:06, Mike Copeland wrote:
>
>> The change I made is in the HTML table code near the bottom of the
>> code, where I commented out one of the prompts. (You can see the change
>> I made if you look at the code.) Again, the remaining code appears to
>> function, but no e-mail is sent and no error is reported by the browsers
>> I've tested. Please advise. TIA
>
> Unfortunately we can't see the php code, just the html that it generates.
>
> However, I see the following conflict when I look at the page html:
>
> <form name="form_name" ....... onclick="check(this)">
>
> <input name="name" .... >
>
> </form>
>
> and the javascript:
>
> function check(form) {
> name = form.name;
> if (trim(name.value) == "") /* barf gently */;
> }
>
> If form.name is the name attribute of the form, then it has no value
> attribute, so I'm wondering what trim which I assume is a locally
> defined function will do when given an undefined value ....
>
> Whether this is related to your problem or not I don't know.

My apologies to all: I didn't realize that the PHP source isn't
accessible. Here it is (but it's messy due to the tabs, etc.). Hope
this helps...
<?php
include "include/page_top.php";
?>

<table border="0" style="width:455px">
<tr>
<td>
<div class="header_text" align="center">
RESULTS QUESTIONS OR PROBLEMS
</div>
</td>
</tr>
<tr>
<td class="spacer">&nbsp;</td>
</tr>
<tr>
<td class="page_text">
If there is no finish time listed or your
feel the listed time is incorrect, please fill in and submit the below
info:
</td>
</tr>
<tr>
<td class="spacer">&nbsp;</td>
</tr>
<tr>
<td align="center" >
<?php

//add form submition code
if(isset($submt_btn)) {

$to =
"results(at)raceplaceevents(dot)com,mrc2323(at)cox(dot)net";
$from =
"results(at)raceplaceevents(dot)com";
$subject = "Race Place
Events Website Results Question/Problem Submitted";
$body1 = "Below is the
info submitted on the website:".
"\n\nName:
$name".
"\nEmail:
$email".
"\nAge:
$age".
"\nSex:
$sex".
"\nBib
Number: $bib_number".
"\nName of
Event: $event_entered".
"\nEvent
Distance: $event_distance".
"\nHas
Finish Time?: $has_finish_time".
"\nFinish
Time: $finish_time".

"\nFinished Near Someone?: $finish_near_someone".
"\nTheir
Name or Bib #: $friend_name_bib".
"\nWas Tag
Collected?: $tag_collected".

"\nAdditional Comments: $add_comments";

$eml_result = email($to,
$subject, $from, $body1);

if($eml_result) {
do_msg("<br>Your
info has been submitted. You will be contacted in the next couple of
days.<br><br>");
} else {
do_msg("<br>There
was a problem sending your info. Please email <a
href='mailto:results(at)raceplaceevents(dot)com'>results(at)raceplaceevents(dot)com
</a> about your results problem.<br>");
}

} else {

?>
<script language="JavaScript">

function checkInput(form) {

var name = form.name;
var email = form.email;
var event = form.event_entered;

if(trim(name.value) == "") {
notifyInvalidInput("Name
is a required field. Please enter your name.", name);
return false;
} else if(trim(email.value) ==
"") {
notifyInvalidInput
("Email is a required field. Please enter.", email);
return false;
} else if(trim(event.value) ==
"") {
notifyInvalidInput("Name
of Event is a required field. Please enter.", event);
return false;
}else{
return true;
}

}

</script>

<form name="ques_form" action="<?= $_SERVER
['PHP_SELF'] ?>" method="get" onsubmit="return checkInput(this)">

<div class="bordered_text"
style="width:450px">
<table class="page_text">
<tr>
<td class="spacer" colspan="2">
</td>
</tr>
<tr>
<td>*Name:</td>
<td><input type="text"
name="name" class="input"></td>
</tr>
<tr>
<td>*Email:</td>
<td><input type="text"
name="email" class="input"></td>
</tr>
<tr>
<td>Age:</td>
<td><input type="text"
name="age" class="input" style="width:70px"></td>
</tr>
<tr>
<td>Sex:</td>
<td><select name="sex">
<option
value="Male">Male</option>
<option
value="Female">Female</option>
</select>
</td>
</tr>
<tr>
<td>Bib Number:</td>
<td><input type="text"
name="bib_number" class="input" style="width:70px"></td>
</tr>
<tr>
<td>*Name of Event:</td>
<td><input type="text"
name="event_entered" class="input"></td>
</tr>
<tr>
<td>Event Distance:</td>
<td><input type="text"
name="event_distance" class="input"></td>
</tr>
<tr>
<td class="spacer" colspan="2">
</td>
</tr>
<tr>
<td colspan="2">Did you see the
clock or have a watch with your finish time?
<select
name="has_finish_time">
<option
value="No">No</option>
<option
value="Yes">Yes</option>
</select>
</td>
</tr>
<tr>
<td colspan="2">
What was your time?
<input type="text" name="finish_time" class="input" style="width:70px">
</td>
</tr>
<tr>
<td class="spacer" colspan="2">
</td>
</tr>
<tr>
<td colspan="2">Did you finish
near of with anyone you know?
<select
name="finish_near_someone">
<option
value="No">No</option>
<option
value="Yes">Yes</option>
</select>
</td>
</tr>
<tr>
<td colspan="2">
What was their name
and/or bib number?<br><input type="text" name="friend_name_bib"
class="input" style="width:300px">
</td>
</tr>
<tr>
<td class="spacer" colspan="2">
</td>
</tr>
<!--
<tr>
<td colspan="2">Was your tag
collected at the end of the finish chute?
<select
name="tag_collected">
<option
value="No">No</option>
<option
value="Yes">Yes</option>
</select>
</td>
</tr>
-->
<tr>
<td class="spacer" colspan="2">
</td>
</tr>
<tr>
<td valign="top">Additional
Comments:</td>
<td><textarea
name="add_comments" class="input" rows="3"></textarea></td>
</tr>
<tr>
<td class="spacer" colspan="2">
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" name="submt_btn" class="button" value="Submit">
</td>
</tr>
<tr>
<td class="spacer" colspan="2">
</td>
</tr>
<tr>
<td colspan="2" align="left">*
<span style="font-style:italic">Required Field</span></td>
</tr>
</table>
</div>
</form>

<?php
}
?>

</td>
</tr>
</table>

<?php
include "include/page_bottom.php";
?>
Re: Code Stops Working [message #172386 is a reply to message #172385] Wed, 16 February 2011 01:05 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 2/15/2011 7:36 PM, Mike Copeland wrote:
> if(isset($submt_btn)) {

Unless you have register_globals enabled (which it should NOT be), this
value will not be set. You need to use $_GET['submt_btn'] instead (and
the same is true for the other form fields).

If this were a POST request in the form (which it really should be),
then you would use $_POST['submt_btn'], etc.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: Code Stops Working [message #172387 is a reply to message #172386] Wed, 16 February 2011 01:16 Go to previous messageGo to next message
mrc2323 is currently offline  mrc2323
Messages: 12
Registered: February 2011
Karma: 0
Junior Member
In article <ijf7t3$u6h$1(at)news(dot)eternal-september(dot)org>,
jstucklex(at)attglobal(dot)net says...
> On 2/15/2011 7:36 PM, Mike Copeland wrote:
>> if(isset($submt_btn)) {
>
> Unless you have register_globals enabled (which it should NOT be), this
> value will not be set. You need to use $_GET['submt_btn'] instead (and
> the same is true for the other form fields).
>
> If this were a POST request in the form (which it really should be),
> then you would use $_POST['submt_btn'], etc.

Hmmmm...I don't know about this "register_globals" thing. How do I
determine (and change) this?
Re: Code Stops Working [message #172388 is a reply to message #172385] Wed, 16 February 2011 01:40 Go to previous messageGo to next message
P E Schoen is currently offline  P E Schoen
Messages: 86
Registered: January 2011
Karma: 0
Member
"Mike Copeland" wrote in message
news:MPG(dot)27c4ca15863d82319896a6(at)news(dot)eternal-september(dot)org...

> $eml_result = email($to,
> $subject, $from, $body1);

I'm not a PHP expert, but it seems that you have the $from and $body1
reversed.

The correct syntax is:

$to = "someone(at)example(dot)com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse(at)example(dot)com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);

Also, the server may have some requirements for the sender ($from). This is
an example from my sendmail.ini for my xampp Apache server for Localhost:

# Set default values for all following accounts.
defaults
logfile "C:\xampp\sendmail\sendmail.log"

# Mercury
account Mercury
host localhost
from postmaster@localhost
auth off

# Set a default account
account default : Mercury

You might need to do something else for a remote server. This might help:
http://email.about.com/od/emailprogrammingtips/qt/Configure_PHP_to_Use_a_Lo cal_Mail_Server_for_Sending_Mail.htm

Paul
Re: Code Stops Working [message #172389 is a reply to message #172387] Wed, 16 February 2011 03:05 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 2/15/2011 8:16 PM, Mike Copeland wrote:
> In article<ijf7t3$u6h$1(at)news(dot)eternal-september(dot)org>,
> jstucklex(at)attglobal(dot)net says...
>> On 2/15/2011 7:36 PM, Mike Copeland wrote:
>>> if(isset($submt_btn)) {
>>
>> Unless you have register_globals enabled (which it should NOT be), this
>> value will not be set. You need to use $_GET['submt_btn'] instead (and
>> the same is true for the other form fields).
>>
>> If this were a POST request in the form (which it really should be),
>> then you would use $_POST['submt_btn'], etc.
>
> Hmmmm...I don't know about this "register_globals" thing. How do I
> determine (and change) this?

http://www.lmgtfy.com/?q=register_globals

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: Code Stops Working [message #172390 is a reply to message #172380] Wed, 16 February 2011 04:36 Go to previous messageGo to next message
richard is currently offline  richard   
Messages: 213
Registered: June 2013
Karma: 0
Senior Member
On Tue, 15 Feb 2011 15:06:01 -0700, Mike Copeland wrote:

> I have assumed ownership of a site that has a lot of PHP code - and I
> don't have much experience with the language and environment. The site
> is:
>
> www.raceplaceevents.com
>
> The situation is that I've made a small change to one of the sub-
> pages that seems to render it not working. The sub-page is:
>
> results_ques_probs.php
>
> and can be accessed from the main page by clicking the "Results
> Questions Or Problems" button of the left.
> When clicked, the action _appears_ to work. If one fills out the
> required fields and clicks the "Submit" button, everything seems okay:
> no errors or messages. However, no e-mail is sent to either of the 2
> addresses, nor is there a status message sent to the sender's e-mail. 8
> <{{
> The change I made is in the HTML table code near the bottom of the
> code, where I commented out one of the prompts. (You can see the change
> I made if you look at the code.) Again, the remaining code appears to
> function, but no e-mail is sent and no error is reported by the browsers
> I've tested. Please advise. TIA

One thing I have avoided doing is using words in variables and strings that
may cause confusion.
As "name" has a purpose in both html and php, I would never use that as a
variable in any fashion. Instead, I would use something like "aname".
Your problem could be that simple.
Re: Code Stops Working [message #172391 is a reply to message #172382] Wed, 16 February 2011 04:39 Go to previous messageGo to next message
richard is currently offline  richard   
Messages: 213
Registered: June 2013
Karma: 0
Senior Member
On Tue, 15 Feb 2011 23:02:47 +0000, Tim Streater wrote:

> In article <MPG(dot)27c4a6b086a6d5169896a5(at)news(dot)eternal-september(dot)org>,
> mrc2323(at)cox(dot)net (Mike Copeland) wrote:
>
>> I have assumed ownership of a site that has a lot of PHP code - and I
>> don't have much experience with the language and environment. The site
>> is:
>>
>> www.raceplaceevents.com
>>
>> The situation is that I've made a small change to one of the sub-
>> pages that seems to render it not working. The sub-page is:
>>
>> results_ques_probs.php
>>
>> and can be accessed from the main page by clicking the "Results
>> Questions Or Problems" button of the left.
>> When clicked, the action _appears_ to work. If one fills out the
>> required fields and clicks the "Submit" button, everything seems okay:
>> no errors or messages. However, no e-mail is sent to either of the 2
>> addresses, nor is there a status message sent to the sender's e-mail. 8
>> <{{
>> The change I made is in the HTML table code near the bottom of the
>> code, where I commented out one of the prompts. (You can see the change
>> I made if you look at the code.) Again, the remaining code appears to
>> function, but no e-mail is sent and no error is reported by the browsers
>> I've tested. Please advise. TIA
>
> Hmmm, how are we supposed to see the PHP source? All I can see is the
> HTML resulting from the PHP script running. Personally I've never used
> these <!-- comments so I'm not sure what they do.
>
> I'd suspect that the PHP code is looking for the "tag_collected" element
> and not finding it, is giving up. Have you looked through the PHP code
> to see where that is used?
>
> By the way, there's a typo on this page in "Did you finish near of with
> anyone you know?"

In html

<!-- this is a comment -->

To function properly the ending --> must be as shown.
Anything within the < > is not acted upon.
Re: Code Stops Working [message #172392 is a reply to message #172380] Wed, 16 February 2011 08:09 Go to previous messageGo to next message
John Andersen is currently offline  John Andersen
Messages: 1
Registered: February 2011
Karma: 0
Junior Member
Undo your change and see if it works again!
If it does, concentrate on finding the error within your change!
If it doesn't work, follow the leads from the other in this group.
Enjoy,
John

On 15 Feb., 23:06, mrc2...@cox.net (Mike Copeland) wrote:
>    I have assumed ownership of a site that has a lot of PHP code - and I
> don't have much experience with the language and environment.  The site
> is:
>
>        www.raceplaceevents.com
>
>    The situation is that I've made a small change to one of the sub-
> pages that seems to render it not working.  The sub-page is:
>
>         results_ques_probs.php
>
> and can be accessed from the main page by clicking the "Results
> Questions Or Problems" button of the left.
>    When clicked, the action _appears_ to work.  If one fills out the
> required fields and clicks the "Submit" button, everything seems okay:
> no errors or messages.  However, no e-mail is sent to either of the 2
> addresses, nor is there a status message sent to the sender's e-mail.  8
> <{{
>    The change I made is in the HTML table code near the bottom of the
> code, where I commented out one of the prompts.  (You can see the change
> I made if you look at the code.)  Again, the remaining code appears to
> function, but no e-mail is sent and no error is reported by the browsers
> I've tested.  Please advise.  TIA
Re: Code Stops Working [message #172393 is a reply to message #172392] Wed, 16 February 2011 08:27 Go to previous messageGo to next message
P E Schoen is currently offline  P E Schoen
Messages: 86
Registered: January 2011
Karma: 0
Member
"John Andersen" wrote in message
news:ac29b1ee-97d4-40aa-b70f-13dd13cb50cb(at)v7g2000yqh(dot)googlegroups(dot)com...

> Undo your change and see if it works again!
> If it does, concentrate on finding the error within
> your change! If it doesn't work, follow the leads
> from the other in this group.

Good advice. Hopefully the OP will report back if and when he has found (and
hopefully fixed) the problem. I have learned that it is always good to make
copies of code as changes are made, with plenty of comments, so it is easy
to go back to a previous working condition. Even then subtle errors can be
hard to find.

And another good technique is to strip out unnecessary code and try a simple
test script. It was hard to pick out the possible problems in the OP's code.

Paul
Re: Code Stops Working [message #172394 is a reply to message #172389] Wed, 16 February 2011 10:29 Go to previous messageGo to next message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma: 0
Senior Member
In article <ijfeuf$q72$1(at)news(dot)eternal-september(dot)org>,
Jerry Stuckle <jstucklex(at)attglobal(dot)net> wrote:

> On 2/15/2011 8:16 PM, Mike Copeland wrote:
>> In article<ijf7t3$u6h$1(at)news(dot)eternal-september(dot)org>,
>> jstucklex(at)attglobal(dot)net says...
>>> On 2/15/2011 7:36 PM, Mike Copeland wrote:
>>>> if(isset($submt_btn)) {
>>>
>>> Unless you have register_globals enabled (which it should NOT be), this
>>> value will not be set. You need to use $_GET['submt_btn'] instead (and
>>> the same is true for the other form fields).
>>>
>>> If this were a POST request in the form (which it really should be),
>>> then you would use $_POST['submt_btn'], etc.
>>
>> Hmmmm...I don't know about this "register_globals" thing. How do I
>> determine (and change) this?
>
> http://www.lmgtfy.com/?q=register_globals

:-)

You may not be in a position to change it. Where is the web site hosted?
If you are not in control of the host, whoever *is* in control may have
switched register_globals off as a matter of policy.

As has been suggested, revert your change and see if it still fails.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
Re: Code Stops Working [message #172395 is a reply to message #172385] Wed, 16 February 2011 13:27 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
On 16/02/11 00:36, Mike Copeland wrote:

> My apologies to all: I didn't realize that the PHP source isn't
> accessible. Here it is (but it's messy due to the tabs, etc.). Hope
> this helps...

Hi Mike

I reduced your php code to a minimal example, and then made it work:

----8<----8<----8<-- cut here --8<----8<----8<----
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=utf-8">
<meta name="MSSmartTagsPreventParsing" content="TRUE">
<title>Form Test</title>
<!-- provide trim() and
notifyInvalidInput() functions -->
<script type="text/javascript">
function notifyInvalidInput(msg,field) {
alert(msg);
field.focus();
}
function trim(str) {
var len = str.length;
var result = "";
if (len == 0) return "";
var first = 0;
while (str.charAt(first).match(/\s/) != null &&
first < len) first++;
var last = len - 1;
while (str.charAt(last).match(/\s/) != null &&
last > 0) last--;
last ++;
if (last >= first) return str.slice(first,last);
return "";
}
</script>
<!-- re-written checkInput() function -->
<script type="text/javascript">
function checkInput() {
var runner = document.getElementById("runner");
if (trim(runner.value) == "") {
notifyInvalidInput("Name is a required field. "+
"Please enter your name.", runner);
return false;
}
return true;
}
</script>
</head>
<body>

<?php
if(isset($_POST['submit'])) {
$to = "invalid1(at)example(dot)com,invalid2(at)example(dot)com";
$from = "From: invalid3(at)example(dot)com";
$subject = "Website Results Query Submitted";
$body1 = "Below is the info submitted on the website:
Name: {$_POST['runner']}";
$body2 = wordwrap($body1,70);
$eml_result = mail($to, $subject, $body2, $from);
if($eml_result) {
echo "<p>Your info has been submitted. You will be
contacted in the next couple of days.</p>";
}
else {
$subject = rawurlencode($subject);
$body2 = rawurlencode($body2);
$dest = "invalid4(at)example(dot)com";
$url = "mailto:$dest?subject={$subject}&body={$body2}";
echo "<p>There was a problem sending your info. Please
email <a href='{$url}'>{$dest}</a> about your results
problem.</p>";
}
}
else {
?>

<p>Basic Form:</p>
<form name="ques_form" id="ques_form"
action="<?php echo $_SERVER['PHP_SELF'] ?>"
method="post" onsubmit="return checkInput();">
<table>
<tr><td>Name: </td><td><input type="text"
name="runner" id="runner" size="30"></td></tr>
<tr><td colspan="2" align="center">
<input type="submit" name="submit" id="submit">
</td></tr>
</table>
</form>

<?php
}
?>

</body>
</html>
----8<----8<----8<-- cut here --8<----8<----8<----

I have made changes to the php, html and javascript.

Note the following points:

1) In the above, I have used invalidX(at)example(dot)com email addresses, as
obviously I don't want to publish the email addresses I used for
testing. You will need to change these.

2) I had to write my own trim() and notifyInvalidInput() functions as
these are not art of standard javascript. I have included the ones I
used here. I presume the ones you referenced were included in the
document header php file you were including, but I didn't have a copy of
that.

3) Your javascript elements used the deprecated "language" attribute and
were missing the required "type" attribute.

4) I removed all the css from the example, it just takes up space.

5) As previously mentioned, form elements called "name" can cause a
naming conflict with the form attribute "name" - I reassigned the "Name"
field as "runner". "contestant" might be another good alternative.

6) I assigned an "id" attribute to the form and input elements, and I
use the element id and the document.getElementById() method in
javascript to identify the form field for both testing content and
setting focus when the field is empty. Note that any specific id may
only be applied to a single element in an html document.

7) I use the standard php "mail()" function and not the "email()"
function that you were using. I assume your "email()" function is
defined somewhere in the document header php file you were including,
but I didn't have a copy of that.

8) I changed the form to use the post method instead of the get method,
and additionally, to refer to form elements using the $_POST['']
predefined variable array.

9) In the fallback message for email failure, I encode the subject and
body in the url, so that a suitably configured client-side email client
will, when clicking on the link, automatically fill in the message
subject and body text as well as the recipient.

10) I formatted the source to remain reasonably readable even when in
the restricted width of a news post.

11) I've put the form validation javascript in the document head. This
is cosmetic, but it helps make things more readable too.

I suggest that you save the file as something like "form_test.php", edit
the email addresses, upload to your server, and see if it works. If it
does, you may need to investigate and understand some of the points I
mentioned above.

Rgds

Denis McMahon
Re: Code Stops Working [message #172396 is a reply to message #172385] Wed, 16 February 2011 13:53 Go to previous messageGo to next message
sheldonlg is currently offline  sheldonlg
Messages: 166
Registered: September 2010
Karma: 0
Senior Member
On 2/15/2011 7:36 PM, Mike Copeland wrote:
> In article<4d5b0bf7$0$8054$bed64819(at)gradwell(dot)net>,
> denis(dot)m(dot)f(dot)mcmahon(at)googlemail(dot)com says...
>> On 15/02/11 22:06, Mike Copeland wrote:
>>
>>> The change I made is in the HTML table code near the bottom of the
>>> code, where I commented out one of the prompts. (You can see the change
>>> I made if you look at the code.) Again, the remaining code appears to
>>> function, but no e-mail is sent and no error is reported by the browsers
>>> I've tested. Please advise. TIA
>>
>> Unfortunately we can't see the php code, just the html that it generates.
>>
>> However, I see the following conflict when I look at the page html:
>>
>> <form name="form_name" ....... onclick="check(this)">
>>
>> <input name="name" ....>
>>
>> </form>
>>
>> and the javascript:
>>
>> function check(form) {
>> name = form.name;
>> if (trim(name.value) == "") /* barf gently */;
>> }
>>
>> If form.name is the name attribute of the form, then it has no value
>> attribute, so I'm wondering what trim which I assume is a locally
>> defined function will do when given an undefined value ....
>>
>> Whether this is related to your problem or not I don't know.
>
> My apologies to all: I didn't realize that the PHP source isn't
> accessible. Here it is (but it's messy due to the tabs, etc.). Hope
> this helps...

No excuse! _YOU_ are the one seeking help. It is up to _YOU_ to go
through the trouble to make it easily readable to the people you are
asking for help.

Sorry, but this is just too hard to read for me to spend the time to dig
into this. Maybe someone else doesn't care and will answer you.

<snip>

--
Shelly
Re: Code Stops Working [message #172397 is a reply to message #172395] Wed, 16 February 2011 14:01 Go to previous messageGo to next message
sheldonlg is currently offline  sheldonlg
Messages: 166
Registered: September 2010
Karma: 0
Senior Member
On 2/16/2011 8:27 AM, Denis McMahon wrote:
> On 16/02/11 00:36, Mike Copeland wrote:
>
>> My apologies to all: I didn't realize that the PHP source isn't
>> accessible. Here it is (but it's messy due to the tabs, etc.). Hope
>> this helps...
>
> Hi Mike
>
> I reduced your php code to a minimal example, and then made it work:
>
> ----8<----8<----8<-- cut here --8<----8<----8<----
> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
> "http://www.w3.org/TR/html4/strict.dtd">
>
> <html>
> <head>
> <meta http-equiv="Content-Type"
> content="text/html; charset=utf-8">
> <meta name="MSSmartTagsPreventParsing" content="TRUE">
> <title>Form Test</title>
> <!-- provide trim() and
> notifyInvalidInput() functions -->
> <script type="text/javascript">
> function notifyInvalidInput(msg,field) {
> alert(msg);
> field.focus();
> }
> function trim(str) {
> var len = str.length;
> var result = "";
> if (len == 0) return "";
> var first = 0;
> while (str.charAt(first).match(/\s/) != null&&
> first< len) first++;
> var last = len - 1;
> while (str.charAt(last).match(/\s/) != null&&
> last> 0) last--;
> last ++;
> if (last>= first) return str.slice(first,last);
> return "";
> }
> </script>
> <!-- re-written checkInput() function -->
> <script type="text/javascript">
> function checkInput() {
> var runner = document.getElementById("runner");
> if (trim(runner.value) == "") {
> notifyInvalidInput("Name is a required field. "+
> "Please enter your name.", runner);
> return false;
> }
> return true;
> }
> </script>
> </head>
> <body>
>
> <?php
> if(isset($_POST['submit'])) {
> $to = "invalid1(at)example(dot)com,invalid2(at)example(dot)com";
> $from = "From: invalid3(at)example(dot)com";
> $subject = "Website Results Query Submitted";
> $body1 = "Below is the info submitted on the website:
> Name: {$_POST['runner']}";
> $body2 = wordwrap($body1,70);
> $eml_result = mail($to, $subject, $body2, $from);
> if($eml_result) {
> echo "<p>Your info has been submitted. You will be
> contacted in the next couple of days.</p>";
> }
> else {
> $subject = rawurlencode($subject);
> $body2 = rawurlencode($body2);
> $dest = "invalid4(at)example(dot)com";
> $url = "mailto:$dest?subject={$subject}&body={$body2}";
> echo "<p>There was a problem sending your info. Please
> email<a href='{$url}'>{$dest}</a> about your results
> problem.</p>";
> }
> }
> else {
> ?>
>
> <p>Basic Form:</p>
> <form name="ques_form" id="ques_form"
> action="<?php echo $_SERVER['PHP_SELF'] ?>"
> method="post" onsubmit="return checkInput();">
> <table>
> <tr><td>Name:</td><td><input type="text"
> name="runner" id="runner" size="30"></td></tr>
> <tr><td colspan="2" align="center">
> <input type="submit" name="submit" id="submit">
> </td></tr>
> </table>
> </form>
>
> <?php
> }
> ?>
>
> </body>
> </html>
> ----8<----8<----8<-- cut here --8<----8<----8<----
>
> I have made changes to the php, html and javascript.
>
> Note the following points:
>
> 1) In the above, I have used invalidX(at)example(dot)com email addresses, as
> obviously I don't want to publish the email addresses I used for
> testing. You will need to change these.
>
> 2) I had to write my own trim() and notifyInvalidInput() functions as
> these are not art of standard javascript. I have included the ones I
> used here. I presume the ones you referenced were included in the
> document header php file you were including, but I didn't have a copy of
> that.
>
> 3) Your javascript elements used the deprecated "language" attribute and
> were missing the required "type" attribute.
>
> 4) I removed all the css from the example, it just takes up space.
>
> 5) As previously mentioned, form elements called "name" can cause a
> naming conflict with the form attribute "name" - I reassigned the "Name"
> field as "runner". "contestant" might be another good alternative.
>
> 6) I assigned an "id" attribute to the form and input elements, and I
> use the element id and the document.getElementById() method in
> javascript to identify the form field for both testing content and
> setting focus when the field is empty. Note that any specific id may
> only be applied to a single element in an html document.
>
> 7) I use the standard php "mail()" function and not the "email()"
> function that you were using. I assume your "email()" function is
> defined somewhere in the document header php file you were including,
> but I didn't have a copy of that.
>
> 8) I changed the form to use the post method instead of the get method,
> and additionally, to refer to form elements using the $_POST['']
> predefined variable array.
>
> 9) In the fallback message for email failure, I encode the subject and
> body in the url, so that a suitably configured client-side email client
> will, when clicking on the link, automatically fill in the message
> subject and body text as well as the recipient.
>
> 10) I formatted the source to remain reasonably readable even when in
> the restricted width of a news post.
>
> 11) I've put the form validation javascript in the document head. This
> is cosmetic, but it helps make things more readable too.
>
> I suggest that you save the file as something like "form_test.php", edit
> the email addresses, upload to your server, and see if it works. If it
> does, you may need to investigate and understand some of the points I
> mentioned above.
>
> Rgds
>
> Denis McMahon

Wow! It seems you have essentially done 90% of his work for him. When
I have a problem, I hope you are still around :-) .


--
Shelly
Re: Code Stops Working [message #172398 is a reply to message #172396] Wed, 16 February 2011 14:42 Go to previous messageGo to next message
me is currently offline  me
Messages: 192
Registered: September 2010
Karma: 0
Senior Member
On 2/16/2011 8:53 AM, sheldonlg wrote:
> On 2/15/2011 7:36 PM, Mike Copeland wrote:
>> My apologies to all: I didn't realize that the PHP source isn't
>> accessible. Here it is (but it's messy due to the tabs, etc.). Hope
>> this helps...
>
> No excuse! _YOU_ are the one seeking help. It is up to _YOU_ to go
> through the trouble to make it easily readable to the people you are
> asking for help.

I think we can make allowances for people who begin their request by
saying "I have assumed ownership of a site that has a lot of PHP code -
and I don't have much experience with the language and environment."

Bill B
Re: Code Stops Working [message #172399 is a reply to message #172398] Wed, 16 February 2011 14:45 Go to previous messageGo to next message
sheldonlg is currently offline  sheldonlg
Messages: 166
Registered: September 2010
Karma: 0
Senior Member
On 2/16/2011 9:42 AM, Bill B wrote:
> On 2/16/2011 8:53 AM, sheldonlg wrote:
>> On 2/15/2011 7:36 PM, Mike Copeland wrote:
>>> My apologies to all: I didn't realize that the PHP source isn't
>>> accessible. Here it is (but it's messy due to the tabs, etc.). Hope
>>> this helps...
>>
>> No excuse! _YOU_ are the one seeking help. It is up to _YOU_ to go
>> through the trouble to make it easily readable to the people you are
>> asking for help.
>
> I think we can make allowances for people who begin their request by
> saying "I have assumed ownership of a site that has a lot of PHP code -
> and I don't have much experience with the language and environment."
>
> Bill B

The allowances we can, and should, make are in his lack of understanding
the simple things about PHP. Reformatting the code so that it is
readable by people of whom he is asking for help is common courtesy and
common sense. It has nothing to do with lack of experience in PHP. So,
in short, no, I don't agree.

--
Shelly
Re: Code Stops Working [message #172400 is a reply to message #172397] Wed, 16 February 2011 14:48 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
On 16/02/11 14:01, sheldonlg wrote:

> Wow! It seems you have essentially done 90% of his work for him. When
> I have a problem, I hope you are still around :-) .

Yeah, it was a slow morning.

Also I enjoy figuring out what's wrong with broken stuff.

Rgds

Denis McMahon
Re: Code Stops Working [message #172401 is a reply to message #172400] Wed, 16 February 2011 15:00 Go to previous messageGo to next message
sheldonlg is currently offline  sheldonlg
Messages: 166
Registered: September 2010
Karma: 0
Senior Member
On 2/16/2011 9:48 AM, Denis McMahon wrote:
> On 16/02/11 14:01, sheldonlg wrote:
>
>> Wow! It seems you have essentially done 90% of his work for him. When
>> I have a problem, I hope you are still around :-) .
>
> Yeah, it was a slow morning.
>
> Also I enjoy figuring out what's wrong with broken stuff.

That brought to mind my own experience. I was a Mechanical Engineer for
twenty years and was close to a PhD in Physics. When, out of the
necessity to feed my family during a recession (not this one), I took a
temp job as a programmer and had to do a database conversion. It was great.

On the one hand I was the artist. I created a thing of beauty (working
code) from mind stuff onto a blank canvas.

On the other hand I was Sherlock Holmes. Debugging code was like doing
puzzles -- and getting PAID for it. I would literally let out a cry of
success when I solved a particularly troubling bug.

Both aspects were so great, that I just decided "this was it for me" and
changed careers. Best decision I ever made.

--
Shelly
Re: Code Stops Working [message #172402 is a reply to message #172401] Wed, 16 February 2011 17:11 Go to previous messageGo to next message
Leonardo Azpurua is currently offline  Leonardo Azpurua
Messages: 46
Registered: December 2010
Karma: 0
Member
"sheldonlg" <sheldonlg(at)thevillages(dot)net> escribió en el mensaje
news:ijgoq5$t0a$1(at)news(dot)eternal-september(dot)org...
>
> On the one hand I was the artist. I created a thing of beauty
> (working code) from mind stuff onto a blank canvas.
>
> On the other hand I was Sherlock Holmes. Debugging code was like
> doing puzzles -- and getting PAID for it. I would literally let out
> a cry of success when I solved a particularly troubling bug.

Isn't this the best of all crafts?

It is several years now that I don't work with code from others, and
the mind set created by OO, design patterns and test driven
development (neither of which I use strictly) combined with modern
tools, make it hard to write particularly nasty bugs. But the
pleasure of building order out of nothing is still great.

--
Re: Code Stops Working [message #172403 is a reply to message #172402] Wed, 16 February 2011 17:34 Go to previous messageGo to next message
sheldonlg is currently offline  sheldonlg
Messages: 166
Registered: September 2010
Karma: 0
Senior Member
On 2/16/2011 12:11 PM, Leonardo Azpurua wrote:
>
> "sheldonlg" <sheldonlg(at)thevillages(dot)net> escribió en el mensaje
> news:ijgoq5$t0a$1(at)news(dot)eternal-september(dot)org...
>>
>> On the one hand I was the artist. I created a thing of beauty (working
>> code) from mind stuff onto a blank canvas.
>>
>> On the other hand I was Sherlock Holmes. Debugging code was like doing
>> puzzles -- and getting PAID for it. I would literally let out a cry of
>> success when I solved a particularly troubling bug.
>
> Isn't this the best of all crafts?

Not having taken part in all crafts, I can't really say. (Yes, that is
programmer in me trapping for error conditions :-) ). However, I can
say that I found a magnificent path for me.

>
> It is several years now that I don't work with code from others, and the
> mind set created by OO, design patterns and test driven development
> (neither of which I use strictly) combined with modern tools, make it
> hard to write particularly nasty bugs. But the pleasure of building

You must be a fantastic programmer if you no longer get nasty bugs, even
with all that :-). I still do on occasion.

> order out of nothing is still great.

Yup.

--
Shelly
Re: Code Stops Working [message #172409 is a reply to message #172393] Wed, 16 February 2011 19:28 Go to previous messageGo to next message
Sherm Pendley is currently offline  Sherm Pendley
Messages: 33
Registered: September 2010
Karma: 0
Member
"P E Schoen" <paul(at)pstech-inc(dot)com> writes:

> "John Andersen" wrote in message
> news:ac29b1ee-97d4-40aa-b70f-13dd13cb50cb(at)v7g2000yqh(dot)googlegroups(dot)com...
>
>> Undo your change and see if it works again!
>> If it does, concentrate on finding the error within
>> your change! If it doesn't work, follow the leads
>> from the other in this group.
>
> Good advice.

*Great* advice! One very common beginner mistake is to make a whole
host of changes at once, before trying to execute the result. When (not
if) problems occur, that makes it difficult to pin down exactly which
one of the many changes is responsible. Keeping changes as small as
possible, and testing in between each, makes it easier.

> I have learned that it is
> always good to make copies of code as changes are made

Ouch. It's far better, IMHO, to use a SCM (source code management) tool
that's been expressly designed for just that purpose, such as Subversion,
Mercurial, or Git. Making backup copies (i.e. foo.php, foo-2.php, foo-
bak.php, foo-ihopethisdoesntbreak.php, etc.) is a pretty poor substitute
for such a tool.

sherm--

--
Sherm Pendley
<http://camelbones.sourceforge.net>
Cocoa Developer
Re: Code Stops Working [message #172410 is a reply to message #172409] Wed, 16 February 2011 23:14 Go to previous messageGo to next message
mrc2323 is currently offline  mrc2323
Messages: 12
Registered: February 2011
Karma: 0
Junior Member
In article <m2k4gz6apj(dot)fsf(at)sherm(dot)shermpendley(dot)com>,
sherm(dot)pendley(at)gmail(dot)com says...
> "P E Schoen" <paul(at)pstech-inc(dot)com> writes:
>
>> "John Andersen" wrote in message
>> news:ac29b1ee-97d4-40aa-b70f-13dd13cb50cb(at)v7g2000yqh(dot)googlegroups(dot)com...
>>
>>> Undo your change and see if it works again!
>>> If it does, concentrate on finding the error within
>>> your change! If it doesn't work, follow the leads
>>> from the other in this group.
>>
>> Good advice.
>
> *Great* advice! One very common beginner mistake is to make a whole
> host of changes at once, before trying to execute the result. When (not
> if) problems occur, that makes it difficult to pin down exactly which
> one of the many changes is responsible. Keeping changes as small as
> possible, and testing in between each, makes it easier.
>
>> I have learned that it is
>> always good to make copies of code as changes are made
>
> Ouch. It's far better, IMHO, to use a SCM (source code management) tool
> that's been expressly designed for just that purpose, such as Subversion,
> Mercurial, or Git. Making backup copies (i.e. foo.php, foo-2.php, foo-
> bak.php, foo-ihopethisdoesntbreak.php, etc.) is a pretty poor substitute
> for such a tool.

I backed out my changes, and the code does not work as it used to. I
made several (very minor) changes to the code (correcting spelling
errors in the text, etc.) to see that my "restored version" was being
engaged...and it is. 8<{{
Seems I have to start looking at my Web environment and such, as has
been suggested. <sigh...>
Thanks to all for your help!
Re: Code Stops Working [message #172411 is a reply to message #172394] Wed, 16 February 2011 23:18 Go to previous messageGo to next message
mrc2323 is currently offline  mrc2323
Messages: 12
Registered: February 2011
Karma: 0
Junior Member
In article <timstreater-D23DFC(dot)10292816022011(at)news(dot)individual(dot)net>,
timstreater(at)waitrose(dot)com says...
> In article <ijfeuf$q72$1(at)news(dot)eternal-september(dot)org>,
> Jerry Stuckle <jstucklex(at)attglobal(dot)net> wrote:
>
>> On 2/15/2011 8:16 PM, Mike Copeland wrote:
>>> In article<ijf7t3$u6h$1(at)news(dot)eternal-september(dot)org>,
>>> jstucklex(at)attglobal(dot)net says...
>>>> On 2/15/2011 7:36 PM, Mike Copeland wrote:
>>>> > if(isset($submt_btn)) {
>>>>
>>>> Unless you have register_globals enabled (which it should NOT be), this
>>>> value will not be set. You need to use $_GET['submt_btn'] instead (and
>>>> the same is true for the other form fields).
>>>>
>>>> If this were a POST request in the form (which it really should be),
>>>> then you would use $_POST['submt_btn'], etc.
>>>
>>> Hmmmm...I don't know about this "register_globals" thing. How do I
>>> determine (and change) this?
>>
>> http://www.lmgtfy.com/?q=register_globals
>
> :-)
>
> You may not be in a position to change it. Where is the web site hosted?
> If you are not in control of the host, whoever *is* in control may have
> switched register_globals off as a matter of policy.
>
> As has been suggested, revert your change and see if it still fails.

I did, and it continues to fail (bummer...). The server is
godaddy.com, and while I'm only maintaining the code, I'll have to work
with the site's owner to look at this. 8<{{
Re: Code Stops Working [message #172412 is a reply to message #172411] Wed, 16 February 2011 23:40 Go to previous messageGo to next message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma: 0
Senior Member
In article <MPG(dot)27c6093958c05cfe9896a9(at)news(dot)eternal-september(dot)org>,
mrc2323(at)cox(dot)net (Mike Copeland) wrote:

> In article <timstreater-D23DFC(dot)10292816022011(at)news(dot)individual(dot)net>,
> timstreater(at)waitrose(dot)com says...
>> In article <ijfeuf$q72$1(at)news(dot)eternal-september(dot)org>,
>> Jerry Stuckle <jstucklex(at)attglobal(dot)net> wrote:
>>
>>> On 2/15/2011 8:16 PM, Mike Copeland wrote:
>>>> In article<ijf7t3$u6h$1(at)news(dot)eternal-september(dot)org>,
>>>> jstucklex(at)attglobal(dot)net says...
>>>> > On 2/15/2011 7:36 PM, Mike Copeland wrote:
>>>> >> if(isset($submt_btn)) {
>>>> >
>>>> > Unless you have register_globals enabled (which it should NOT be), this
>>>> > value will not be set. You need to use $_GET['submt_btn'] instead (and
>>>> > the same is true for the other form fields).
>>>> >
>>>> > If this were a POST request in the form (which it really should be),
>>>> > then you would use $_POST['submt_btn'], etc.
>>>>
>>>> Hmmmm...I don't know about this "register_globals" thing. How do I
>>>> determine (and change) this?
>>>
>>> http://www.lmgtfy.com/?q=register_globals
>>
>> :-)
>>
>> You may not be in a position to change it. Where is the web site hosted?
>> If you are not in control of the host, whoever *is* in control may have
>> switched register_globals off as a matter of policy.
>>
>> As has been suggested, revert your change and see if it still fails.
>
> I did, and it continues to fail (bummer...). The server is
> godaddy.com, and while I'm only maintaining the code, I'll have to work
> with the site's owner to look at this. 8<{{

OK. You can say your page stopped working and have they made any changes
to their PHP configuration.

As (I think I got this right) Jerry said, if that's what's happened
you'll need to make changes to the PHP parts of the code as described.
It's better practice anyway.

By the way, don't forget to let us know what is was once you're sorted.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
Re: Code Stops Working [message #172413 is a reply to message #172410] Thu, 17 February 2011 00:00 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
On 16/02/11 23:14, Mike Copeland wrote:

> Seems I have to start looking at my Web environment and such, as has
> been suggested. <sigh...>
> Thanks to all for your help!

ok, simple trick for this:

----8<----8<----8<-- cut here --8<----8<----8<----
<?php
phpinfo();
?>
----8<----8<----8<-- cut here --8<----8<----8<----

upload it to the server as something like "phpenv.php" and
http://server.domain/phpenv.php

It should give you a full run down of the php environment on the server.

I assume you have seen my modified and working version of your php post
in amongst all the other dross? I think you may have a combination of
issues in the html, javascript and php parts of the code.

Rgds

Denis McMahon
Re: Code Stops Working [message #172424 is a reply to message #172411] Thu, 17 February 2011 12:23 Go to previous messageGo to next message
me is currently offline  me
Messages: 192
Registered: September 2010
Karma: 0
Senior Member
On 2/16/2011 6:18 PM, Mike Copeland wrote:
> I did, and it continues to fail (bummer...). The server is
> godaddy.com, and while I'm only maintaining the code, I'll have to work
> with the site's owner to look at this. 8<{{

godaddy.com's technical support is very good. If you haven't done a
fly-by yet, see what they have to say. May be something they can spot.

Bill B
Re: Code Stops Working [message #172464 is a reply to message #172395] Sat, 19 February 2011 18:46 Go to previous messageGo to next message
mrc2323 is currently offline  mrc2323
Messages: 12
Registered: February 2011
Karma: 0
Junior Member
In article <4d5bd187$0$7839$bed64819(at)gradwell(dot)net>,
denis(dot)m(dot)f(dot)mcmahon(at)googlemail(dot)com says...
> I reduced your php code to a minimal example, and then made it work:
>
> ----8<----8<----8<-- cut here --8<----8<----8<----
> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
> "http://www.w3.org/TR/html4/strict.dtd">
>
> <html>
> <head>
> <meta http-equiv="Content-Type"
> content="text/html; charset=utf-8">
> <meta name="MSSmartTagsPreventParsing" content="TRUE">
> <title>Form Test</title>
> <!-- provide trim() and
> notifyInvalidInput() functions -->
> <!-- re-written checkInput() function -->
> <script type="text/javascript">
> function checkInput() {
> var runner = document.getElementById("runner");
> if (trim(runner.value) == "") {
> notifyInvalidInput("Name is a required field. "+
> "Please enter your name.", runner);
> return false;

Denis, I really appreciate your sample here - it works nicely for
what you did for me. I have a couple of problems, though:
Your rewrite of the "checkInput" function works only for the "runner"
field and doesn't seem extensible for others I need. And the invocation
of the function is part of the "action=" code. So it seems that the
only field that can be checked is that one (runner), even when I extend
your template to all the fields I need to input and process.
Am I missing something in this?

<p>Basic Form:</p>
<form name="ques_form" id="ques_form"
action="<?php echo $_SERVER['PHP_SELF'] ?>"
method="post" onsubmit="return checkInput();">
<table>
<tr><td>Name: </td><td><input type="text"
name="runner" id="runner" size="30"></td></tr>
<tr><td colspan="2" align="center">
<input type="submit" name="submit" id="submit">
</td></tr>
</table>
</form>

Also, I checked my ISP regarding the"register_globals" option: it's
set "off". So I guess that whatever's causing my problems with the code
that used to work, but now isn't, is not that particular issue.
I'm pursuing expanding your template to add other fields (hence this
message), but it's difficult for me as a PHP newbie...as well as having
to work with this "production site" in times where it isn't likely to be
used. 8<}}
Re: Code Stops Working [message #172465 is a reply to message #172464] Sat, 19 February 2011 20:29 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 2/19/2011 1:46 PM, Mike Copeland wrote:
<snip>

> I'm pursuing expanding your template to add other fields (hence this
> message), but it's difficult for me as a PHP newbie...as well as having
> to work with this "production site" in times where it isn't likely to be
> used. 8<}}

The very first thing you need to do is set up a development system,
preferably on your local computer, emulating the host as well as possible.

NEVER work on a live production site! And nowadays, there is no time
when it isn't "likely to be used".

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: Code Stops Working [message #172475 is a reply to message #172395] Sun, 20 February 2011 20:39 Go to previous messageGo to next message
mrc2323 is currently offline  mrc2323
Messages: 12
Registered: February 2011
Karma: 0
Junior Member
In article <4d5bd187$0$7839$bed64819(at)gradwell(dot)net>,
denis(dot)m(dot)f(dot)mcmahon(at)googlemail(dot)com says...
> I reduced your php code to a minimal example, and then made it work:
>
> ----8<----8<----8<-- cut here --8<----8<----8<----
> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
> "http://www.w3.org/TR/html4/strict.dtd">
>
> <html>
> <head>
> <meta http-equiv="Content-Type"
> content="text/html; charset=utf-8">
> <meta name="MSSmartTagsPreventParsing" content="TRUE">
> <title>Form Test</title>
> <!-- provide trim() and
> notifyInvalidInput() functions -->
> <script type="text/javascript">
> function notifyInvalidInput(msg,field) {
> alert(msg);
> field.focus();
> }
[deleted...]
Well, I was able to complete the conversion of your code here to my
data, and the process works well and consistently. Thank you very much.
Bottom line results: your process works and is extensible, and except
for the field validations for specific data, do the job nicely. I
didn't have to make any change to my ISP's environment, and I believe I
learned a lot from this exercise. Clearly, I have much yet to learn
about PHP and the Web environment, and that will be slow going for
someone my age. 8<{{ I haven't yet been able to establish an "IDE
environment" (as I know I should), and perhaps that will come with time.
Right now a prototype of the page is working (I still haven't reinserted
the boilerplate), which was important for today, as we anticipate some
usage for this functionality after today.
Thanks again to all for your thoughts and help!
Re: Code Stops Working [message #172477 is a reply to message #172475] Mon, 21 February 2011 00:16 Go to previous messageGo to next message
Beauregard T. Shagnas is currently offline  Beauregard T. Shagnas
Messages: 154
Registered: September 2010
Karma: 0
Senior Member
Mike Copeland wrote:

> and that will be slow going for someone my age.

How old are you?

--
-bts, septuagenarian
Re: Code Stops Working [message #172480 is a reply to message #172477] Mon, 21 February 2011 01:33 Go to previous messageGo to next message
mrc2323 is currently offline  mrc2323
Messages: 12
Registered: February 2011
Karma: 0
Junior Member
In article <ijsat3$6m7$1(at)news(dot)eternal-september(dot)org>,
a(dot)nony(dot)mous(at)example(dot)invalid says...
> Mike Copeland wrote:
>
>> and that will be slow going for someone my age.
>
> How old are you?
>
71 on Tuesday...
Re: Code Stops Working [message #172482 is a reply to message #172480] Mon, 21 February 2011 02:27 Go to previous messageGo to next message
Beauregard T. Shagnas is currently offline  Beauregard T. Shagnas
Messages: 154
Registered: September 2010
Karma: 0
Senior Member
Mike Copeland wrote:

> Beauregard T. Shagnasty says...
>> Mike Copeland wrote:
>>> and that will be slow going for someone my age.
>>
>> How old are you?
>>
> 71 on Tuesday...

Then certainly not too old to learn! :-) You've got me by just a year.

--
-bts
-Four wheels carry the body; two wheels move the soul
Re: Code Stops Working [message #172494 is a reply to message #172482] Mon, 21 February 2011 11:22 Go to previous messageGo to next message
sheldonlg is currently offline  sheldonlg
Messages: 166
Registered: September 2010
Karma: 0
Senior Member
On 2/20/2011 9:27 PM, Beauregard T. Shagnasty wrote:
> Mike Copeland wrote:
>
>> Beauregard T. Shagnasty says...
>>> Mike Copeland wrote:
>>>> and that will be slow going for someone my age.
>>>
>>> How old are you?
>>>
>> 71 on Tuesday...
>
> Then certainly not too old to learn! :-) You've got me by just a year.

....and me by two and I am constantly learning new things.

--
Shelly
Re: Code Stops Working [message #172511 is a reply to message #172494] Mon, 21 February 2011 13:51 Go to previous messageGo to next message
mrc2323 is currently offline  mrc2323
Messages: 12
Registered: February 2011
Karma: 0
Junior Member
In article <ijthui$vi5$1(at)news(dot)eternal-september(dot)org>,
sheldonlg(at)thevillages(dot)net says...
> On 2/20/2011 9:27 PM, Beauregard T. Shagnasty wrote:
>>> Beauregard T. Shagnasty says...
>>>> Mike Copeland wrote:
>>>> > and that will be slow going for someone my age.
>>>>
>>>> How old are you?
>>>>
>>> 71 on Tuesday...
>>
>> Then certainly not too old to learn! :-) You've got me by just a year.
>
> ...and me by two and I am constantly learning new things.
>
Not saying "can't", just saying it's harder and slower at my age.
I've been at this (programming) for 50+ years, and learning new stuff is
definitely more challenging! 8<{{
Re: Code Stops Working [message #172512 is a reply to message #172511] Mon, 21 February 2011 13:59 Go to previous message
sheldonlg is currently offline  sheldonlg
Messages: 166
Registered: September 2010
Karma: 0
Senior Member
On 2/21/2011 8:51 AM, Mike Copeland wrote:
> In article<ijthui$vi5$1(at)news(dot)eternal-september(dot)org>,
> sheldonlg(at)thevillages(dot)net says...
>> On 2/20/2011 9:27 PM, Beauregard T. Shagnasty wrote:
>>>> Beauregard T. Shagnasty says...
>>>> > Mike Copeland wrote:
>>>> >> and that will be slow going for someone my age.
>>>> >
>>>> > How old are you?
>>>> >
>>>> 71 on Tuesday...
>>>
>>> Then certainly not too old to learn! :-) You've got me by just a year.
>>
>> ...and me by two and I am constantly learning new things.
>>
> Not saying "can't", just saying it's harder and slower at my age.
> I've been at this (programming) for 50+ years, and learning new stuff is
> definitely more challenging! 8<{{

If you have been at it for fifty years (about the same for me), and if
you know C, then this should be very easy for you. If you know C++ or
Java, the PHP5 with the OO should also be a breeze.

I find that the more I learn, the more I am able to learn and easier it
becomes to do so.

--
Shelly
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: about memory usage with php application
Next Topic: PHP currency converter with XML feed
Goto Forum:
  

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

Current Time: Mon Nov 25 23:06:42 GMT 2024

Total time taken to generate the page: 0.11349 seconds