Problem with Error/Mail/something...

From: Date: Mon, 13 Aug 2001 18:22:31 +0000
Subject: Problem with Error/Mail/something...
Groups: php.general 
Request: Send a blank email to php-general+get-62474@lists.php.net to get a copy of this message
hey- I wrote this form checker/mailer for my website. I feel like I may have written it wrong, however there are a few things I wanted to ask about. I think I may be having a problem with how I'm checking if the mail was sent, or maybe something with the if statement to see if the submit button was pressed. Maybe it's a problem with the way I'm using variables in all of my functions, I have no idea...I'm getting a 500 error pretty much all the time, except when the page first loads, in which case the action is set to 1 and it works fine, but after that, nothing works...can someone help figure out what's wrong? -chris here's the code-- <? include("/home/fplg/lib/functions.php"); echo "starting page<br>"; if(!isset($action)) { $action = 1; } echo "finished isset action if<br>"; echo "starting if for submit check<br>"; if($submit) { file://$action = 2; echo "inside if<br>"; $match = ereg("^[^@ ]+@[^@ ]+\.[^@ \.]+$", $sender); echo "set match to ereg<br>"; echo "entering mailto if<br>"; if(!isset($mailto)) { echo "inside mailto if<br>"; array_push($error_fields, "Mail To Field(select name from list"); $action = 3; } echo "entering sender if<br>"; if(!isset($sender)) { echo "inside sender if<br>"; array_push($error_fields, "From Field(fill in your email address)"); $action = 3; } echo "else statement for sender if<br>"; else { echo "entering match if<br>"; if(!match) { echo "inside match if<br>"; array_push($error_fields, "Invalid Email Address(please reenter your email address)"); $action = 3; } echo "done with match if<br>"; } echo "entering subject if<br>"; if(!isset($subject)) { echo "inside subject if<br>"; array_push($error_fields, "Empty Subject(please fill in the subject field for your message)"); $action = 3; } echo "entering body if<br>"; if(!isset($body)) { echo "inside body if<br>"; array_push($error_fields, "Empty Body field(please type some text in your for message)"); $action = 3; } echo "entering if for empty error fields array<br>"; if(empty($error_fields)) { echo "inside empty array if<br>"; $send_to = $people[$mailto]; $sender = chop($sender); $subject = chop($subject); $body = chop($body); $body = htmlspecialchars($body); $mail_headers = ''; $mail_headers .= "From:$sender\r\n"; $mail_headers .= "Reply-to:$sender\r\n"; } echo "entering else for empty array<br>"; else { echo "inside else<br>"; $action = 3; } echo "entering if for mail<br>"; if(!mail($send_to,$subject,$body,$mail_headers)) { echo "inside mail if<br>"; $action = 4; } } echo "outside of submit if<br>"; echo "entering switch statement<br>"; switch($action) { case 1: echo "in case 1<br>"; header_start("FPLG: CONTACT US!"); display_form(); break; case 2: echo "in case 2<br>"; header_start("FPLG: Mail status."); display_conf(); break; case 3: echo "in case 3<br>"; header_start("FPLG: Form error."); display_error($error_fields); display_form(); break; case 4: echo "in case 4<br>"; header_start("FPLG: Sending Error."); display_m_err(); break; } echo "outside of switch<br>"; function display_form() { global $send_to,$sender,$subject,$body; ?> <center> <form method="POST" action="contact.php"> <table width="692" cellspacing="1" cellpadding="0"> <tr align="center"> <td colspan="2" bgcolor="#ff6600"> <font size="2" face="verdana" color="#ffffff"> </td> </tr> <tr align="center"> <td width="35%" bgcolor="#808080" valign="top"> <font face="verdana" size="2" color="#ffffff">To:</font><br> <select name="mailto" size="1" style="BACKGROUND-COLOR: rgb(0,0,0); BORDER-BOTTOM: rgb(255,255,255) 1px solid; BORDER-LEFT: rgb(255,255,255) 1px solid; BORDER-RIGHT: rgb(255,255,255) 1px solid; BORDER-TOP: rgb(255,255,255) 1px solid; COLOR: rgb(255,255,255); FLOAT: none; FONT-FAMILY: verdana; FONT-SIZE: 8pt; LETTER-SPACING: normal; LINE-HEIGHT: normal; MARGIN-LEFT: 0px; PADDING-BOTTOM: 1px; PADDING-TOP: 1px; TEXT-ALIGN: center; TEXT-INDENT: 0px; VERTICAL-ALIGN: middle; scrollbar-arrow-color:#ffffff; scrollbar-base-color:#808080; scrollbar-Highlight-Color:#ffffff"> <option selected>Select from this list</option> <option value="band">Band</option> <option value="booking">Booking</option> <option value="jamie">Jamie Balmer</option> <option value="chris">Chris Cocuzzo</option> <option value="jared">Jared Salavatore</option> <option value="max">Max Baehr</option> <option value="ben">Ben Brenner</option> <option value="marcus">Marcus Sholar</option> </select> <br><br><br><br> <font face="verdana" size="2" color="#ffffff">From(email address):</font><br> <input type="text" name="sender" size="30" style="BACKGROUND-COLOR: rgb(0,0,0); BORDER-BOTTOM: rgb(255,255,255) 1px solid; BORDER-LEFT: rgb(255,255,255) 1px solid; BORDER-RIGHT: rgb(255,255,255) 1px solid; BORDER-TOP: rgb(255,255,255) 1px solid; COLOR: rgb(255,255,255); FLOAT: none; FONT-FAMILY: verdana; FONT-SIZE: 8pt; LETTER-SPACING: normal; LINE-HEIGHT: normal; MARGIN-LEFT: 0px; PADDING-BOTTOM: 1px; PADDING-TOP: 1px; TEXT-ALIGN: center; TEXT-INDENT: 0px; VERTICAL-ALIGN: middle"> <br><br> <font face="verdana" size="2" color="#ffffff">Subject</font><br> <input type="text" name="subject" size="30" style="BACKGROUND-COLOR: rgb(0,0,0); BORDER-BOTTOM: rgb(255,255,255) 1px solid; BORDER-LEFT: rgb(255,255,255) 1px solid; BORDER-RIGHT: rgb(255,255,255) 1px solid; BORDER-TOP: rgb(255,255,255) 1px solid; COLOR: rgb(255,255,255); FLOAT: none; FONT-FAMILY: verdana; FONT-SIZE: 8pt; LETTER-SPACING: normal; LINE-HEIGHT: normal; MARGIN-LEFT: 0px; PADDING-BOTTOM: 1px; PADDING-TOP: 1px; TEXT-ALIGN: center; TEXT-INDENT: 0px; VERTICAL-ALIGN: middle"> </td> <td width="65%" bgcolor="#808080"> <font face="verdana" size="2" color="#ffffff">Enter text of message in box below:</font><br> <textarea name="body" cols="68" rows="16" style="BACKGROUND-COLOR: rgb(0,0,0); BORDER-BOTTOM: rgb(255,255,255) 1px solid; BORDER-LEFT: rgb(255,255,255) 1px solid; BORDER-RIGHT: rgb(255,255,255) 1px solid; BORDER-TOP: rgb(255,255,255) 1px solid; COLOR: rgb(255,255,255); FLOAT: none; FONT-FAMILY: verdana; FONT-SIZE: 8pt; LETTER-SPACING: normal; LINE-HEIGHT: normal; MARGIN-LEFT: 0px; PADDING-BOTTOM: 1px; PADDING-TOP: 1px; TEXT-ALIGN: left; TEXT-INDENT: 0px; VERTICAL-ALIGN: middle"> </textarea> <br><br> </td> </tr> <tr align="center" valign="middle"> <td colspan="2" bgcolor="#ff6600" align="center" valign="middle"> <input type="submit" name="submit" value="Submit" style="BACKGROUND-COLOR: rgb(0,0,0); BORDER-BOTTOM: rgb(255,255,255) 1px solid; BORDER-LEFT: rgb(255,255,255) 1px solid; BORDER-RIGHT: rgb(255,255,255) 1px solid; BORDER-TOP: rgb(255,255,255) 1px solid; COLOR: rgb(255,255,255); FLOAT: none; FONT-FAMILY: verdana; FONT-SIZE: 8pt; LETTER-SPACING: normal; LINE-HEIGHT: normal; MARGIN-LEFT: 0px; PADDING-BOTTOM: 1px; PADDING-TOP: 1px; TEXT-ALIGN: center; TEXT-INDENT: 0px; VERTICAL-ALIGN: middle"> <input type="reset" value="Reset" style="BACKGROUND-COLOR: rgb(0,0,0); BORDER-BOTTOM: rgb(255,255,255) 1px solid; BORDER-LEFT: rgb(255,255,255) 1px solid; BORDER-RIGHT: rgb(255,255,255) 1px solid; BORDER-TOP: rgb(255,255,255) 1px solid; COLOR: rgb(255,255,255); FLOAT: none; FONT-FAMILY: verdana; FONT-SIZE: 8pt; LETTER-SPACING: normal; LINE-HEIGHT: normal; MARGIN-LEFT: 0px; PADDING-BOTTOM: 1px; PADDING-TOP: 1px; TEXT-ALIGN: center; TEXT-INDENT: 0px; VERTICAL-ALIGN: middle"> <input type="hidden" name="action" value="2"> </td> </tr> </table> </form> </center> <?php } function display_conf() { global $send_to,$subject; ?> <center> <table width="692" cellspacing="0" cellpadding="0"> <tr> <td align="center"> <font size="2" face="verdana,arial" color="WHITE"> Your message, '<?php echo $subject;?>' has been delivered to <?php echo $send_to;?>.<br> Expect a response back within the next couple of days.<br><br><br><br> <a href="/index.php?page=home" class="hov1">Click here to go back to the home page</a> </font> </td> </tr> </table> </center> <?php } function display_error($error_fields) { global $send_to,$sender,$subject,$body; ?> <center> <form method="POST" action="contact.php"> <table width="692" cellspacing="1" cellpadding="0"> <tr align="center"> <td colspan="2" bgcolor="#ff6600" align="center"> <font size="2" face="verdana" color="#ffffff"> The following form fields are blank/have errors:<br> <?php foreach($error_fields As $error) { echo "$error<br>"; } ?> Please correct your errors in resubmit. </font> </td> </tr> <tr align="center"> <td width="35%" bgcolor="#808080" valign="top"> <font face="verdana" size="2" color="#ffffff">To:</font><br> <select name="mailto" size="1" style="BACKGROUND-COLOR: rgb(0,0,0); BORDER-BOTTOM: rgb(255,255,255) 1px solid; BORDER-LEFT: rgb(255,255,255) 1px solid; BORDER-RIGHT: rgb(255,255,255) 1px solid; BORDER-TOP: rgb(255,255,255) 1px solid; COLOR: rgb(255,255,255); FLOAT: none; FONT-FAMILY: verdana; FONT-SIZE: 8pt; LETTER-SPACING: normal; LINE-HEIGHT: normal; MARGIN-LEFT: 0px; PADDING-BOTTOM: 1px; PADDING-TOP: 1px; TEXT-ALIGN: center; TEXT-INDENT: 0px; VERTICAL-ALIGN: middle; scrollbar-arrow-color:#ffffff; scrollbar-base-color:#808080; scrollbar-Highlight-Color:#ffffff"> <option selected>Select from this list</option> <option value="band">Band</option> <option value="booking">Booking</option> <option value="jamie">Jamie Balmer</option> <option value="chris">Chris Cocuzzo</option> <option value="jared">Jared Salavatore</option> <option value="max">Max Baehr</option> <option value="ben">Ben Brenner</option> <option value="marcus">Marcus Sholar</option> </select> <br><br><br><br> <font face="verdana" size="2" color="#ffffff">From(email address):</font><br> <input type="text" name="sender" size="30" style="BACKGROUND-COLOR: rgb(0,0,0); BORDER-BOTTOM: rgb(255,255,255) 1px solid; BORDER-LEFT: rgb(255,255,255) 1px solid; BORDER-RIGHT: rgb(255,255,255) 1px solid; BORDER-TOP: rgb(255,255,255) 1px solid; COLOR: rgb(255,255,255); FLOAT: none; FONT-FAMILY: verdana; FONT-SIZE: 8pt; LETTER-SPACING: normal; LINE-HEIGHT: normal; MARGIN-LEFT: 0px; PADDING-BOTTOM: 1px; PADDING-TOP: 1px; TEXT-ALIGN: center; TEXT-INDENT: 0px; VERTICAL-ALIGN: middle"> <br><br> <font face="verdana" size="2" color="#ffffff">Subject</font><br> <input type="text" name="subject" size="30" style="BACKGROUND-COLOR: rgb(0,0,0); BORDER-BOTTOM: rgb(255,255,255) 1px solid; BORDER-LEFT: rgb(255,255,255) 1px solid; BORDER-RIGHT: rgb(255,255,255) 1px solid; BORDER-TOP: rgb(255,255,255) 1px solid; COLOR: rgb(255,255,255); FLOAT: none; FONT-FAMILY: verdana; FONT-SIZE: 8pt; LETTER-SPACING: normal; LINE-HEIGHT: normal; MARGIN-LEFT: 0px; PADDING-BOTTOM: 1px; PADDING-TOP: 1px; TEXT-ALIGN: center; TEXT-INDENT: 0px; VERTICAL-ALIGN: middle"> </td> <td width="65%" bgcolor="#808080"> <font face="verdana" size="2" color="#ffffff">Enter text of message in box below:</font><br> <textarea name="body" cols="68" rows="16" style="BACKGROUND-COLOR: rgb(0,0,0); BORDER-BOTTOM: rgb(255,255,255) 1px solid; BORDER-LEFT: rgb(255,255,255) 1px solid; BORDER-RIGHT: rgb(255,255,255) 1px solid; BORDER-TOP: rgb(255,255,255) 1px solid; COLOR: rgb(255,255,255); FLOAT: none; FONT-FAMILY: verdana; FONT-SIZE: 8pt; LETTER-SPACING: normal; LINE-HEIGHT: normal; MARGIN-LEFT: 0px; PADDING-BOTTOM: 1px; PADDING-TOP: 1px; TEXT-ALIGN: left; TEXT-INDENT: 0px; VERTICAL-ALIGN: middle"> </textarea> <br><br> </td> </tr> <tr align="center" valign="middle"> <td colspan="2" bgcolor="#ff6600" align="center" valign="middle"> <input type="submit" name="submit" value="Submit" style="BACKGROUND-COLOR: rgb(0,0,0); BORDER-BOTTOM: rgb(255,255,255) 1px solid; BORDER-LEFT: rgb(255,255,255) 1px solid; BORDER-RIGHT: rgb(255,255,255) 1px solid; BORDER-TOP: rgb(255,255,255) 1px solid; COLOR: rgb(255,255,255); FLOAT: none; FONT-FAMILY: verdana; FONT-SIZE: 8pt; LETTER-SPACING: normal; LINE-HEIGHT: normal; MARGIN-LEFT: 0px; PADDING-BOTTOM: 1px; PADDING-TOP: 1px; TEXT-ALIGN: center; TEXT-INDENT: 0px; VERTICAL-ALIGN: middle"> <input type="reset" value="Reset" style="BACKGROUND-COLOR: rgb(0,0,0); BORDER-BOTTOM: rgb(255,255,255) 1px solid; BORDER-LEFT: rgb(255,255,255) 1px solid; BORDER-RIGHT: rgb(255,255,255) 1px solid; BORDER-TOP: rgb(255,255,255) 1px solid; COLOR: rgb(255,255,255); FLOAT: none; FONT-FAMILY: verdana; FONT-SIZE: 8pt; LETTER-SPACING: normal; LINE-HEIGHT: normal; MARGIN-LEFT: 0px; PADDING-BOTTOM: 1px; PADDING-TOP: 1px; TEXT-ALIGN: center; TEXT-INDENT: 0px; VERTICAL-ALIGN: middle"> <input type="hidden" name="action" value="2"> </td> </tr> </table> </form> </center> <?php } function display_m_err() { global $mailto; ?> <center> <table width="692" cellspacing="0" cellpadding="0"> <tr> <td align="center"> <font size="2" face="verdana,arial" color="WHITE"> There was a problem with sending your message to <?php echo $mailto;?><br><br> Please contact: webmaster@fplg.net and notify us of the problem. <br><br><br><br> <a href="/index.php?page=home" class="hov1">Click here to go back to the home page</a> </font> </td> </tr> </table> </center> <?php } ?>

« previous php.general (#62474) next »