Jump to content

Probably something simple - as usual!


Bifter

Recommended Posts

Hi All,

 

I have created a quoting tool which outputs to browser fine, the upon clicking a button should email the script; and it does however any fuction with an IF statement(AnaLineTotal () ) emails "Not Required" which is the 1st step in the IF statement and will not go past this, whereas all other fuctions(MainUnit () ) email the output just fine...would be grateful if a fresh pair of eye could cast a look over it:

 

Inputs:

<?php
$AnalogueExt = $_POST['AnalogueExt'];
?>

 

Arrays:

<?php
/* Main Unit */
$MainUnit = array(
   array('Unit' => 'Avaya', 'Price' => '406'),
                array('Unit' => 'Cisco', 'Price' => '1500'),
                array('Unit' => 'Samsung', 'Price' => '995')
                );

/* Line Cards */
$LineCard = array(
                array('Card' => 'Analogue Card/s', 'Price' => '232'),
                array('Card' => 'ISDN2e Card/s', 'Price' => '275'),
                array('Card' => 'ISDN30e Card/s', 'Price' => '530'),
			array('Card' => 'Cisco ISDN2e Card/s', 'Price' => '200'),
                array('Card' => 'Cisco ISDN30e Card/s', 'Price' => '600'),
			array('Card' => 'Samsung Analogue Card/s', 'Price' => '345'),
			array('Card' => 'Samsung ISDN2e Card/s', 'Price' => '395'),
                array('Card' => 'Samsund ISDN30e Card/s', 'Price' => '530')
                );
?>

 

 

Functions:

<?php
/* Main Unit */
function MainUnit ($MainUnit) {
global $MainUnit;
return $MainUnit['0']['Price'] . "<br>";
}

/* Analogue Card */
function AnaLineTotal ($LineCard,$LinesAnalogue) {
global $LinesAnalogue;
global $LineCard;
if ($LinesAnalogue <= 0 ) {
   return "Not Required" . "<br>";
   }
elseif ($LinesAnalogue <= 5 ) {
   return $LineCard['0']['Price'] . "<br>";
   }
elseif ($LinesAnalogue <= 8 ) {
   return $LineCard['0']['Price'] * 2 . "<br>";
   }
elseif ($LinesAnalogue <= 12 ) {
   return $LineCard['0']['Price'] * 3 . "<br>";
   }
elseif ($LinesAnalogue >= 13 ) {
   return "Please Call" . "<br>";
   }
}
?>

 

Html Output:

<?php
function html () { 
return "<html>
<body>
<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
  <tr>
    <td width=\"33%\"><table width=\"99%\" align=\"left\" cellpadding=5 class=bordered>
<tr>
<th colspan=4><img src=\"http://www.flipsolutions.co.uk/images/quoting/avaya.png\" width=\"120\" height=\"49\"></th></tr>
      <tr>
        <th width=\"34%\"><div align=\"center\"><strong>Part </strong></div></th>
        <th width=\"18%\"><div align=\"center\"><strong>Unit Price </strong></div></th>
        <th width=\"24%\"><div align=\"center\"><strong>No. Required </strong></div></th>
        <th width=\"24%\"><div align=\"center\"><strong>Line Total </strong></div></th>
      </tr>
<tr>
        <td><div align=\"center\">Main Unit </div></td>
        <td><div align=\"center\">£406.00</div></td>
        <td><div align=\"center\">1</div></td>
        <td><div align=\"center\">£". MainUnit () ."</div></td>
      </tr>
      <tr>
        <td><div align=\"center\">Analogue Card </div></td>
        <td><div align=\"center\">£232.00</div></td>
        <td><div align=\"center\">". AnaNumReq () ."</div></td>
        <td><div align=\"center\">£". AnaLineTotal () ."</div></td>
      </tr>
      <tr>
</table>
</body> 
</html>";
}
echo html ();
?>

 

Email script:

<?phprequire('process-new.php');
//define the receiver of the email
$to = $_POST['Email'];
//define the subject of the email
$subject = 'Online Quote from Flip Solutions'; 
//create a boundary string. It must be unique 
//so we use the MD5 algorithm to generate a random hash
$random_hash = md5(date('r', time())); 
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: [email protected]\r\nReply-To: [email protected]";
//add boundary string and mime type specification
$headers .= "\r\nContent-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\""; 
//define the body of the message.

?>
--PHP-alt-<?php echo $random_hash; ?>  
Content-Type: text/plain; charset="iso-8859-1" 
Content-Transfer-Encoding: 7bit

This email requires HTML to be turned on, please enable this and resend the email! 

--PHP-alt-<?php echo $random_hash; ?>  
Content-Type: text/html; charset="iso-8859-1" 
Content-Transfer-Encoding: 7bit

<?php echo html($LineCard,$ExtCard); ?>

--PHP-alt-<?php echo $random_hash; ?>--
<?
//copy current buffer contents into $message variable and delete current output buffer
$message = ob_get_clean();
//send the email
$mail_sent = @mail( $to, $subject, $message, $headers );
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed" 
echo $mail_sent ? "Mail sent" : "Mail failed";
?>
[code]

I have trimmed down some of the code - but all the important bits remain - I hope....

[/code]

Link to comment
https://forums.phpfreaks.com/topic/113891-probably-something-simple-as-usual/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.