Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - fruitfly

Pages: [1]
1
General PHP Help / Ugly Code
« on: February 07, 2012, 07:11:16 AM »
Good day, i recently got put incharge of a website for a friend. The contact forms on quote and repair both hang and try redirect the user after submitting the form. the re submit times out. Could you take a look at the code and see where this is being done, a simple echo "message sent" would be fine. Not sure where the original coder put this redirect command. http://www.pool-companies.co.za/contact/free-quote.php, please see the php below

PHP Code: [Select]
<? 

if($_POST['task'] == 'Submit'){ 

	
//proccess form
	
$to1 'info@pool-companies.co.za';
	

	

	
	
//if($_SESSION['validSession'] == 1 || $_SESSION['validSession'] == true){
	
	
  
$subject "All Pools - Request a Quote";
	
	
//}else{
	
	
//  $subject = "Water Boys - Request a Quote - AUTOMATED [SPAM]";
	
	
//}

	
  if (
strtoupper(substr(PHP_OS,0,3)=='WIN')) { 
	
	
$eol="\r\n"
	
  } elseif (
strtoupper(substr(PHP_OS,0,3)=='MAC')) { 
	
	
$eol="\r"
	
  } else { 
	
	
$eol="\n"
	
  }
	
  
	
$body='<html><head><style>body{font-family:verdana,arial,tahoma;font-size:12px;}</style></head><body>'.chr(13);
	
$body.='<table width="480" cellpadding="2" cellspacing="0" border="0">'.chr(13); 
	
$body.='  <tr>'.chr(13); 
	
$body.='    <td valign="top">Date:</td><td valign="top">'.date('Y-m-j H:i:s').'</td>'.chr(13); 
	
$body.='  </tr>'.chr(13);
	

	
foreach(
$_POST as $key_name => $key_value) {
	

	
	
if(
$key_value!='' && $key_name!='task' && $key_name!='x' && $key_name!='y'){
	
	
	
$body.='<tr><td>'.str_replace('chb','',str_replace('chk','',str_replace('rbl','',str_replace('txt','',$key_name)))) . ':&nbsp;</td><td>' $key_value .'</td></tr>';
	
	
}
	

	
}
	

	
$body.='</table>'.chr(13); 
	
$body.='</body></html>'.chr(13); 
	

	
$headers 'From: All Pools <info@pool-companies.co.za>'.$eol.
	
	
	
   
'Reply-To: All Pools <info@pool-companies.co.za>'.$eol.
	
	
	
	
   
	
	
	
   
'MIME-Version: 1.0'.$eol.
	
	
	
   
'Content-type: text/html; charset=iso-8859-1';

	
	
	
$okmail($to1$subject$body$headers);
	
	
	
$okmail($to2$subject$body$headers);
	
	
	
$okmail($to3$subject$body$headers);
	
	
	
//$ok= mail($to4, $subject, $body, $headers);
	
	
	
//$ok= mail($to5, $subject, $body, $headers);
	
	
	
if (
$ok){
	
	
	
$mess="been sent";
	
	
	
}else{
	
	
	
$mess="not been sent";
	
	
	
}
	
	
	

	
	
	

	
	
	

	
	
 
// Write request to html file
	
	
	
$FileName date('Y_m_j_H_i_s').".html";
	
	
	
$FileHandle fopen("../requests/".$FileName'w') or die("can't open file");
	
	
	
fwrite($FileHandle$body);
	
	
	
fclose($FileHandle);

	
	
	
Header("Location: /contact/");

}else{

	
	
	
Header("Location: /contact/?err=not+submitted");

}

?>

2
General PHP Help / Re: Contact Form not processing all fields
« on: February 07, 2012, 02:22:01 AM »
Thnks for the quick reply,
Changed the php code still only processing through the message,email and name..

3
General PHP Help / Contact Form not processing all fields
« on: February 06, 2012, 04:00:35 AM »
Good day,

My site www.supernet.co.za/contact.html
The contact form there sends through the name email and message but nothing else. if i add in a field for "number" the form does not process it still asks for required field. I have basic php knowledge could some1 please give me a hand. I would like the form to process name email tel message and company. If i add the desired fields into the php doc it does not process the form at all.

Please see form data and php data below.

Thanks in advance !!


Code: [Select]
<form action="contact.php" method="post" id="contactform">
          <ol>
            <li>
              <label for="name">First Name <span class="red">*</span></label>
              <input id="name" name="name" class="text" />
            </li>
            <li>
              <label for="email">Your email <span class="red">*</span></label>
              <input id="email" name="email" class="text" />
            </li>
            <li>
              <label for="number">Number</label>
              <input id="number" name="number" class="text" />
            </li>
            <li>
              <label for="subject">Subject</label>
              <input id="subject" name="subject" class="text" />
            </li>
            <li>
              <label for="message">Message <span class="red">*</span></label>
              <textarea id="message" name="message" rows="6" cols="50"></textarea>
            </li>
            <li class="buttons">
              <input type="image" name="imageField" id="imageField" src="images/send.gif" />
            </li>
          </ol>
        </form>



PHP Code: [Select]
<?php

if(!$_POST) exit;

$email $_POST['email'];


//$error[] = preg_match('/\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i', $_POST['email']) ? '' : 'INVALID EMAIL ADDRESS';
if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email )){
	
$error.="Invalid email address entered";
	
$errors=1;
}
if(
$errors==1) echo $error;
else{
	
$values = array ('name','email','message');
	
$required = array('name','email','message','number');
	
 
	
$your_email "brad@supernet.co.za";
	
$email_subject "New Message: ".$_POST['subject'];
	
$email_content "new message:\n";
	

	
foreach(
$values as $key => $value){
	
  if(
in_array($value,$required)){
	
	
if (
$key != 'subject' && $key != 'number') {
	
	
  if( empty(
$_POST[$value]) ) { echo 'PLEASE FILL IN REQUIRED FIELDS'; exit; }
	
	
}
	
	
$email_content .= $value.': '.$_POST[$value]."\n";
	
  }
	
}
	
 
	
if(@
mail($your_email,$email_subject,$email_content)) {
	
	
echo 
'Message sent!'
	
} else {
	
	
echo 
'ERROR!';
	
}
}
?>

Pages: [1]