473,387 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

PHP Problem

hi
im doing an html project for college and im having a bit of trouble adding a sumed total to a php file....
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3.     echo " Surname ". $_POST["lastname"].
  4.     "<br><br/>";
  5.     echo " First name ". $_POST["firstname"].
  6.     "<br><br/>";
  7.     echo " Address ". $_POST["address"].
  8.     "<br><br/>";
  9.     echo " City/Town ". $_POST["city"].
  10.     "<br><br/>";
  11.     echo " County ". $_POST["county"].
  12.     "<br><br/>";
  13.     echo " Country ". $_POST["country"].
  14.     "<br><br/>";
  15.     echo " Email address ". $_POST["email"].
  16.     "<br><br/>";    
  17.     echo " Subtotal". $_POST["excvat"].
  18.     "<br><br/>";    
  19.     echo " Total ". $_POST["incvat"].
  20.     "<br><br/>";    
  21.  
  22. ?>
  23.  
I think im gone wrong somewhere here.. Everything is working grand except for the sub-total and total..
Mar 5 '08 #1
17 1681
hsriat
1,654 Expert 1GB
What is the problem with the code?
Mar 5 '08 #2
What is the problem with the code?
The totals dont come up on the PHP page and it comes up what is wrong on the page but it is in huge black latters like size 40
Mar 5 '08 #3
Markus
6,050 Expert 4TB
What is the page you use to submit the values?
Mar 5 '08 #4
What is the page you use to submit the values?
There on the php page, I dont have any cookies put in. Im not sure if it matters because the rest of the values work fine without it.
Mar 5 '08 #5
hsriat
1,654 Expert 1GB
There on the php page, I dont have any cookies put in. Im not sure if it matters because the rest of the values work fine without it.
cookies have nothing to do it....

Show your html file which is posting your variables?
Mar 5 '08 #6
cookies have nothing to do it....

Show your html file which is posting your variables?
[php]
<!DOCTYPE html PUBLIC
<html>
<head>
<link rel="stylesheet"
type="text/css" href="style.css" />
<style>
#content{
width:55%;
}
</style>
<script type="text/javascript">
function calculate()
{
//declare the variables at local level
var K700;
var TKdeco;
var K14;
var Sanaton;
var Consultancy;
var Support;
var Content;
var Telephone;
var Website;
//Examine the option buttons and assign the
//appropriate values to the local variables
if(document.feedbackfrm.K700.checked==true)
{varK700=document.feedbackfrm.K700.value}
else {varK700=0};
if(document.feedbackfrm.TKdeco.checked==true)
{varTKdeco=document.feedbackfrm.TKdeco.value}
else {varTKdeco=0};
if(document.feedbackfrm.K14.checked==true)
{varK14=document.feedbackfrm.K14.value}
else {varK14=0};
if(document.feedbackfrm.Sanaton.checked==true)
{varSanaton=document.feedbackfrm.Sanaton.value}
else {varSanaton=0};
if(document.feedbackfrm.Website.checked==true)
{varWebsite=document.feedbackfrm.Website.value}
else {varWebsite=0};
if(document.feedbackfrm.Telephone.checked==true)
{varTelephone=document.feedbackfrm.Telephone.value }
else {varTelephone=0};
if (document.feedbackfrm.Content[0].checked==true)
{varContent=document.feedbackfrm.Content[0].value}
else {varContent=document.feedbackfrm.Content[1].value};
if(document.feedbackfrm.Support.checked==true)
{varSupport=document.feedbackfrm.Support.value}
else {varSupport=0};
//Convert the variables to numeric values using the parseInt function
varK700=parseInt(varK700);
varTKdeco=parseInt(varTKdeco);
varK14=parseInt(varK14);
varSanaton=parseInt(varSanaton);
varSupport=parseInt(varSupport);
varContent=parseInt(varContent);
varTelephone=parseInt(varTelephone);
varWebsite=parseInt(varWebsite);
//add the variables to get the total price
total = varK700 + varTKdeco + varK14 + varSanaton + varSupport + varContent + varTelephone + varWebsite;
vat = total * 1.21;
//Create an alert box to display the cost
alert("The total cost of your purchase is €" + Math.round(total) +
"exclusive of vat. Including VAT your purchase price is €" + Math.round(vat));
document.feedbackfrm.excvat.value = total;
document.feedbackfrm.incvat.value = vat;
}
</script>[/php]

Enclose any code within the proper code tags. See the Posting Guidelines on how to do that. - moderator
Mar 5 '08 #7
hsriat
1,654 Expert 1GB
I can't see the form tag!
Mar 5 '08 #8
I can't see the form tag!
</script>

</head>

<body>

<div id="link">

<h2><a href="http://www.bebo.com">Bebo</a>

<a href="http://www.yahoo.com">Yahoo</a>

<a href="http://www.msn.com">MSN</a>

<a href="http://www.youtube.com">You Tube</a>

<a href="http://www.ask.com">ASK</a><h2/>

</div>

<div id="navpanel">

<h2>
<a href="index.html">Home</a>
<hr>

<a href="cv.html">CV</a>
<hr>

<a href="interests.html">Interests</a>
<hr>

<a href="company.html">Company</a>
<hr>

<a href="about.html">About Us</a>
<hr>

<a href="Expertise.html">Our Expertise</a>
<hr>

<a href="UsefulLinks.html">Useful Links</a>
<hr>

<a href="ebusiness.html">Ebusiness</a>
<h2 />

</div>

<div id= "content">




<br />
<br />
<br />
<form name="feedbackfrm" action="http://corvus2.ucc.ie/BScI07/SWalsh/Scripts/Confirmation.php" method="POST" >
<table align =" center" border =" 1" width =100% ><!--Creates table to hold buttons-->

<tr>
<td colspan="3"><h6>Horizon Laptops<h6 /></td>

<tr>
<td><input type = "checkbox" name = "K700" value = "1200">Horizon K700</td>
<td>€1200</td>
<td ><input type="button" value="More Info" onclick="window.open('K700.html')"></td>

<tr>
<td><input type = "checkbox" name = "TKdeco" value = "1350">Horizon TKdeco</td>
<td>€1350</td>
<td><input type="button" value="More Info" onclick="window.open('TKdeco.html')"></td>

<tr>
<td><input type = "checkbox" name = "K14" value = "800">Horizon K14</td>
<td>€800</td>
<td><input type="button" value="More Info" onclick="window.open('K14.html')"></td>

<tr>
<td><input type = "checkbox" name = "Sanaton" value = "1100">Horizon Sanaton</td>
<td>€1100</td>
<td><input type="button" value="More Info" onclick="window.open('Sanaton.html')"></td>

<tr>
<td colspan="3"><h6>Our Technology Services<h6 /></td>

<tr>

<td colspan="2"><input type = "radio" name = "Content" value = "2000">Content Management System</td>
<td>€2000</td>

<tr>

<td colspan="2"><input type = "radio" name = "Content" value = "1500">Flash Anamation & Multimedia</td>
<td>€1500</td>

<tr>

<td rowspan="2">Consultancy</td>
<td><input type="checkbox" name="Telephone" value="100">Telephone</td>
<td>€100</td>
<tr>

<td><input type="checkbox" name="Website" value="200">Website</td>
<td>€200</td>

<tr>

<td colspan="2"><input type = "checkbox" name = "Support" value = "25">Web Support</td>
<td>€25</td>

<tr>

<td colspan="2">Total Price exc. VAT</td>
<td><input type ="text" name="excvat" value=""></td>

<tr>
<td colspan="2">Total Price inc. VAT</td>
<td><input type ="text" name="incvat" value=""></td>

</table>

<input type = "button" name = "Calculate" value ="Calculate cost" onclick =" calculate();">

<input type = "reset" name = "reset" value ="Clear Current Selections" onclick ="Reset();">

<input type="button" value="Add to shopping cart" onclick="window.open('CustomerDetails.php')">

