Jump to content

No-Refresh Help


Skittalz

Recommended Posts

I am creating a script that has the user input various values and then upon being submitted... The script does not refresh but displays the total. Can someone help me out? I've spent the last hour trying how to do it but I can't figure out what I'm doing wrong. Here's my code... Can someone help me out?

 

<?php 


include 'quote_functions.php';

if(isset($_POST['Calculate'])) {
  if(numeric($_POST['width'])) {
    $price = $_POST['width']*$_POST['height'];
    if($_POST['bannertype'] == '1') {
$price = $price * 3; }
    else if($_POST['bannertype'] == '2') {
$price = $price * 2.5;
    }
    $price = number_format($price,2);

  } else {
    
  }
  
}

?>

<html><head></head><body><div align='center'> 

<form method="post" action="204.php"> 
<table align='center' width='600' bordercolor='#000000' bordercolor='#222222' bordercolorlight='#102444' border=1>
  <tr>
    <td background='cellbg.jpg' align='center'><font color='#171F2D'><b>-=| Online Quotation |=-</b></font></td></tr>
  <tr>
    <td>
<table width=598 border=1>
  <tr>
    <td width=20%><div align='center'>Banner Type: <br>
	<select name="bannertype">
	  <option value="2">Simple Text Banner</option>
	  <option value="1">Full Color Banner</option>
	</select></div>
    </td>
    <td width=20%><div align='center'>Height: <br>
	<select name="height">
	  <option value="1">1</option>
	  <option value="2">2</option>
	  <option value="3">3</option>
	  <option value="4">4</option>
	  <option value="5">5</option>
	  <option value="6">6</option>
	  <option value="7">7</option>
	  <option value="8">8</option>
	</select> inch(es).</div>
    </td>
    <td width=20%><div align='center'>Width: <br>
	<input type="text" name="width" size="3" value="" /> inch(es).</div>
    </td>
  </tr>
  <tr>
    <td width=20%><div align='center'><b>Total</b>: $ <?php if(isset($price)) { echo $price; } else { echo "0.00"; }?>
	</div>
    </td>
    <td></td>

<td>
<input type="submit" name="Calculate" value="Calculate" />	<input type="submit" name="Order" value="Order" />
	</td></tr></table>
</table><br />

Link to comment
https://forums.phpfreaks.com/topic/90835-no-refresh-help/
Share on other sites

this is what it does.

 

 

$val = "";

 

empty($val) would return true - so the statement is saying if its not empty.

 

then if i go if(isset($val)), it checks to see if there  is a variable called $val, therefore returning true.

 

basically its changing to testing if the variabel is set - to if it is empty

Link to comment
https://forums.phpfreaks.com/topic/90835-no-refresh-help/#findComment-465610
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.