A quick PHP code check, please

  [DELETED] 14:18 14 Jun 2006
Locked

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!

  [DELETED] 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.

  [DELETED] 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.

  [DELETED] 18:22 14 Jun 2006

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

//closing brace here
}
?>

  [DELETED] 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?

  [DELETED] 18:43 14 Jun 2006

header( "Location: click here" );
}
?>

  [DELETED] 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...

  [DELETED] 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!

  [DELETED] 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.

  [DELETED] 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.

Doh!

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

Elsewhere on IDG sites

How to watch the World Cup for free on TV and online

Meet Superfiction, the little design studio with a load of character

Best Mac music-production software

Comment savoir si votre message a été lu sur Facebook & WhatsApp ?