Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Mar 2013
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Adding PHP code into HTML script

    I am building a website for a business and I have all of the code written for the website (in HTML) and all the code for the shopping cart (in PHP). I was just wondering if any one could tell me where I would put the shopping PHP within the HTML.

  • #2
    Regular Coder patryk's Avatar
    Join Date
    Oct 2012
    Location
    /dev/couch
    Posts
    398
    Thanks
    2
    Thanked 64 Times in 64 Posts
    you change your file's suffix from .html to .php and you put your php code between <?php and ?>

    but honestly... if you have to ask that question then you probably should find someone to implement stuff like that for you...

    i would suggest learning on projects not involving money

  • #3
    New to the CF scene
    Join Date
    Mar 2013
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    you completely missed the point, i understand that, i know what I am doing, I was asking where in the code would I put the shopping cart, you know, like beginning, middle, end,between certain things, or what?

  • #4
    Regular Coder patryk's Avatar
    Join Date
    Oct 2012
    Location
    /dev/couch
    Posts
    398
    Thanks
    2
    Thanked 64 Times in 64 Posts
    in that case it all depends on your site's design. traditionally one puts 'add to cart' button with quantity input right next to product description / image and somewhere on top of document you would find a link to cart's contents list
    (that's if you are asking about usability and some logical layout)

  • #5
    Banned
    Join Date
    Mar 2013
    Posts
    139
    Thanks
    0
    Thanked 9 Times in 9 Posts
    I see you have a duplicate thread on this topic, but anyway here is what I said in your other thread

    Where you have your shopping cart php code also depends on how the php code is constructed. Personally I would suggest setting up your cart code as a php object which can be kept completely separate from any html code. You then simply instantiate an instance of the shopping cart php class and send items to it from your web page.

    If you want to embed the cart php code into your web page code then how/where you do it depends on how you are getting the user to add an item to their cart. Post the html code prompting the user to add an item to their cart.

  • #6
    Banned
    Join Date
    Mar 2013
    Posts
    139
    Thanks
    0
    Thanked 9 Times in 9 Posts
    Quote Originally Posted by patryk View Post
    but honestly... if you have to ask that question then you probably should find someone to implement stuff like that for you...
    and I agree with patryk. I don't see how you could have written all the html and php and then not know how to "join" the two together.

    This is now sounding like you have got bits and pieces of code from various sources and are now trying to get someone to put them together for you

  • #7
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,281
    Thanks
    57
    Thanked 523 Times in 510 Posts
    Blog Entries
    5
    Quote Originally Posted by gavinshaw View Post
    you completely missed the point, i understand that, i know what I am doing, I was asking where in the code would I put the shopping cart, you know, like beginning, middle, end,between certain things, or what?
    Hang on.. you know what you're doing, you understand everything but you need to ask the question as to where to put your code?

    Honestly, you are not a programmer. You do not understand what you are doing and YOU have missed the point. If you knew what you were doing, you wouldn't need to ask.

    Seriously, do not continue with your project. If it involves processing payments and is written with nothing but basic code and snippets you've stitched together (just) you're asking for more trouble than you can handle.

    If you really believe you have half a clue what you're doing and you have to ask others where to put your php code, the hackers (who actually do really know what they're doing) are going to rip your site to bits.

    Also do not even think about storing peoples credit card details in your database. There are very strict financial laws about credit card processing and the storage of data and all sorts of approvals you will need from various financial institutions before you are legally permitted to do so. Sites like paypal and amazon pour $millions into hiring the very best programmers and security experts they can to keep their customers details safe. There is no way you can match their level of expertise or meet the same legal requirements that they have. You can use a payment gateway via an API (paypal, worldpay, 2checkout etc) but you cannot store card details yourself.

    Seriously, if you are asking what to do with / where to put your php in your html, you are not skilled enough to be running an ecommerce site. I've been a php programmer for several years and I wouldn't do it myself.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •