Hey guys,

Thanks in advance for your help.

I'm working on emailing the contents of a form using php.  It worked fine,
until I turned global_variables off in an attempt to secure the form (I
still have yet to write the data validation part).

Anyway, I have an IF statement that fires depending on a hidden variable in
the form.  If the
variable is empty, it loads the form.  If the variable contains the hidden
value I give it during form creation, then it emails the contents on the
form and displays a thank you msg instead of displaying the form.

The problem I have run into, involves the hidden value for the form.  I
didn't have to declare it before when I had global_variables turned on, but
now I have to.  I searched the manual and tried statements like "global
$variablename" but the code wouldn't run properly.  I've searched through
the newsgroups as well, but I'm new to PHP so it was tough to figure out
what to search for.  I'm sure all I'm missing is one line of code.  I
included my code below.  The problem exists in this line:

if ($_POST['frmAction'] == "formmail")

which is before where the form is created so the $frmAction variable isn't
declared yet.  I'm
getting a variable not declared error, which I know, but if I declare the
variable earlier in the document, then it resets the value that I give it
before I submit the form.  How do I make this work?

Thanks so very much!!

Steve

<html>
<head>
</head>
<body>
**HTML stuff here**
<?php

// error handler
function e($type, $msg, $file, $line)
{
 $errorLog = "error.log";
**Error Handler code here**
}

error_reporting(E_ERROR | E_WARNING);
set_error_handler("e");

$TO = "[EMAIL PROTECTED]";
$MP = "mail.mailserver.com";
?>

<?php
if ($_POST['frmAction'] == "formmail")
{


$fd = popen($MP,"w");
fputs($fd, "To: $TO\n");
fputs($fd, "From: $_POST['name'] <$_POST['email']>\n");
fputs($fd, "Subject: $_POST['inforequest']\n");
fputs($fd, "X-Mailer: PHP3\n");
fputs($fd, "Name: $_POST['name']\n");
fputs($fd, "Business: $_POST['business']\n");
fputs($fd, "Phone: $_POST['phone']\n");
fputs($fd, "Email: $_POST['email']\n");
fputs($fd, "Details: $_POST['details']");
pclose($fd);

?>

**HTML thank you msg here**

<?php

exit;
} else {

?>
 <table>
           <form action="test.php" method=POST>
                    <select name="inforequest">
                      <option>Select Info Source</option>
                      <option value="Option 1">Option 1</option>
                      <option value="Option 2">Option 2</option>
                      <option value="Option 3">Option 3</option>
                      <option value="Option 4">Option 4</option>
                    </select>
                  </td>
                </tr>
                <tr>
                    <input type="text" name="name">
                  </td>
                </tr>
                <tr>
                    <input type="text" name="business">
                  </td>
                </tr>
                <tr>
                    <input type="text" name="phone">
                  </td>
                </tr>
                <tr>
                    <input type="text" name="email">
                  </td>
                </tr>
                <tr>
                    <textarea name="details" wrap="PHYSICAL" cols="35"
rows="8"></textarea>
                  </td>
                </tr>
                <tr>
                  <td>
                  <input type="hidden" name="frmAction" value="formmail">
                  <input type=submit name="Submit" value="Submit">
                  <input type="reset" name="Reset" value="Reset">
                  </td>
                </tr>
              </form>
            </table>
<?php
}
?>

**last bit of HTML here**
</body>
</html>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to