The message comes through OK, but the success page has the following across the middle

Warning: Cannot modify header information - headers already sent by (output started at /websites/123reg/LinuxPackage21/c5/d_/co/c5d.co.uk/public_html/changeofaddress.php:8) in /websites/123reg/LinuxPackage21/c5/d_/co/c5d.co.uk/public_html/changeofaddress.php on line 72

If that does not cure that error -- which is caused because your page is outputting something onto the page prior to calling header(); then you should comment out blocks of code until you find out what it is.

certificates
—
2013-02-09T21:51:37Z —
#3

Are you certain that's all I need to change because it doesn't seem to make any difference.

The form comes through but I still get the same blurb across the success page

Part 1

At the end of a thread is a box titled "Quick Reply". This is where messages are posted in the forum.

When you post code in a message, please surround that code with [noparse]

[/noparse]</font> tags typed as follows:
<font color='blue'>[noparse]

[/noparse]paste your code here[noparse]

[/noparse]</font>
As you know, posting code in a message does not preserve indents or formatting and some characters in proportionally spaced fonts are hard to spot.
Using [noparse]

[/noparse] tags makes code much easier for us to read and potentially saves vertical space in the message.

If it is not convenient to type the [noparse]

[/noparse] tags, then try this instead:
At the bottom right of the "Quick Reply" box is an orange button that says "Go Advanced".
Click that button.
The one row of command buttons in the "Quick Reply" box will be replaced with three rows of buttons.
The # symbol near the right end of the middle row inserts the [noparse]

[/noparse] tags for you.The php symbol at the very right end inserts [noparse]

[/noparse] tags.
In all cases, the generic [noparse]

[/noparse] tags are far more helpful than none at all.

Thanks

ronpat
—
2013-02-10T10:35:56Z —
#5

I started to post a Part 2, but my brain is tired. Will try again tomorrow afternoon.

Can someone tell me if it is possible for a user (like me) to read a php/html file without having the php calls interpreted? Not being able to see where calls are being made (and read the calling statements) is a bit of a problem. I'm pretty sure that it can't be done, since that is a server side function, but I have to ask.

The code in the changeofaddress.php file appears to be seriously invalid.

Thanks

ralphm
—
2013-02-10T13:28:16Z —
#6

As ronpat notes, your page code is seriously messed up there. You can't start your page with a doctype etc and then have another one further down—at least, not the way you've done it. So the thing to do here is first clarify what you are trying to do here, because it's not clear to me. Firstly, what page does the form appear on? You would typically have an HTML page with a form on it. In the action="" part of the form, you post the URL of the PHP page the contains the PHP code that will process the form. That PHP code will check the input data, and either end that data to you via email and divert the user to a thank you page, or divert the user to an Error page is there is a problem.

Alternatively, this can all be handled with fewer pages. for example, if the PHP script page finds an error, it can reload itself and inform the user of a problem, or, if all's well, that page can reload itself and thank the user.

At the moment, your code does none of those things. So the first thing you need to clarify is what scenario you want to see.

certificates
—
2013-02-10T14:06:52Z —
#7

What I am trying to do is to use this page http://www.c5d.co.uk/addresschange.php as a page for a change of address. I know that the current box needs amending, but that's the second stage of my problem.

<!DOCTYPE html><html lang="en"><head> <meta charset="utf-8"><title>Welcome To The Ashton Under Lyne Golf Club Website: Change of Address</title>

It looks like Antony tried to install a JavaScripted on-page data validation method, which would have been very efficent!, but couldn't make it work, so along came Plan B.

Accordingly, the form transmits data to the changeofaddress.php file where the data is validated.

If it validates OK, then the e-mail with the new information should be sent to Antony and the user should be redirected to the "thank you" page.

If the data fails validation, then Ralph's HTML below the validation php code will be opened in the user's browser and the failure codes presented to the user. Noted: there is no "Try Again" button, the user is expected to use his browser's "Back" button to return to the addresschange.php page.

For simplicity (separation of functions), I would like to propose a Plan C.

The changeofaddress.php would contain ONLY the php validation code and decision making/action code.

If the data validates correctly, then the e-mail is generated and the user is sent to the "thank you" page.

