Jump to content


Photo

Embedding hidden PHP in Static html page


  • Please log in to reply
2 replies to this topic

#1 scatcatpdx

scatcatpdx
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 09 July 2006 - 06:02 AM


I am rolling my own MYSQL shopping cart. One of my requirement is the catalog will be static html files.  I have embedded the following into my web page.



<form action="http://www.[my page]addcart.php" method="post"  NAME="order" id="order">
      Quantity: <input type=text size=2 maxlength=3 name=QUANTITY >
  <?php
 
header("Location: http://www.[mypage]setInputbutton.php?item=44005");
?>


      <input type=hidden name="ID_NUM" value="44005">
   
      </form >

The way it works is in the form I call SetInputbutton.php with the catalog number. The script queries database to get the quantity  in stock. If good it echos the place in cart button, if below a set point it places the number in stock and a place in cart button and if zero, echo only out of stock preventign purchase. The script works but When I view HTML source; it shows the entire PHP script. The question is how to hide the PHP script for prying eyes.



#2 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 09 July 2006 - 06:06 AM

For that you'd want to use AJAX (Asynchronous JavaScript And XML). You can read about it at these links:
http://www.w3schools...jax/default.asp
http://en.wikipedia....x_(programming)
http://developer.moz...Getting_Started

Your example script won't work by the way, you are sending a header after outputting.

#3 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 09 July 2006 - 06:10 AM

Also, if your source file does not have a ".php" extension, you PHP code will not get processed and will be treated as plain text, showing up on the page and in the source.

Ken




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users