PHP Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Grenagh
    New Member
    • Mar 2008
    • 9

    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....
    [code=php]
    <?php

    echo " Surname ". $_POST["lastname"].
    "<br><br/>";
    echo " First name ". $_POST["firstname"].
    "<br><br/>";
    echo " Address ". $_POST["address"].
    "<br><br/>";
    echo " City/Town ". $_POST["city"].
    "<br><br/>";
    echo " County ". $_POST["county"].
    "<br><br/>";
    echo " Country ". $_POST["country"].
    "<br><br/>";
    echo " Email address ". $_POST["email"].
    "<br><br/>";
    echo " Subtotal". $_POST["excvat"].
    "<br><br/>";
    echo " Total ". $_POST["incvat"].
    "<br><br/>";

    ?>
    [/code]

    I think im gone wrong somewhere here.. Everything is working grand except for the sub-total and total..
    Last edited by Atli; Mar 5 '08, 10:50 PM. Reason: Added [code] tags.
  • hsriat
    Recognized Expert Top Contributor
    • Jan 2008
    • 1653

    #2
    What is the problem with the code?

    Comment

    • Grenagh
      New Member
      • Mar 2008
      • 9

      #3
      Originally posted by hsriat
      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

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        What is the page you use to submit the values?

        Comment

        • Grenagh
          New Member
          • Mar 2008
          • 9

          #5
          Originally posted by markusn00b
          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.

          Comment

          • hsriat
            Recognized Expert Top Contributor
            • Jan 2008
            • 1653

            #6
            Originally posted by Grenagh
            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?

            Comment

            • Grenagh
              New Member
              • Mar 2008
              • 9

              #7
              Originally posted by hsriat
              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.fee dbackfrm.K700.c hecked==true)
              {varK700=docume nt.feedbackfrm. K700.value}
              else {varK700=0};
              if(document.fee dbackfrm.TKdeco .checked==true)
              {varTKdeco=docu ment.feedbackfr m.TKdeco.value}
              else {varTKdeco=0};
              if(document.fee dbackfrm.K14.ch ecked==true)
              {varK14=documen t.feedbackfrm.K 14.value}
              else {varK14=0};
              if(document.fee dbackfrm.Sanato n.checked==true )
              {varSanaton=doc ument.feedbackf rm.Sanaton.valu e}
              else {varSanaton=0};
              if(document.fee dbackfrm.Websit e.checked==true )
              {varWebsite=doc ument.feedbackf rm.Website.valu e}
              else {varWebsite=0};
              if(document.fee dbackfrm.Teleph one.checked==tr ue)
              {varTelephone=d ocument.feedbac kfrm.Telephone. value}
              else {varTelephone=0 };
              if (document.feedb ackfrm.Content[0].checked==true)
              {varContent=doc ument.feedbackf rm.Content[0].value}
              else {varContent=doc ument.feedbackf rm.Content[1].value};
              if(document.fee dbackfrm.Suppor t.checked==true )
              {varSupport=doc ument.feedbackf rm.Support.valu e}
              else {varSupport=0};
              //Convert the variables to numeric values using the parseInt function
              varK700=parseIn t(varK700);
              varTKdeco=parse Int(varTKdeco);
              varK14=parseInt (varK14);
              varSanaton=pars eInt(varSanaton );
              varSupport=pars eInt(varSupport );
              varContent=pars eInt(varContent );
              varTelephone=pa rseInt(varTelep hone);
              varWebsite=pars eInt(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(tota l) +
              "exclusive of vat. Including VAT your purchase price is €" + Math.round(vat) );
              document.feedba ckfrm.excvat.va lue = total;
              document.feedba ckfrm.incvat.va lue = vat;
              }
              </script>[/php]

              Enclose any code within the proper code tags. See the Posting Guidelines on how to do that. - moderator
              Last edited by ronverdonk; Mar 5 '08, 07:31 PM. Reason: warning: code within tags!

              Comment

              • hsriat
                Recognized Expert Top Contributor
                • Jan 2008
                • 1653

                #8
                I can't see the form tag!

                Comment

                • Grenagh
                  New Member
                  • Mar 2008
                  • 9

                  #9
                  Originally posted by hsriat
                  I can't see the form tag!
                  </script>

                  </head>

                  <body>

                  <div id="link">

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

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

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

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

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

                  </div>

                  <div id="navpanel">

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

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

                  <a href="interests .html">Interest s</a>
                  <hr>

                  <a href="company.h tml">Company</a>
                  <hr>

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

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

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

                  <a href="ebusiness .html">Ebusines s</a>
                  <h2 />

                  </div>

                  <div id= "content">




                  <br />
                  <br />
                  <br />
                  <form name="feedbackf rm" action="http://corvus2.ucc.ie/BScI07/SWalsh/Scripts/Confirmation.ph p" 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">Hori zon K700</td>
                  <td>€1200</td>
                  <td ><input type="button" value="More Info" onclick="window .open('K700.htm l')"></td>

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

                  <tr>
                  <td><input type = "checkbox" name = "K14" value = "800">Horiz on 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">Hori zon 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"><in put type = "radio" name = "Content" value = "2000">Cont ent Management System</td>
                  <td>€2000</td>

                  <tr>

                  <td colspan="2"><in put type = "radio" name = "Content" value = "1500">Flas h Anamation & Multimedia</td>
                  <td>€1500</td>

                  <tr>

                  <td rowspan="2">Con sultancy</td>
                  <td><input type="checkbox" name="Telephone " value="100">Tel ephone</td>
                  <td>€100</td>
                  <tr>

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

                  <tr>

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

                  <tr>

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

                  <tr>
                  <td colspan="2">Tot al 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('Customer Details.php')">

                  </form>

                  </div>



                  <div id="banner">

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

                  </div>

                  </body>

                  </html>

                  Comment

                  • hsriat
                    Recognized Expert Top Contributor
                    • Jan 2008
                    • 1653

                    #10
                    Why are you posting it in installments and that too without code tags?

                    Add [html] and [/html] before and after your code.

                    Comment

                    • Grenagh
                      New Member
                      • Mar 2008
                      • 9

                      #11
                      Originally posted by hsriat
                      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.

                      Comment

                      • hsriat
                        Recognized Expert Top Contributor
                        • Jan 2008
                        • 1653

                        #12
                        There is no submit button!

                        Which button do you click to get the result?

                        Comment

                        • Grenagh
                          New Member
                          • Mar 2008
                          • 9

                          #13
                          Originally posted by hsriat
                          There is no submit button!

                          Which button do you click to get the result?
                          Add to shopping cart button

                          Comment

                          • hsriat
                            Recognized Expert Top Contributor
                            • Jan 2008
                            • 1653

                            #14
                            Originally posted by Grenagh
                            Add to shopping cart button
                            It should be [html]<input type="submit" name="submit" value="Add to shopping cart" />[/html]

                            And add action="Custome rDetails.php" to the form tag.

                            Have a look at how it works

                            Comment

                            • Grenagh
                              New Member
                              • Mar 2008
                              • 9

                              #15
                              Originally posted by hsriat
                              It should be [html]<input type="submit" name="submit" value="Add to shopping cart" />[/html]

                              And add action="Custome rDetails.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\wwwr oot\BScI07\SWal sh\Scripts\Conf irmation.php on line 103 PHP Notice: Undefined index: excvat in c:\Inetpub\wwwr oot\BScI07\SWal sh\Scripts\Conf irmation.php on line 103 PHP Notice: Use of undefined constant incvat - assumed 'incvat' in c:\Inetpub\wwwr oot\BScI07\SWal sh\Scripts\Conf irmation.php on line 105 PHP Notice: Undefined index: incvat in c:\Inetpub\wwwr oot\BScI07\SWal sh\Scripts\Conf irmation.php on line 105

                              Comment

                              Working...