If the data fails validation, then the user is sent to an error page...

A new error page would be created which displays the error messages if data validation fails.

The difference between Plan B and Plan C is the addition of a redirect in the php file and the creation of the new error presentation page (the target of that new redirect), therefore no embedded HTML page would exist in the php file. (Both changes sound easy.) The "separation of functions" makes it more logical, therefore easier to manage.

What do ya'll think?

I could easily be misinterpreting things, so please correct any of my misconceptions :).

PS: changeofaddress.php as it is currently designed is not really a "success" page, it is the "validate" page. I would think that the "success" page would be the "thank you" page. Terminology seems confusing to me.

ralphm
—
2013-02-11T01:12:10Z —
#10

ronpat said:

What do ya'll think?

I could easily be misinterpreting things, so please correct any of my misconceptions :).

Makes sense, Ron, but there are other options, too. Having the error page as part of the PHP page has some advantages, such as being able to echo the whole form and include the user's current answers (although that's not set up here). Another option (the one I prefer) is to have everything on the one, original form page do everything. So the processing code is on the form page itself, and depending on the results, the user either gets a thanks message, or a list of errors, followed by the form with the original input data shown (preferably with the incorrect ones highlighted).

ronpat
—
2013-02-11T01:29:04Z —
#11

Thanks, Ralph. Yes, I agree with processing the data on the page with the form. It looks like Antony's original intent was to use an on-page JavaScript data validation method which would have eliminated the php calls to the server. Maybe it would be worth reconsidering.

Cheers

ralphm
—
2013-02-11T01:36:28Z —
#12

ronpat said:

an on-page JavaScript data validation method which would have eliminated the php calls to the server. Maybe it would be worth reconsidering.

JS can provide a nice validation enhancement, such that you get feedback on your input without having to refresh the page, but it's only really useful as an enhancement. It's still important to have the server-side version as a backup. People can have JS off, of course, and thus bypass JS validation. So the server-side code needs to be there to clean up anything that gets through the net.

If the entire form processing is left up to JS, you have an even bigger problem if JS is off, because the form won't process at all.

ronpat
—
2013-02-11T01:49:03Z —
#13

Good point about JavaScript. Weirdly slipped my mind that JS can be disabled. I think I need to back off and "read the mail" on this issue for a bit.

ralphm
—
2013-02-11T01:56:27Z —
#14

ronpat said:

I think I need to back off and "read the mail" on this issue for a bit.

Not at all. These are good questions. Remember also that I know little about this subject, but I do find it fascinating. I haven't ventured far into the whole Ajax live validation stuff, but I'd love to master that. And I can just do the most basic bits of PHP. I can't guarantee that what I posted above will work without soe modification.

certificates
—
2013-02-11T05:59:16Z —
#15

Thanks for the replies.

I loaded the suggested script suggested by ralph.m and called it changeofaddress.php. I also changed this

//redirect to the 'thank you' pageheader('thankyou.php');

to

//redirect to the 'changeofaddress' pageheader('changeofaddress.php');

Which seemed logical to me. I cannot use the thankyou page because I akready have a thankyou.php in respect of orders.

Sorry for the error. I should have added a } at the very end of that code. Add that in and see what happens.

certificates said:

header('changeofaddress.php');

Which seemed logical to me. I cannot use the thankyou page because I akready have a thankyou.php in respect of orders.

You don't want to return the user to this page itself, because it doesn't contain any kind of thank you message. Just make some other thank you page, like thankyou.html, or success.php, and use that instead.

certificates
—
2013-02-11T06:26:12Z —
#17

Well we are one step further on because the form now sends and sends the details, but I get a different error.

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

<<<<<Please contact the server administrator, www.123-support.co.uk and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Hm, you are at least partly suffering from my inexperience with PHP, as I've made some kind of error around line 77. It seems $errors is not an array, though I thought it was. O well, you could try replacing this code:

foreach ($errors as $err) {
echo '<li>'.$err.'</li>';
}

with the original code you had:

echo nl2br($errors);

Unless someone who knows PHP steps in, we'll just have to stumble along like this.

Here is an alternate version of the page where I've attempted to turn $errors into a proper array, so feel free to try this out too. If it works, it will give a better resutl: