Hello list, I just wanted to bounce a slight issue that I'm having off you regarding self referencing a php script. Moving from the 'sendemail.htm' page where a form is used to the 'sendemail.php' page that is in the form action works fine! But if you reload the page, the php part of the equation loses track of it's $_POST[] variables, and you see the following errors in the output of the php page: Notice: Undefined index: subject in /Library/WebServer/Documents/examples/ch03/final/makemeelvis/sendemail.php on line 19 Notice: Undefined index: elvismail in /Library/WebServer/Documents/examples/ch03/final/makemeelvis/sendemail.php This is the original form from the sendemail.html page: <form method="post" action="sendemail.php"> <label for="subject">Subject of email:</label><br /> <input id="subject" name="subject" type="text" size="30" /><br /> <label for="elvismail">Body of email:</label><br /> <textarea id="elvismail" name="elvismail" rows="8" cols="40"></textarea><br /> <input type="submit" name="Submit" value="Submit" /> </form> On the php page I'm using a true / false 'flag' to indicate whether or not a form is displayed. $output_form = "false"; If the user fails to submit information to either field the script re-displays the form via the $output_form variable: if (empty($subject) && empty($text)) { //* We know both $subject AND $text are blank echo 'You forgot the email subject and body.<br />'; $output_form="true"; } if ($output_form == 'false') { $dbc = mysqli_connect('127.0.0.1', 'admin', 'secret', 'elvis_store') or die('Error connecting to MySQL server.'); $query = "SELECT * FROM email_list"; $result = mysqli_query($dbc, $query) or die('Error querying database.'); while ($row = mysqli_fetch_array($result)){ $to = $row['email']; $first_name = $row['first_name']; $last_name = $row['last_name']; $msg = "Dear $first_name $last_name,\n$text"; mail($to, $subject, $msg, 'From:' . $from); echo 'Email sent to: ' . $to . '<br />'; } mysqli_close($dbc); } The html form is really the only important part of the .html page, but here is the full php script from 'sendemail.php' to provide a bit of context. Passwords have been changed to protect the innocent! <?php $from = 'me@xxxxxxxxxxxx'; $subject = $_POST['subject']; $text = $_POST['elvismail']; $output_form = "false"; if (empty($subject) && empty($text)) { //* We know both $subject AND $text are blank echo 'You forgot the email subject and body.<br />'; $output_form="true"; } if (empty($subject) && !empty($text)) { echo 'You forgot the email subject.<br />'; $output_form="true"; } if ((!empty($subject)) && empty($text)) { echo 'You forgot the email body text.<br />'; $output_form="true"; } if ($output_form == 'true') { echo '<br /><br /><form action="sendemail.php" "method="post"> <label for="subject">Subject of email:</label><br /> <input id="subject" name="subject" type="text" size="30" /><br /> <label for="elvismail">Body of email:</label><br /> <textarea id="elvismail" name="elvismail" rows="8" cols="40"></textarea><br /> <input type="submit" name="Submit" value="Submit" /> </form>'; } if ($output_form == 'false') { $dbc = mysqli_connect('127.0.0.1', 'admin', 'secret', 'elvis_store') or die('Error connecting to MySQL server.'); $query = "SELECT * FROM email_list"; $result = mysqli_query($dbc, $query) or die('Error querying database.'); while ($row = mysqli_fetch_array($result)){ $to = $row['email']; $first_name = $row['first_name']; $last_name = $row['last_name'];å $msg = "Dear $first_name $last_name,\n$text"; mail($to, $subject, $msg, 'From:' . $from); echo 'Email sent to: ' . $to . '<br />'; } mysqli_close($dbc); } ?> Thanks in advance! tim -- GPG me!! gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php