• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 8. Meeting HTML's Powerful Friends > Vary your content with variables

Vary your content with variables

Most interactive technologies use variables. A variable is quite simply a placeholder for information that can vary. Talk about your logical names. An example of a variable is a form field. When a user enters information, the variable is no longer null (empty). ASP, CGI/PERL, JavaScript, and PHP are a few technologies that use variables. An example of a variable in action is a PHP page transmitting the information from a form into a database. The variable populates the applicable field in the database. Listing PHP Code with Variables shows some PHP code with variables.

							PHP Code with Variables
						
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "RegisterUser")) {
  $insertSQL = sprintf("INSERT INTO users (FirstName, LastName, Address, City, `State`, Zip, email, InfoStore, announcements, productsUsed, feedback) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['FirstName'], "text"),
                       GetSQLValueString($_POST['LastName'], "text"),
                       GetSQLValueString($_POST['Address'], "text"),
                       GetSQLValueString($_POST['City'], "text"),
                       GetSQLValueString($_POST['State'], "text"),
                       GetSQLValueString($_POST['zip'], "int"),
                       GetSQLValueString($_POST['Email'], "text"),
                       GetSQLValueString(isset($_POST['InfoStore']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString(isset($_POST['announcements']) ? "true" : "", "defined","'Y'","'N'"),
                       GetSQLValueString($_POST['productsUsed'], "text"),
                       GetSQLValueString($_POST['feedback'], "text"));

					  



PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint