codelinx Posted July 24, 2013 Share Posted July 24, 2013 The error i am getting is : Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/test/firewall.form.v2.php:256) in/var/www/html/test/firewall.form.v2.php on line 351 I cannot figure out what variables to change, I am open to reading, but i did not find anything that fixed my issue in particular. This is the Code for both pages: (please dont mind all the comments.... ) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" > <head> <title>Firewall Request Form</title> </head> <body> <h2>Firewall Request Form</h2> <?php require_once('firewallsuccess.php'); //date for time stamp on page $date = date("l F j, o g:i:s a"); //variable error array $error = array(); //error data in the variable for each element $siperror = '<strong><b><font style="color:#FF0000">Source IP Address:</font></b></strong> Please fill out the source/destiantion IP address with proper number formatting.'; $diperror = '<strong><b><font style="color:#FF0000">Destination IP Address:</font></b></strong> Please fill out the source/destiantion IP address with proper number formatting.'; $sporterror = '<strong><b><font style="color:#FF0000">Source Port:</font></b></strong> Please fill out the source/destiantion port.'; $dporterror = '<strong><b><font style="color:#FF0000">Destination Port:</font></b></strong> Please fill out the source/destiantion port.'; $protocolerror = '<strong><b><font style="color:#FF0000">Protocol:</font></b></strong> Please selec a protocol(i.e. TCP...UDP).'; $protocolerrorshort = '<strong><b><font style="color:#FF0000">Protocol:</font></b></strong> Protocol too <strong><b><i><font style="color:#FF0000">short.</font></i></b></strong> Please fill out the protocol required(i.e. TCP...UDP).'; $protocolerrorlong = '<strong><b><font style="color:#FF0000">Protocol:</font></b></strong> Protocol too <strong><b><i><font style="color:#FF0000">long.</font></i></b></strong> Please fill out the protocol required(i.e. TCP...UDP).'; $sapperror = '<strong><b><font style="color:#FF0000">Source Application:</font></b></strong> Please fill out the source/destiantion application.'; $dapperror = '<strong><b><font style="color:#FF0000">Destination Application:</font></b></strong> Please fill out the source/destiantion application.'; $reasonerror = '<strong><b><font style="color:#FF0000">Description/Reason:</font></b></strong> Please fill out the reason/description box'; $emailerror = '<strong><b><font style="color:#FF0000">Email:</font></b></strong> Please fill out the username/email.'; $email_to = "test@email.com"; $page = 'firewallsuccess.php'; if (isset($_POST['submit'])) { // pass POST to variables $fr_s_ip = $_POST['fr_s_ip']; $fr_d_ip = $_POST['fr_d_ip']; $fr_s_port = $_POST['fr_s_port']; $fr_d_port = $_POST['fr_d_port']; $fr_protocol = $_POST['fr_protocol']; //$fr_protocol_other = $_POST['fr_protocol_other']; $fr_s_app = $_POST['fr_s_app']; $fr_d_app = $_POST['fr_d_app']; $fr_reason = $_POST['fr_reason']; $fr_email = $_POST['fr_email']; // email vairable for: mail($to, $subject, $mail_body); // conditions for errors such as is empty or validation functions // Source IP Address validation with exception only for IPV4 validation // works in php >= 5.2.0: if (!filter_var($fr_s_ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> if ( !preg_match( '/^(??:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])'.'\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]?|[0-9])$/',$fr_s_ip)) { $error[] = $siperror; } // Destination IP Address validation with exception only for IPV4 validation // works in php >= 5.2.0: if (!filter_var($fr_d_ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)){ // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> //if (!preg_match("^[0-255]{1,3}/./[0-255]{1,3}/./+[0-255]{1,3}/./+[0-255]{1,3}$",$fr_s_ip) //if (!preg_match("^[0-255]+[\.]+[0-255]+[\.]+[0-255]+[\.]+[0-255]$",$fr_s_ip) // other sources: http://komunitasweb.com/2009/03/10-practical-php-regular-expression-recipes/ // pulled from: http://answers.oreilly.com/topic/318-how-to-match-ipv4-addresses-with-regular-expressions/ // ("^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$") if (!preg_match('/^(??:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])'.'\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]?|[0-9])$/',$fr_d_ip)){ $error[] = $diperror; } // Source Port error //http://stackoverflow.com/questions/6726450/check-for-valid-hostport-combination if (empty($fr_s_port)){ $error[] = $sporterror; } // Destination Port error // http://stackoverflow.com/questions/6726450/check-for-valid-hostport-combination if (empty($fr_d_port)){ $error[] = $dporterror; } // protocol error //if (empty($fr_protocol)){ //$error[] = $protocolerror; //}elseif(strlen($fr_protocol)<2){ //$error[] = $protocolerrorshort; //}elseif(strlen($fr_protocol)>4){ //$error[] = $protocolerrorlong; //} //if (!isset($fr_protocol)){ if(empty($fr_protocol)){ $error[] = $protocolerror; } //} // source application error if (empty($fr_s_app)){ $error[] = $sapperror; } // destination application error if (empty($fr_d_app)){ $error[] = $dapperror; } //description error if (empty($fr_reason)){ $error[] = $reasonerror; } // email error // works in php >= 5.2.0: if (filter_var($fr_email, FILTER_VALIDATE_EMAIL) === FALSE){ if (!preg_match("^[_a-zA-Z0-9-]+(\.[\w-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,3})$^", $fr_email)){ $error[] = $emailerror; //'Email: Please submit a valid email.'; } if (isset($fr_sd_ap)){$subject = $fr_sd_ap;} // if (isset($fr_sd_ap)){$headers = "From: " . $fr_email;} $mail_body = "From: " . $fr_email . "\n"; $mail_body .= "\nSource IP Address: " . $fr_s_ip ; $mail_body .= "\nDestination IP Address: " . $fr_d_ip . "\n"; $mail_body .= "\nSource Port: " . $fr_s_port ; $mail_body .= "\nDestinationPort: " . $fr_d_port . "\n"; $mail_body .= "\nProtocol: " . $fr_protocol . "\n"; $mail_body .= "\nSource Application: " . $fr_s_app ; $mail_body .= "\nDestination Application: " . $fr_d_app . "\n"; $mail_body .= "\nDescription/Reason: " . $fr_reason . "\n"; } ?> <form action="" method="POST"> <!-- This form is setup to allow the user to request changes to the firewall with requirements needed outlined in the form below. Fields needed are: Description, Source/Dest. port,Source/Dest. ip, Source/Dest. Application, Protocol (i.e. TCP, UDP, etc.), Username/Email --> <fieldset> <table width="800px"> <!-- IP ADDRESS--> <tr> <!-- This section has two parts that will be conjoined for Source and Destination IP address variables followed through to the message on the same row --> <!-- Source IP container--> <td valign="top" size="20%"> <label for="fr_s_ip" >Source IP Address: *</label> </td> <td valign="top"> <input type="text" id="fr_s_ip" maxlength="30" size="20" placeholder="i.e. Format: 0.0.0.0" value="<?php echo (isset($_POST['fr_s_ip'])) ? htmlentities($_POST["fr_s_ip"]) : ''; ?>"/> </td> <td> <span class="error" style="color:#FF0000"></span> </td> <!-- Source IP container--> <!-- Destination IP container--> <td valign="top" size="20%"> <label for="fr_d_ip" >Destination IP Address: *</label> </td> <td valign="top"> <input type="text" id="fr_d_ip" maxlength="30" size="20" placeholder="i.e. Format: 0.0.0.0" value="<?php echo (isset($_POST['fr_d_ip'])) ? htmlentities($_POST["fr_d_ip"]) : ''; ?>"/> </td> <td> <span class="error" style="color:#FF0000"></span> </td> <!-- Destination IP container--> </tr> <!--IP ADDRESS--> <!--PORTS--> <!-- Source Port container--> <tr> <td valign="top" size="20%"> <label for="fr_s_port">Source Port: *</label> </td> <td valign="top"> <input type="text" id="fr_s_port" maxlength="6" size="20" value="<?php echo (isset($_POST['fr_s_port'])) ? htmlentities($_POST["fr_s_port"]) : ''; ?>"/> </td> <td size="45%"> <span class="error" style="color:#FF0000"></span> </td> <!-- Source Port container--> <!-- Destination Port container--> <td valign="top" size="20%"> <label for="fr_d_port">Destination Port: *</label> </td> <td valign="top"> <input type="text" id="fr_d_port" maxlength="6" size="20" value="<?php echo (isset($_POST['fr_d_port'])) ? htmlentities($_POST["fr_d_port"]) : ''; ?>"/> </td> <td size="45%"> <span class="error" style="color:#FF0000"></span> </td> <!-- Destination Port container--> </tr> <!--PORTS--> <!--PROTOCOL--> <tr> <td valign="top" size="20%"> <label for="fr_protocol">Protocol: *</label> </td> <td valign="top"> <input type="text" id="fr_protocol" maxlength="20" size="20" value="<?php //echo (isset($_POST['fr_protocol'])) ? htmlentities($_POST["fr_protocol"]) : ''; ?>"/> </td> <td size="45%"> <span class="error" style="color:#FF0000"></span> </td> </tr> <!-- textbox for protocol end--> <!-- NOTE : WIP ******************************************************************* <tr> <td valign="top" size="20%"> <label for="fr_protocol">Protocol: *</label> </td> <td valign="top"> <select id="fr_protocol" > <option value="<?php //echo (isset($_POST['fr_protocol'])) ? htmlentities($_POST["fr_protocol"]) : ''; ?>" selected="Select" >Select<option/> <option value="<?php //echo (isset($_POST['submit'])) ? htmlentities($_POST["fr_protocol"]) : ''; ?>" >TCP<option/> <option value="<?php //echo (isset($_POST['fr_protocol'])) ? htmlentities($_POST["fr_protocol"]) : ''; ?>" >UDP<option/> <option value="<?php //echo (isset($_POST['fr_protocol'])) ? htmlentities($_POST["fr_protocol"]) : ''; ?>" >TCP/UDP<option/> <option value="<?php //echo (isset($_POST['fr_protocol'])) ? htmlentities($_POST["fr_protocol"]) : ''; ?>" >FTP<option/> <option value="<?php //echo (isset($_POST['fr_protocol'])) ? htmlentities($_POST["fr_protocol"]) : ''; ?>" >None<option/> <option onchange="showtextbox()" value="other" id="fr_protocol_other" >Other<option/> <select/> <input type="text" id="fr_protocol_otherfld" maxlength="4" size="9" style="display:none;" /> <script type="text/javascript" > function showtextbox(){ if (document.getElementById("fr_protocol_other").value === "other") { document.getElementById("fr_protocol_otherfld").style.display ="block"; } else { document.getElementById("fr_protocol_otherfld").style.display ="none'; } } </script> NOTE : WIP ******************************************************************* --> </td> <td size="45%"> <span class="error" style="color:#FF0000"></span> </td> </tr> <!--PROTOCOL--> <!--APPLICATION--> <!-- i.e. Source: Dealer \ Dest.: MDS --> <tr> <!-- Source App container--> <td valign="top" size="20%"> <label for="fr_s_app">Source Application: *</label> </td> <td valign="top"> <input type="text" id="fr_s_app" maxlength="30" size="20" placeholder="i.e. Dealer" value="<?php echo (isset($_POST['fr_s_app'])) ? htmlentities($_POST["fr_s_app"]) : ''; ?>"/> </td> <td size="45%"> <span class="error" style="color:#FF0000"></span> </td> <!-- Source App container--> <!-- Destination App container--> <td valign="top" size="20%"> <label for="fr_d_app">Destination Application: *</label> </td> <td valign="top"> <input type="text" id="fr_d_app" maxlength="30" size="20" placeholder="i.e. MDS" value="<?php echo (isset($_POST['fr_d_app'])) ? htmlentities($_POST["fr_d_app"]) : ''; ?>"/> </td> <td size="45%"> <span class="error" style="color:#FF0000"></span> </td> <!-- Destination App container--> </tr> <!--APPLICATION--> <!--DESCRIPTION/REASON--> <!-- NOTE: in the <textarea></textarea> tags there can be no line breaks or white space or refreshing the page or hitting the submit button will insert that into the text area and not produce a proper error message. --> <tr> <td valign="top" size="20%"> <label for="fr_reason">Description/Reason: *</label> </td> <td valign="top"> <textarea id="fr_reason" maxlength="1000" col="20" rows="8" placeholder="Describe the scenario..."><?php echo (isset($_POST['fr_reason'])) ? htmlentities($_POST["fr_reason"]) : ''; ?></textarea> </td> <td size="45%"> <span class="error" style="color:#FF0000"></span> </td> </tr> <!--DESCRIPTION/REASON--> <!--USERNAME/EMAIL--> <tr> <td valign="top" size="20%"> <label for="fr_email">Username/Email: *</label> </td> <td valign="top"> <input type="text" id="fr_email" maxlength="30" size="20" placeholder="test@otcmarkets.com" value="<?php echo (isset($_POST['fr_email'])) ? htmlentities($_POST["fr_email"]) : ''; ?>"/> </td> <td size="45%"> <span class="error" style="color:#FF0000"></span> </td> </tr> <!--USERNAME/EMAIL--> </table> </fieldset> <br /> <input type="submit" value="Email Firewall Request" id="submit" onsubmit="<?php //if (empty($error)){ //if (isset($_POST['submit'])){ //produce success message //$success = '<i><u>Status: Your firewall request form has been submitted.</u></i>'; //echo $success; //} //} ?>" /> <input type="reset" value="Clear Form" id="reset"/> <br /><br /> <?php echo "\nToday is: $date"; ?> <br /> <br /> <tr> <td valign="top"> <?php //if the fields are empty prompt the user with "[All fields required]" if (empty($fr_s_ip) && empty($fr_d_ip) && empty($fr_s_port) && empty($fr_d_port) && empty($fr_protocol) && empty($fr_s_app) && empty($fr_d_app) && empty($fr_reason) && empty($fr_email)){ $fieldsrequired = '<strong><b><font style="color:#FF0000">All the fields with \'*\' are required.</font></b></strong><br />'; echo $fieldsrequired; } // if the error variable is not empty loop through the errors and display them if (!empty($error)){ foreach($error as $errorsoutput){ //html formatting plus the error message using the '.' (period symbol) echo $errorsoutput.'<br>'; } }else{ //mail function @mail($email_to,$subject,$mail_body); //if mail() returns 1 or true print $success variable if (@mail($email_to,$subject,$mail_body)){ //produce success message //$success = '<i><u>Status: Your firewall request form has been submitted.</u></i>'; //echo $success; header("Location: " . $page); } } if (isset($_POST['fr_protocol_other'])){ $status = 'visible'; }else{ $status = 'hidden'; } ?> </td> </tr> </form> <br/> </body> </html> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" > <head> <title>Firewall Request Form</title> </head> <body> <h2></h2> <?php $fwform = 'firewall.form.v2.php'; $success = '<i><u>Status: Your firewall request form has been submitted.</u></i>'; echo $success; ob_clean(); ?> </body> </html> Thank you in advance for any suggestions..... Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted July 24, 2013 Share Posted July 24, 2013 http://forums.phpfreaks.com/topic/273121-readme-php-resources-faqs/?do=findComment&comment=1405508 Quote Link to comment Share on other sites More sharing options...
codelinx Posted July 24, 2013 Author Share Posted July 24, 2013 Thank you very much... all the links i found were dead... I am going to go through this now... Quote Link to comment Share on other sites More sharing options...
codelinx Posted July 24, 2013 Author Share Posted July 24, 2013 My problem i think is the organization of my code. This is my first webpage ever, but i think the problem lies in where I am placing variables, output, and if() statements. The flow control is not working correctly, which is giving me undesirable results. Quote Link to comment Share on other sites More sharing options...
codelinx Posted July 24, 2013 Author Share Posted July 24, 2013 (edited) I updated my code for pages: <?php $page = 'firewallsuccess.php'; //date for time stamp on page $date = date("l F j, o g:i:s a"); //variable error array $error = array(); //error data in the variable for each element $siperror = '<strong><b><font style="color:#FF0000">Source IP Address:</font></b></strong> Please fill out the source/destiantion IP address with proper number formatting.'; $diperror = '<strong><b><font style="color:#FF0000">Destination IP Address:</font></b></strong> Please fill out the source/destiantion IP address with proper number formatting.'; $sporterror = '<strong><b><font style="color:#FF0000">Source Port:</font></b></strong> Please fill out the source/destiantion port.'; $dporterror = '<strong><b><font style="color:#FF0000">Destination Port:</font></b></strong> Please fill out the source/destiantion port.'; $protocolerror = '<strong><b><font style="color:#FF0000">Protocol:</font></b></strong> Please selec a protocol(i.e. TCP...UDP).'; $protocolerrorshort = '<strong><b><font style="color:#FF0000">Protocol:</font></b></strong> Protocol too <strong><b><i><font style="color:#FF0000">short.</font></i></b></strong> Please fill out the protocol required(i.e. TCP...UDP).'; $protocolerrorlong = '<strong><b><font style="color:#FF0000">Protocol:</font></b></strong> Protocol too <strong><b><i><font style="color:#FF0000">long.</font></i></b></strong> Please fill out the protocol required(i.e. TCP...UDP).'; $sapperror = '<strong><b><font style="color:#FF0000">Source Application:</font></b></strong> Please fill out the source/destiantion application.'; $dapperror = '<strong><b><font style="color:#FF0000">Destination Application:</font></b></strong> Please fill out the source/destiantion application.'; $reasonerror = '<strong><b><font style="color:#FF0000">Description/Reason:</font></b></strong> Please fill out the reason/description box'; $emailerror = '<strong><b><font style="color:#FF0000">Email:</font></b></strong> Please fill out the username/email.'; $email_to = "test@email.com"; if (isset($_POST['submit'])) { // pass POST to variables $fr_s_ip = $_POST['fr_s_ip']; $fr_d_ip = $_POST['fr_d_ip']; $fr_s_port = $_POST['fr_s_port']; $fr_d_port = $_POST['fr_d_port']; $fr_protocol = $_POST['fr_protocol']; //$fr_protocol_other = $_POST['fr_protocol_other']; $fr_s_app = $_POST['fr_s_app']; $fr_d_app = $_POST['fr_d_app']; $fr_reason = $_POST['fr_reason']; $fr_email = $_POST['fr_email']; // email vairable for: mail($to, $subject, $mail_body); // conditions for errors such as is empty or validation functions // Source IP Address validation with exception only for IPV4 validation // works in php >= 5.2.0: if (!filter_var($fr_s_ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> if ( !preg_match( '/^(??:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])'.'\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]?|[0-9])$/',$fr_s_ip)) { $error[] = $siperror; } // Destination IP Address validation with exception only for IPV4 validation // works in php >= 5.2.0: if (!filter_var($fr_d_ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)){ // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> //if (!preg_match("^[0-255]{1,3}/./[0-255]{1,3}/./+[0-255]{1,3}/./+[0-255]{1,3}$",$fr_s_ip) //if (!preg_match("^[0-255]+[\.]+[0-255]+[\.]+[0-255]+[\.]+[0-255]$",$fr_s_ip) // other sources: http://komunitasweb.com/2009/03/10-practical-php-regular-expression-recipes/ // pulled from: http://answers.oreilly.com/topic/318-how-to-match-ipv4-addresses-with-regular-expressions/ // ("^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$") if (!preg_match('/^(??:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])'.'\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]?|[0-9])$/',$fr_d_ip)){ $error[] = $diperror; } // Source Port error //http://stackoverflow.com/questions/6726450/check-for-valid-hostport-combination if (empty($fr_s_port)){ $error[] = $sporterror; } // Destination Port error // http://stackoverflow.com/questions/6726450/check-for-valid-hostport-combination if (empty($fr_d_port)){ $error[] = $dporterror; } // protocol error //if (empty($fr_protocol)){ //$error[] = $protocolerror; //}elseif(strlen($fr_protocol)<2){ //$error[] = $protocolerrorshort; //}elseif(strlen($fr_protocol)>4){ //$error[] = $protocolerrorlong; //} //if (!isset($fr_protocol)){ if(empty($fr_protocol)){ $error[] = $protocolerror; } //} // source application error if (empty($fr_s_app)){ $error[] = $sapperror; } // destination application error if (empty($fr_d_app)){ $error[] = $dapperror; } //description error if (empty($fr_reason)){ $error[] = $reasonerror; } // email error // works in php >= 5.2.0: if (filter_var($fr_email, FILTER_VALIDATE_EMAIL) === FALSE){ if (!preg_match("^[_a-zA-Z0-9-]+(\.[\w-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,3})$^", $fr_email)){ $error[] = $emailerror; //'Email: Please submit a valid email.'; } if (isset($fr_sd_ap)){$subject = $fr_sd_ap;} // if (isset($fr_sd_ap)){$headers = "From: " . $fr_email;} $mail_body = "From: " . $fr_email . "\n"; $mail_body .= "\nSource IP Address: " . $fr_s_ip ; $mail_body .= "\nDestination IP Address: " . $fr_d_ip . "\n"; $mail_body .= "\nSource Port: " . $fr_s_port ; $mail_body .= "\nDestinationPort: " . $fr_d_port . "\n"; $mail_body .= "\nProtocol: " . $fr_protocol . "\n"; $mail_body .= "\nSource Application: " . $fr_s_app ; $mail_body .= "\nDestination Application: " . $fr_d_app . "\n"; $mail_body .= "\nDescription/Reason: " . $fr_reason . "\n"; header("Location: " . $page); $header = header("Location: " . $page); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" > <head> <title>Firewall Request Form</title> </head> <body> <h2>Firewall Request Form</h2> <form action="" method="POST"> <!-- This form is setup to allow the user to request changes to the firewall with requirements needed outlined in the form below. Fields needed are: Description, Source/Dest. port,Source/Dest. ip, Source/Dest. Application, Protocol (i.e. TCP, UDP, etc.), Username/Email --> <fieldset> <table width="800px"> <!-- IP ADDRESS--> <tr> <!-- This section has two parts that will be conjoined for Source and Destination IP address variables followed through to the message on the same row --> <!-- Source IP container--> <td valign="top" size="20%"> <label for="fr_s_ip" >Source IP Address: *</label> </td> <td valign="top"> <input type="text" id="fr_s_ip" maxlength="30" size="20" placeholder="i.e. Format: 0.0.0.0" value="<?php echo (isset($_POST['fr_s_ip'])) ? htmlentities($_POST["fr_s_ip"]) : ''; ?>"/> </td> <td> <span class="error" style="color:#FF0000"></span> </td> <!-- Source IP container--> <!-- Destination IP container--> <td valign="top" size="20%"> <label for="fr_d_ip" >Destination IP Address: *</label> </td> <td valign="top"> <input type="text" id="fr_d_ip" maxlength="30" size="20" placeholder="i.e. Format: 0.0.0.0" value="<?php if(isset($_POST['submit'])){echo (isset($_POST['fr_d_ip'])) ? htmlentities($_POST["fr_d_ip"]) : '';} ?>"/> </td> <td> <span class="error" style="color:#FF0000"></span> </td> <!-- Destination IP container--> </tr> <!--IP ADDRESS--> <!--PORTS--> <!-- Source Port container--> <tr> <td valign="top" size="20%"> <label for="fr_s_port">Source Port: *</label> </td> <td valign="top"> <input type="text" id="fr_s_port" maxlength="6" size="20" value="<?php echo (isset($_POST['fr_s_port'])) ? htmlentities($_POST["fr_s_port"]) : ''; ?>"/> </td> <td size="45%"> <span class="error" style="color:#FF0000"></span> </td> <!-- Source Port container--> <!-- Destination Port container--> <td valign="top" size="20%"> <label for="fr_d_port">Destination Port: *</label> </td> <td valign="top"> <input type="text" id="fr_d_port" maxlength="6" size="20" value="<?php echo (isset($_POST['fr_d_port'])) ? htmlentities($_POST["fr_d_port"]) : ''; ?>"/> </td> <td size="45%"> <span class="error" style="color:#FF0000"></span> </td> <!-- Destination Port container--> </tr> <!--PORTS--> <!--PROTOCOL--> <tr> <td valign="top" size="20%"> <label for="fr_protocol">Protocol: *</label> </td> <td valign="top"> <input type="text" id="fr_protocol" maxlength="20" size="20" value="<?php //echo (isset($_POST['fr_protocol'])) ? htmlentities($_POST["fr_protocol"]) : ''; ?>"/> </td> <td size="45%"> <span class="error" style="color:#FF0000"></span> </td> </tr> <!-- textbox for protocol end--> <!-- NOTE : WIP ******************************************************************* <tr> <td valign="top" size="20%"> <label for="fr_protocol">Protocol: *</label> </td> <td valign="top"> <select id="fr_protocol" > <option value="<?php //echo (isset($_POST['fr_protocol'])) ? htmlentities($_POST["fr_protocol"]) : ''; ?>" selected="Select" >Select<option/> <option value="<?php //echo (isset($_POST['submit'])) ? htmlentities($_POST["fr_protocol"]) : ''; ?>" >TCP<option/> <option value="<?php //echo (isset($_POST['fr_protocol'])) ? htmlentities($_POST["fr_protocol"]) : ''; ?>" >UDP<option/> <option value="<?php //echo (isset($_POST['fr_protocol'])) ? htmlentities($_POST["fr_protocol"]) : ''; ?>" >TCP/UDP<option/> <option value="<?php //echo (isset($_POST['fr_protocol'])) ? htmlentities($_POST["fr_protocol"]) : ''; ?>" >FTP<option/> <option value="<?php //echo (isset($_POST['fr_protocol'])) ? htmlentities($_POST["fr_protocol"]) : ''; ?>" >None<option/> <option onchange="showtextbox()" value="other" id="fr_protocol_other" >Other<option/> <select/> <input type="text" id="fr_protocol_otherfld" maxlength="4" size="9" style="display:none;" /> <script type="text/javascript" > function showtextbox(){ if (document.getElementById("fr_protocol_other").value === "other") { document.getElementById("fr_protocol_otherfld").style.display ="block"; } else { document.getElementById("fr_protocol_otherfld").style.display ="none'; } } </script> NOTE : WIP ******************************************************************* --> </td> <td size="45%"> <span class="error" style="color:#FF0000"></span> </td> </tr> <!--PROTOCOL--> <!--APPLICATION--> <!-- i.e. Source: Dealer \ Dest.: MDS --> <tr> <!-- Source App container--> <td valign="top" size="20%"> <label for="fr_s_app">Source Application: *</label> </td> <td valign="top"> <input type="text" id="fr_s_app" maxlength="30" size="20" placeholder="i.e. Dealer" value="<?php echo (isset($_POST['fr_s_app'])) ? htmlentities($_POST["fr_s_app"]) : ''; ?>"/> </td> <td size="45%"> <span class="error" style="color:#FF0000"></span> </td> <!-- Source App container--> <!-- Destination App container--> <td valign="top" size="20%"> <label for="fr_d_app">Destination Application: *</label> </td> <td valign="top"> <input type="text" id="fr_d_app" maxlength="30" size="20" placeholder="i.e. MDS" value="<?php echo (isset($_POST['fr_d_app'])) ? htmlentities($_POST["fr_d_app"]) : ''; ?>"/> </td> <td size="45%"> <span class="error" style="color:#FF0000"></span> </td> <!-- Destination App container--> </tr> <!--APPLICATION--> <!--DESCRIPTION/REASON--> <!-- NOTE: in the <textarea></textarea> tags there can be no line breaks or white space or refreshing the page or hitting the submit button will insert that into the text area and not produce a proper error message. --> <tr> <td valign="top" size="20%"> <label for="fr_reason">Description/Reason: *</label> </td> <td valign="top"> <textarea id="fr_reason" maxlength="1000" col="20" rows="8" placeholder="Describe the scenario..."><?php echo (isset($_POST['fr_reason'])) ? htmlentities($_POST["fr_reason"]) : ''; ?></textarea> </td> <td size="45%"> <span class="error" style="color:#FF0000"></span> </td> </tr> <!--DESCRIPTION/REASON--> <!--USERNAME/EMAIL--> <tr> <td valign="top" size="20%"> <label for="fr_email">Username/Email: *</label> </td> <td valign="top"> <input type="text" id="fr_email" maxlength="30" size="20" placeholder="test@otcmarkets.com" value="<?php echo (isset($_POST['fr_email'])) ? htmlentities($_POST["fr_email"]) : ''; ?>"/> </td> <td size="45%"> <span class="error" style="color:#FF0000"></span> </td> </tr> <!--USERNAME/EMAIL--> </table> </fieldset> <br /> <input type="submit" value="Email Firewall Request" id="submit" onsubmit="<?php //if (empty($error)){ //if (isset($_POST['submit'])){ //produce success message //$success = '<i><u>Status: Your firewall request form has been submitted.</u></i>'; //echo $success; //} //} ?>" /> <input type="reset" value="Clear Form" id="reset"/> <br /><br /> <?php echo "\nToday is: $date"; ?> <br /> <br /> <tr> <td valign="top"> </td> </tr> </form> <br/> <?php //if the fields are empty prompt the user with "[All fields required]" if (empty($fr_s_ip) && empty($fr_d_ip) && empty($fr_s_port) && empty($fr_d_port) && empty($fr_protocol) && empty($fr_s_app) && empty($fr_d_app) && empty($fr_reason) && empty($fr_email)){ $fieldsrequired = '<strong><b><font style="color:#FF0000">All the fields with \'*\' are required.</font></b></strong><br />'; echo $fieldsrequired; } // if the error variable is not empty loop through the errors and display them if (!empty($error)){ foreach($error as $errorsoutput){ //html formatting plus the error message using the '.' (period symbol) echo $errorsoutput.'<br>'; } }elseif(isset($_POST['submit'])){//if mail() returns 1 or true print $success variable //mail function @mail($email_to,$subject,$mail_body); //produce success message //$success = '<i><u>Status: Your firewall request form has been submitted.</u></i>'; //echo $success; $header; } ?> </body> </html> Success Page: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" > <head> <title>Firewall Request Form</title> </head> <body> <h2></h2> <?php //$fwform = 'firewall.form.v2.php'; $success = '<i><u>Status: Your firewall request form has been submitted.</u></i>'; echo $success; ?> </body> </html> I now have 2 problems, which are bothersome, when the submit button is hit the form clears even if there are empty fields, when you are navigating to the page you are sometimes automatically directed to the success.php page, and the last problem is that i have tried running different edits, but this one does not error, it just doesn't work as intended. Edited July 24, 2013 by codelinx Quote Link to comment Share on other sites More sharing options...
codelinx Posted July 24, 2013 Author Share Posted July 24, 2013 Okay i removed the reference to headers and placed in the last php {} <?php .... $header ?> I also removed the duplicate $header variable in the first <?php?> section. Next i left the variable $page = 'firewallsuccess.php'; on the first line in the php section before the html and form. I changed the last elsif(){} in the last php section to: if(!empty($error)){ if (isset($_POST['submit'])){//if mail() returns 1 or true print $success variable //mail function @mail($email_to,$subject,$mail_body); //produce success message //$success = '<i><u>Status: Your firewall request form has been submitted.</u></i>'; //echo $success; $header; } Quote Link to comment Share on other sites More sharing options...
codelinx Posted July 24, 2013 Author Share Posted July 24, 2013 I added functions to call them when needed and passed them the variable they need to process.... Here is my changed code if anyone can help or make some suggestions on code structure, form changes, organization, and maybe some examples and or references would be great also. <?php $page = 'firewallsuccess.php'; //date for time stamp on page $date = date("l F j, o g:i:s a"); //variable error array $error = array(); //error data in the variable for each element $siperror = '<strong><b><font style="color:#FF0000">Source IP Address:</font></b></strong> Please fill out the source/destiantion IP address with proper number formatting.'; $diperror = '<strong><b><font style="color:#FF0000">Destination IP Address:</font></b></strong> Please fill out the source/destiantion IP address with proper number formatting.'; $sporterror = '<strong><b><font style="color:#FF0000">Source Port:</font></b></strong> Please fill out the source/destiantion port.'; $dporterror = '<strong><b><font style="color:#FF0000">Destination Port:</font></b></strong> Please fill out the source/destiantion port.'; $protocolerror = '<strong><b><font style="color:#FF0000">Protocol:</font></b></strong> Please selec a protocol(i.e. TCP...UDP).'; $protocolerrorshort = '<strong><b><font style="color:#FF0000">Protocol:</font></b></strong> Protocol too <strong><b><i><font style="color:#FF0000">short.</font></i></b></strong> Please fill out the protocol required(i.e. TCP...UDP).'; $protocolerrorlong = '<strong><b><font style="color:#FF0000">Protocol:</font></b></strong> Protocol too <strong><b><i><font style="color:#FF0000">long.</font></i></b></strong> Please fill out the protocol required(i.e. TCP...UDP).'; $sapperror = '<strong><b><font style="color:#FF0000">Source Application:</font></b></strong> Please fill out the source/destiantion application.'; $dapperror = '<strong><b><font style="color:#FF0000">Destination Application:</font></b></strong> Please fill out the source/destiantion application.'; $reasonerror = '<strong><b><font style="color:#FF0000">Description/Reason:</font></b></strong> Please fill out the reason/description box'; $emailerror = '<strong><b><font style="color:#FF0000">Email:</font></b></strong> Please fill out the username/email.'; $email_to = "test@email.com"; function submit($post){ if (isset($_POST['submit'])){ // pass POST to variables $fr_s_ip = $_POST['fr_s_ip']; $fr_d_ip = $_POST['fr_d_ip']; $fr_s_port = $_POST['fr_s_port']; $fr_d_port = $_POST['fr_d_port']; $fr_protocol = $_POST['fr_protocol']; //$fr_protocol_other = $_POST['fr_protocol_other']; $fr_s_app = $_POST['fr_s_app']; $fr_d_app = $_POST['fr_d_app']; $fr_reason = $_POST['fr_reason']; $fr_email = $_POST['fr_email']; // email vairable for: mail($to, $subject, $mail_body); // conditions for errors such as is empty or validation functions // Source IP Address validation with exception only for IPV4 validation // works in php >= 5.2.0: if (!filter_var($fr_s_ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> if (!preg_match('/^(??:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])'.'\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]?|[0-9])$/',$fr_s_ip)){ $error[] = $siperror; } // Destination IP Address validation with exception only for IPV4 validation // works in php >= 5.2.0: if (!filter_var($fr_d_ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)){ // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> // if (!preg_match("^[0-255]{1,3}/./[0-255]{1,3}/./+[0-255]{1,3}/./+[0-255]{1,3}$",$fr_s_ip) // if (!preg_match("^[0-255]+[\.]+[0-255]+[\.]+[0-255]+[\.]+[0-255]$",$fr_s_ip) // other sources: http://komunitasweb.com/2009/03/10-practical-php-regular-expression-recipes/ // pulled from: http://answers.oreilly.com/topic/318-how-to-match-ipv4-addresses-with-regular-expressions/ // ("^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$") if (!preg_match('/^(??:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])'.'\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]?|[0-9])$/',$fr_d_ip)){ $error[] = $diperror; } // Source Port error //http://stackoverflow.com/questions/6726450/check-for-valid-hostport-combination if (empty($fr_s_port)){ $error[] = $sporterror; } // Destination Port error // http://stackoverflow.com/questions/6726450/check-for-valid-hostport-combination if (empty($fr_d_port)){ $error[] = $dporterror; } // protocol error //if (empty($fr_protocol)){ //$error[] = $protocolerror; //}elseif(strlen($fr_protocol)<2){ //$error[] = $protocolerrorshort; //}elseif(strlen($fr_protocol)>4){ //$error[] = $protocolerrorlong; //} //if (!isset($fr_protocol)){ if(empty($fr_protocol)){ $error[] = $protocolerror; } //} // source application error if (empty($fr_s_app)){ $error[] = $sapperror; } // destination application error if (empty($fr_d_app)){ $error[] = $dapperror; } //description error if (empty($fr_reason)){ $error[] = $reasonerror; } // email error // works in php >= 5.2.0: if (filter_var($fr_email, FILTER_VALIDATE_EMAIL) === FALSE){ if (!preg_match("^[_a-zA-Z0-9-]+(\.[\w-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,3})$^", $fr_email)){ $error[] = $emailerror; //'Email: Please submit a valid email.'; } function mailset($fr_sd_ap){ if (isset($fr_sd_ap)){$subject = $fr_sd_ap;} // if (isset($fr_sd_ap)){$headers = "From: " . $fr_email;} $mail_body = "From: " . $fr_email . "\n"; $mail_body .= "\nSource IP Address: " . $fr_s_ip ; $mail_body .= "\nDestination IP Address: " . $fr_d_ip . "\n"; $mail_body .= "\nSource Port: " . $fr_s_port ; $mail_body .= "\nDestinationPort: " . $fr_d_port . "\n"; $mail_body .= "\nProtocol: " . $fr_protocol . "\n"; $mail_body .= "\nSource Application: " . $fr_s_app ; $mail_body .= "\nDestination Application: " . $fr_d_app . "\n"; $mail_body .= "\nDescription/Reason: " . $fr_reason . "\n"; $header = header("Location: " . $page); } } return $error; return $mail_body; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" > <head> <title>Firewall Request Form</title> </head> <body> <h2>Firewall Request Form</h2> <form action="<?php submit();?>" method="POST"> <!-- This form is setup to allow the user to request changes to the firewall with requirements needed outlined in the form below. Fields needed are: Description, Source/Dest. port,Source/Dest. ip, Source/Dest. Application, Protocol (i.e. TCP, UDP, etc.), Username/Email --> <fieldset> <table width="800px"> <!-- IP ADDRESS--> <tr> <!-- This section has two parts that will be conjoined for Source and Destination IP address variables followed through to the message on the same row --> <!-- Source IP container--> <td valign="top" size="20%"> <label for="fr_s_ip" >Source IP Address: *</label> </td> <td valign="top"> <input type="text" id="fr_s_ip" maxlength="30" size="20" placeholder="i.e. Format: 0.0.0.0" value="<?php echo (isset($_POST['fr_s_ip'])) ? htmlentities($_POST["fr_s_ip"]) : ''; ?>"/> </td> <td> <span class="error" style="color:#FF0000"></span> </td> <!-- Source IP container--> <!-- Destination IP container--> <td valign="top" size="20%"> <label for="fr_d_ip" >Destination IP Address: *</label> </td> <td valign="top"> <input type="text" id="fr_d_ip" maxlength="30" size="20" placeholder="i.e. Format: 0.0.0.0" value="<?php if(isset($_POST['submit'])){echo (isset($_POST['fr_d_ip'])) ? htmlentities($_POST["fr_d_ip"]) : '';} ?>"/> </td> <td> <span class="error" style="color:#FF0000"></span> </td> <!-- Destination IP container--> </tr> <!--IP ADDRESS--> <!--PORTS--> <!-- Source Port container--> <tr> <td valign="top" size="20%"> <label for="fr_s_port">Source Port: *</label> </td> <td valign="top"> <input type="text" id="fr_s_port" maxlength="6" size="20" value="<?php echo (isset($_POST['fr_s_port'])) ? htmlentities($_POST["fr_s_port"]) : ''; ?>"/> </td> <td size="45%"> <span class="error" style="color:#FF0000"></span> </td> <!-- Source Port container--> <!-- Destination Port container--> <td valign="top" size="20%"> <label for="fr_d_port">Destination Port: *</label> </td> <td valign="top"> <input type="text" id="fr_d_port" maxlength="6" size="20" value="<?php echo (isset($_POST['fr_d_port'])) ? htmlentities($_POST["fr_d_port"]) : ''; ?>"/> </td> <td size="45%"> <span class="error" style="color:#FF0000"></span> </td> <!-- Destination Port container--> </tr> <!--PORTS--> <!--PROTOCOL--> <tr> <td valign="top" size="20%"> <label for="fr_protocol">Protocol: *</label> </td> <td valign="top"> <input type="text" id="fr_protocol" maxlength="20" size="20" value="<?php //echo (isset($_POST['fr_protocol'])) ? htmlentities($_POST["fr_protocol"]) : ''; ?>"/> </td> <td size="45%"> <span class="error" style="color:#FF0000"></span> </td> </tr> <!-- textbox for protocol end--> <!-- NOTE : WIP ******************************************************************* <tr> <td valign="top" size="20%"> <label for="fr_protocol">Protocol: *</label> </td> <td valign="top"> <select id="fr_protocol" > <option value="<?php //echo (isset($_POST['fr_protocol'])) ? htmlentities($_POST["fr_protocol"]) : ''; ?>" selected="Select" >Select<option/> <option value="<?php //echo (isset($_POST['submit'])) ? htmlentities($_POST["fr_protocol"]) : ''; ?>" >TCP<option/> <option value="<?php //echo (isset($_POST['fr_protocol'])) ? htmlentities($_POST["fr_protocol"]) : ''; ?>" >UDP<option/> <option value="<?php //echo (isset($_POST['fr_protocol'])) ? htmlentities($_POST["fr_protocol"]) : ''; ?>" >TCP/UDP<option/> <option value="<?php //echo (isset($_POST['fr_protocol'])) ? htmlentities($_POST["fr_protocol"]) : ''; ?>" >FTP<option/> <option value="<?php //echo (isset($_POST['fr_protocol'])) ? htmlentities($_POST["fr_protocol"]) : ''; ?>" >None<option/> <option onchange="showtextbox()" value="other" id="fr_protocol_other" >Other<option/> <select/> <input type="text" id="fr_protocol_otherfld" maxlength="4" size="9" style="display:none;" /> <script type="text/javascript" > function showtextbox(){ if (document.getElementById("fr_protocol_other").value === "other") { document.getElementById("fr_protocol_otherfld").style.display ="block"; } else { document.getElementById("fr_protocol_otherfld").style.display ="none'; } } </script> NOTE : WIP ******************************************************************* --> </td> <td size="45%"> <span class="error" style="color:#FF0000"></span> </td> </tr> <!--PROTOCOL--> <!--APPLICATION--> <!-- i.e. Source: Dealer \ Dest.: MDS --> <tr> <!-- Source App container--> <td valign="top" size="20%"> <label for="fr_s_app">Source Application: *</label> </td> <td valign="top"> <input type="text" id="fr_s_app" maxlength="30" size="20" placeholder="i.e. Dealer" value="<?php echo (isset($_POST['fr_s_app'])) ? htmlentities($_POST["fr_s_app"]) : ''; ?>"/> </td> <td size="45%"> <span class="error" style="color:#FF0000"></span> </td> <!-- Source App container--> <!-- Destination App container--> <td valign="top" size="20%"> <label for="fr_d_app">Destination Application: *</label> </td> <td valign="top"> <input type="text" id="fr_d_app" maxlength="30" size="20" placeholder="i.e. MDS" value="<?php echo (isset($_POST['fr_d_app'])) ? htmlentities($_POST["fr_d_app"]) : ''; ?>"/> </td> <td size="45%"> <span class="error" style="color:#FF0000"></span> </td> <!-- Destination App container--> </tr> <!--APPLICATION--> <!--DESCRIPTION/REASON--> <!-- NOTE: in the <textarea></textarea> tags there can be no line breaks or white space or refreshing the page or hitting the submit button will insert that into the text area and not produce a proper error message. --> <tr> <td valign="top" size="20%"> <label for="fr_reason">Description/Reason: *</label> </td> <td valign="top"> <textarea id="fr_reason" maxlength="1000" col="20" rows="8" placeholder="Describe the scenario..."><?php echo (isset($_POST['fr_reason'])) ? htmlentities($_POST["fr_reason"]) : ''; ?></textarea> </td> <td size="45%"> <span class="error" style="color:#FF0000"></span> </td> </tr> <!--DESCRIPTION/REASON--> <!--USERNAME/EMAIL--> <tr> <td valign="top" size="20%"> <label for="fr_email">Username/Email: *</label> </td> <td valign="top"> <input type="text" id="fr_email" maxlength="30" size="20" placeholder="test@otcmarkets.com" value="<?php echo (isset($_POST['fr_email'])) ? htmlentities($_POST["fr_email"]) : ''; ?>"/> </td> <td size="45%"> <span class="error" style="color:#FF0000"></span> </td> </tr> <!--USERNAME/EMAIL--> </table> </fieldset> <br /> <input type="submit" value="Email Firewall Request" id="submit" onsubmit="<?php $post = $_POST['submit']; submit(); mailset(); ?>" /> <input type="reset" value="Clear Form" id="reset"/> <br /><br /> <?php echo "\nToday is: $date"; ?> <br /> <br /> <tr> <td valign="top"> </td> </tr> </form> <br/> <?php //if the fields are empty prompt the user with "[All fields required]" if (empty($fr_s_ip) && empty($fr_d_ip) && empty($fr_s_port) && empty($fr_d_port) && empty($fr_protocol) && empty($fr_s_app) && empty($fr_d_app) && empty($fr_reason) && empty($fr_email)){ $fieldsrequired = '<strong><b><font style="color:#FF0000">All the fields with \'*\' are required.</font></b></strong><br />'; echo $fieldsrequired; } // if the error variable is not empty loop through the errors and display them if (!empty($error)){ foreach($error as $errorsoutput){ //html formatting plus the error message using the '.' (period symbol) echo $errorsoutput.'<br>'; } } if(!empty($error)){ if (isset($_POST['submit'])){//if mail() returns 1 or true print $success variable //mail function @mail($email_to,$subject,$mail_body); //produce success message //$success = '<i><u>Status: Your firewall request form has been submitted.</u></i>'; //echo $success; } } ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
codelinx Posted July 29, 2013 Author Share Posted July 29, 2013 never got this working as of yet.... this has been scrapped because of other dependencies i cannot load on the server Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.