A quick PHP code check, please

  ade.h 14:18 14 Jun 2006

Would anyone with a good knowledge of PHP be kind enough to scan over this and check that it's okay, please?

$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$location = $REQUEST['location'] ;
$message = $_REQUEST['message'] ;

if (!isset($_REQUEST['email'])) {
header( "Location: click here" );
elseif (empty($email) || empty($message)) {
header( "Location: click here" );
else {
mail( "[email protected]", "Form Message",
$message, "From: $email" );
header( "Location: click here" );

(Hoping that it formats correctly...) TIA!

  ade.h 14:20 14 Jun 2006

As I suspected, it hasn't formatted 100% correctly; I have added two spaces to the lines between the start and end tags and have used the < at the start. It's based on this tutorial click here.

  ade.h 16:15 14 Jun 2006

Hmmm. I've just uploaded a test version to click here and when I submit the form's contents, I get this:

Parse error: parse error, unexpected $ in /web/sites/343/hillier/click here on line 16

Any ideas what that means?

The php file is identical to my first post, except that the URLs have been changed to match my test server and the location value has been removed to match the test form.

  harristweed 18:22 14 Jun 2006

You need a closing brace after the last....
header( "Location: click here" );

//closing brace here

  ade.h 18:35 14 Jun 2006

Oh, right. I just copied verbatim the code that is created in the Site Wizard tutorial click here and there was no closing brace (I assume you mean the curly symbol?)

So it should be like this, yes?

header( "Location: click here" );


Or is that not quite right?

  harristweed 18:43 14 Jun 2006

header( "Location: click here" );

  ade.h 19:38 14 Jun 2006

Oh, okay. Thanks for your help, harristweed.

I'll try that and see if it now works, assuming I haven't made any other errors. I might be back...

  ade.h 19:46 14 Jun 2006

Well, that cured that php error!

But it has allowed the next error to become apparent. I tried filling in and submitting my form click here but I get my error page rather than the success page and no email.

Any thoughts, anyone? Help is much appreciated!

  ade.h 21:11 14 Jun 2006

I've discovered that this new problem lies with the form itself; I took out the "message" value from the "elseif" line and the message went through successfully. It turns out that the text from the message box is not being picked up, thus triggering the failure. I'll start a new thread on this as it's a new issue.

Thanks again, harristweed.

  ade.h 21:19 14 Jun 2006

The reason became obvious on checking my html code; the message box should be name="message" but I left it as name="FormsMultiLine1" without changing it in NOF's form pallette.


This thread is now locked and can not be replied to.

Elsewhere on IDG sites

AMD Radeon Adrenalin release date, new features, compatible graphics cards

8 brilliant character artists speaking at Pictoplasma 2018

iMac Pro release date, UK price & specs

Football : comment regarder la Ligue 1 en direct ?