</form>

</div>



<div id="banner">

<h1><div style="font-family:Algerian;margin:0px auto;width:500px;color:yellow;filter:shadow;">Ebus iness<h1 />

</div>

</body>

</html>
Mar 5 '08 #9
hsriat
1,654 Expert 1GB
Why are you posting it in installments and that too without code tags?

Add [html] and [/html] before and after your code.
Mar 5 '08 #10
Why are you posting it in installments and that too without code tags?

Add [html] and [/html] before and after your code.
its not in instalments. html tags are in.
Mar 5 '08 #11
hsriat
1,654 Expert 1GB
There is no submit button!

Which button do you click to get the result?
Mar 5 '08 #12
There is no submit button!

Which button do you click to get the result?
Add to shopping cart button
Mar 5 '08 #13
hsriat
1,654 Expert 1GB
Add to shopping cart button
It should be [html]<input type="submit" name="submit" value="Add to shopping cart" />[/html]

And add action="CustomerDetails.php" to the form tag.

Have a look at how it works
Mar 5 '08 #14
It should be [html]<input type="submit" name="submit" value="Add to shopping cart" />[/html]

And add action="CustomerDetails.php" to the form tag.

Have a look at how it works
That doesent work but this is what is coming up on my php page originally in huge writing.

PHP Notice: Use of undefined constant excvat - assumed 'excvat' in c:\Inetpub\wwwroot\BScI07\SWalsh\Scripts\Confirmat ion.php on line 103 PHP Notice: Undefined index: excvat in c:\Inetpub\wwwroot\BScI07\SWalsh\Scripts\Confirmat ion.php on line 103 PHP Notice: Use of undefined constant incvat - assumed 'incvat' in c:\Inetpub\wwwroot\BScI07\SWalsh\Scripts\Confirmat ion.php on line 105 PHP Notice: Undefined index: incvat in c:\Inetpub\wwwroot\BScI07\SWalsh\Scripts\Confirmat ion.php on line 105
Mar 5 '08 #15
hsriat
1,654 Expert 1GB
Comment the whole code in confirmation.php temporarily and add this:[php]<?php
echo "<pre>";
print_r($_POST);
echo "</pre>";
?>[/php]This will tell you about all the variables being posted. Use them accordingly.
Mar 5 '08 #16
Comment the whole code in confirmation.php temporarily and add this:[php]<?php
echo "<pre>";
print_r($_POST);
echo "</pre>";
?>[/php]This will tell you about all the variables being posted. Use them accordingly.
No luck yet, il get back to you tomorrow evening if I cant fix it. Thanks...
Mar 5 '08 #17
hsriat
1,654 Expert 1GB
No luck yet, il get back to you tomorrow evening if I cant fix it. Thanks...
Yeah that will be better. It's 2:30AM here. I can't even think about the problem now.

Check out this tutorial. This may help you.

Harpreet
Mar 5 '08 #18

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Kostatus | last post by:
I have a virtual function in a base class, which is then overwritten by a function of the same name in a publically derived class. When I call the function using a pointer to the derived class...
117
by: Peter Olcott | last post by:
www.halting-problem.com
18
by: Ian Stanley | last post by:
Hi, Continuing my strcat segmentation fault posting- I have a problem which occurs when appending two sting literals using strcat. I have tried to fix it by writing my own function that does the...
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
6
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
0
by: =?Utf-8?B?am8uZWw=?= | last post by:
Hello All, I am developing an Input Methop (IM) for PocketPC / Windows Mobile (PPC/WM). On some devices the IM will not start. The IM appears in the IM-List but when it is selected from the...
1
by: sherifbk | last post by:
Problem description ============== - I have 4 clients and 1 server (SQL server) - 3 clients are Monitoring console 1 client is operation console - Monitoring console collects some data from...
9
by: AceKnocks | last post by:
I am working on a framework design problem in which I have to design a C++ based framework capable of solving three puzzles for now but actually it should work with a general puzzle of any kind and I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.