View Full Version : Help on PHP Form Submit

01-26-2005, 12:28 PM

I've writen a script that should work with my form, however it does'nt, any suggestions please:


<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

switch ($op) {

case send:

$config = "-finfo@nexgen.co.za";

$subject="Information Request from VAGMOS Web Site";


$msg="Please respond in a timely manner.Thanks in advance";

header("Location: http://www.vagmos.co.za/thanks.htm");


On the form itself I have this line:

<form name="frmMail" Action="formmail.php?op=send" method="post">

01-26-2005, 09:53 PM
Are you getting a parse error? If so, the line:
is missing the semi-colon at the end and the switch statement is unterminated.

In case those are just from cutting the code down for the post and you're not getting a parse error:
Are you getting the emails at info@vag.co.za? If you're checking the script by seeing if the redirect works, then that won't work. Headers need to be sent before any content is outputted so put the PHP code before <html>. If you have other cases that don't need the redirect, and so need the html code, you can leave them where the current PHP code is.

If you aren't getting the emails, then it could be that your web host has register_globals off.
ie: $op is undefined, so nothing will happen in your switch statement. Variables from the query string are stored in the $_GET array (in PHP v4.1 or later), so you would want to replace the switch with:
switch ($_GET['op']) {
case "send":

01-26-2005, 10:50 PM
I don't have much to add...

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">You shouldn't use proprietary character sets. You'd probably be better off using iso-8859-1 (aka Latin 1). Moreover, you should be sending the character set (and content type in general) via HTTP Response headers, not meta elements. Unless your server's "broken" (like mine - I can't change the default character set as that's an administrator operation :(), do this part properly.

switch ($op) {Unless your host's PHP version doesn't support super globals, like $_GET, you should avoid using the EGPCS variables even if they are available.