<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.0.4" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>Inexpensive Web Hosting, MySQL, Java, JSP, Php4, Php5 Programming, Servlet Blog</title>
	<link>http://www.g5websitehosting.com</link>
	<description>Weblog about Php5 Hosting, MySQL, Java, JSP, Servlet</description>
	<pubDate>Fri, 28 Mar 2008 11:19:21 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.4</generator>
	<language>en</language>
			<item>
		<title>Web site designers - Chapter 17 . Building Forms from Queries 325</title>
		<link>http://www.g5websitehosting.com/g5/web-site-designers-chapter-17-building-forms-from-queries-325/</link>
		<comments>http://www.g5websitehosting.com/g5/web-site-designers-chapter-17-building-forms-from-queries-325/#comments</comments>
		<pubDate>Fri, 28 Mar 2008 11:19:21 +0000</pubDate>
		<dc:creator>humphreyblogart</dc:creator>
		
	<category>G5</category>
		<guid isPermaLink="false">http://www.g5websitehosting.com/g5/web-site-designers-chapter-17-building-forms-from-queries-325/</guid>
		<description><![CDATA[Chapter 17 . Building Forms from Queries 325  Figure 17-4: A prepopulated check box  Listing 17-6: Checkbox displaying boolean data from database  (optout.php)  ]]></description>
			<content:encoded><![CDATA[<p>Chapter 17 . Building Forms from Queries 325  Figure 17-4: A prepopulated check box  Listing 17-6: Checkbox displaying boolean data from database  (optout.php)  <?php  // Open connection to the database  mysql_connect( localhost ,  phpuser ,  sesame )  or die( Failure to communicate with database );  mysql_select_db( test );  // If the form has been submitted, record the preference and  // redisplay  if ($_POST[ submit ] ==  Submit ) {  $email = $_POST[ email ];  $as_email = addslashes($_POST[ email ]);  if (isSet($_POST[ OptOut ] &#038;&#038; $_POST[ OptOut ] == 1) {  $optout = 1;  } else {  $optout = 0;  } // Update value  $query =  UPDATE checkbox  SET BoxValue = $optout  WHERE BoxName =  OptOut   AND email =  $as_email  ;  $result = mysql_query($query);  if (mysql_error() ==   ) {  Continued   <br />In case you need affordable webhost to host your website, our recommendation is <a href="http://jboss.tomcatjavahosting.com">ecommerce web host</a> services.
</p>
]]></content:encoded>
			<wfw:commentRSS>http://www.g5websitehosting.com/g5/web-site-designers-chapter-17-building-forms-from-queries-325/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>324 Part II . PHP and MySQL Listing  (Web design rates)</title>
		<link>http://www.g5websitehosting.com/g5/324-part-ii-php-and-mysql-listing-web-design-rates/</link>
		<comments>http://www.g5websitehosting.com/g5/324-part-ii-php-and-mysql-listing-web-design-rates/#comments</comments>
		<pubDate>Fri, 28 Mar 2008 00:26:29 +0000</pubDate>
		<dc:creator>humphreyblogart</dc:creator>
		
	<category>G5</category>
		<guid isPermaLink="false">http://www.g5websitehosting.com/g5/324-part-ii-php-and-mysql-listing-web-design-rates/</guid>
		<description><![CDATA[324 Part II . PHP and MySQL  Listing 17-5 (continued)  &#8211;>                  Comment edit  $success_msg      $comment                [...]]]></description>
			<content:encoded><![CDATA[<p>324 Part II . PHP and MySQL  Listing 17-5 (continued)  &#8211;>  </STYLE>  </HEAD>  <BODY>  <TABLE BORDER=0 CELLPADDING=10 WIDTH=100%>  <TR>  <TD BGCOLOR= #F0F8FF  ALIGN=CENTER VALIGN=TOP WIDTH=17%>  </TD>  <TD BGCOLOR= #FFFFFF  ALIGN=LEFT VALIGN=TOP WIDTH=83%>  <H1>Comment edit</H1>  $success_msg  <FORM METHOD= post  ACTION= $thispage >  <INPUT TYPE= text  SIZE= 40  NAME= comment_header   VALUE= $comment_header ><BR><BR>  <TEXTAREA NAME= comment  ROWS=10 COLS=50>$comment</TEXTAREA>  <BR><BR>  <INPUT TYPE= hidden  NAME= comment_id  VALUE= $comment_id >  <INPUT TYPE= submit  NAME= submit  VALUE= Submit >  </FORM>  </TD></TR></TABLE>  </BODY>  </HTML>  EOFORMPAGE;  echo $form_page;  ?>  Remember that in an HTML form integers and doubles must use the TEXT or TEXTAREA  type, as there is no specifically numeric HTML form field type.  CHECKBOX  The CHECKBOX type has only one possible value per input: off (unchecked) or on (checked).  The database field which records this information is almost always going to be a small integer  or bit type with values 0 and 1 corresponding to unchecked or checked check boxes.  Figure 17-4 shows a common type of check box being edited.  Listing 17-6 demonstrates how to use a check box to display and change a Boolean value.  Tip   <br />We would like to recommend you tested and proved <a href="http://jboss.smartwebsitehosting.net">virtual web hosting</a> services, which you will surely find to be of great quality.
</p>
]]></content:encoded>
			<wfw:commentRSS>http://www.g5websitehosting.com/g5/324-part-ii-php-and-mysql-listing-web-design-rates/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Chapter 17 . Building  (Tomcat web server) Forms from Queries 323</title>
		<link>http://www.g5websitehosting.com/g5/chapter-17-building-tomcat-web-server-forms-from-queries-323/</link>
		<comments>http://www.g5websitehosting.com/g5/chapter-17-building-tomcat-web-server-forms-from-queries-323/#comments</comments>
		<pubDate>Thu, 27 Mar 2008 10:06:01 +0000</pubDate>
		<dc:creator>humphreyblogart</dc:creator>
		
	<category>G5</category>
		<guid isPermaLink="false">http://www.g5websitehosting.com/g5/chapter-17-building-tomcat-web-server-forms-from-queries-323/</guid>
		<description><![CDATA[Chapter 17 . Building Forms from Queries 323  Listing 17-5: Editing data from database (comment_edit.php)  ]]></description>
			<content:encoded><![CDATA[<p>Chapter 17 . Building Forms from Queries 323  Listing 17-5: Editing data from database (comment_edit.php)  <?php  // Open connection to the database  mysql_connect( localhost ,  phpuser ,  sesame )  or die( Failure to communicate with database );  mysql_select_db( test );  if ($_POST[ submit ] ==  Submit ) {  // Format the data  $comment_id = $_POST[ comment_id ];  $comment_header = $_POST[ comment_header ];  $as_comment_header = addslashes($comment_header);  $comment = $_POST[ comment ];  $as_comment = addslashes($_POST[ comment ]);  // Update values  $query =  UPDATE comments  SET comment_header =  $as_comment_header ,  comment =  $as_comment   WHERE ID = $comment_id ;  $result = mysql_query($query);  if (mysql_affected_rows() == 1) {  $success_msg =  <P>Your comment has been updated.</P> ;  } else {  error_log(mysql_error());  $success_msg =  <P>Something went wrong.</P> ;  }  } else {  // Get the comment header and comment  $comment_id = $_GET[ comment_id ];  $query =  SELECT comment_header, comment  FROM comments  WHERE ID = $comment_id ;  $result = mysql_query($query);  $comment_arr = mysql_fetch_array($result);  $comment_header = stripslashes($comment_arr[0]);  $comment = stripslashes($comment_arr[1]);  } $thispage = $_SERVER[ PHP_SELF ]; //Have to do this for heredoc  $form_page = <<< EOFORMPAGE  <STYLE TYPE= text/css >  <!--  BODY, P {color: black; font-family: verdana;  font-size: 10 pt}  H1 {color: black; font-family: arial; font-size: 12 pt}  Continued   <br />Searching for affordable and reliable webhost to host and run your web applications? Go to our <a href="http://www.smartwebsitehosting.net">java web server</a> services and you will be pleased.
</p>
]]></content:encoded>
			<wfw:commentRSS>http://www.g5websitehosting.com/g5/chapter-17-building-tomcat-web-server-forms-from-queries-323/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>322 Part II . PHP and MySQL Editing  (Tomcat web server)</title>
		<link>http://www.g5websitehosting.com/g5/322-part-ii-php-and-mysql-editing-tomcat-web-server/</link>
		<comments>http://www.g5websitehosting.com/g5/322-part-ii-php-and-mysql-editing-tomcat-web-server/#comments</comments>
		<pubDate>Wed, 26 Mar 2008 23:21:35 +0000</pubDate>
		<dc:creator>humphreyblogart</dc:creator>
		
	<category>G5</category>
		<guid isPermaLink="false">http://www.g5websitehosting.com/g5/322-part-ii-php-and-mysql-editing-tomcat-web-server/</guid>
		<description><![CDATA[322 Part II . PHP and MySQL  Editing Data with an HTML Form  PHP is brilliant at putting variables into a database, but it really shines when taking data from  a database, displaying it in a form to be edited, and then putting it back in the database. Its  HTML-embeddedness, easy [...]]]></description>
			<content:encoded><![CDATA[<p>322 Part II . PHP and MySQL  Editing Data with an HTML Form  PHP is brilliant at putting variables into a database, but it really shines when taking data from  a database, displaying it in a form to be edited, and then putting it back in the database. Its  HTML-embeddedness, easy variable-passing, and slick database connectivity are at their best  in this kind of job. These techniques are extremely useful, because you will find a million  occasions to edit data you re storing in a database.  Let s look at the specific kinds of HTML FORM data elements and how they are handled.  TEXT and TEXTAREA  TEXT and TEXTAREA are the most straightforward types because they enjoy an unambiguous  one-to-one relationship between identifier and content. In other words, there is only one possible  VALUE per NAME. You just pull the data field from the database and display it in the form  by referencing the appropriate array value, as shown in Figure 17-3.  Figure 17-3: Displaying text for editing  Listing 17-5, comment_edit.php, takes a comment out of the database and allows you to edit it.  You may need to use the stripslashes function when displaying TEXTAREA and TEXT if  there s any chance the values might have single quotes or apostrophes and magic_quotes_  gpc is on. Watch out for people with apostrophe d names like O Malley or D Nesh!  Tip   <br />You need excellent and relaible webhost company to host your web applications? Then pay a visit to <a href="http://www.g5websitehosting.com">Inexpensive Web Hosting</a> services.
</p>
]]></content:encoded>
			<wfw:commentRSS>http://www.g5websitehosting.com/g5/322-part-ii-php-and-mysql-editing-tomcat-web-server/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Chapter 17 . Building Forms from Queries 321  (Submit web site)</title>
		<link>http://www.g5websitehosting.com/g5/chapter-17-building-forms-from-queries-321-submit-web-site/</link>
		<comments>http://www.g5websitehosting.com/g5/chapter-17-building-forms-from-queries-321-submit-web-site/#comments</comments>
		<pubDate>Wed, 26 Mar 2008 13:21:59 +0000</pubDate>
		<dc:creator>humphreyblogart</dc:creator>
		
	<category>G5</category>
		<guid isPermaLink="false">http://www.g5websitehosting.com/g5/chapter-17-building-forms-from-queries-321-submit-web-site/</guid>
		<description><![CDATA[Chapter 17 . Building Forms from Queries 321  Figure 17-2: A multiple self-submitting form  Another issue with self-submitted forms is navigation. With the traditional HTML form, navigation  is strictly one-way: form to handler to whatever navigational device (if any) the designer  decrees. Self-submitted forms need not conform to this rule, however. [...]]]></description>
			<content:encoded><![CDATA[<p>Chapter 17 . Building Forms from Queries 321  Figure 17-2: A multiple self-submitting form  Another issue with self-submitted forms is navigation. With the traditional HTML form, navigation  is strictly one-way: form to handler to whatever navigational device (if any) the designer  decrees. Self-submitted forms need not conform to this rule, however. In each individual  instance, you need to decide:  . Whether the form can be resubmitted multiple times by the user, in whole or in part.  . Whether the user decides when to move on by clicking a link or the form moves users  along automatically.  . Whether you need to pass variables on to the next page, hidden or in plain view.  . Whether you want to control where the user can go next or if you want to give users  multiple choices.  All these techniques are most commonly used in user-management functions registration,  login, and editing user information which are demonstrated realistically in Chapter 44.  The answers to these questions will determine whether you need a control, another form, a  simple link or button, or multiple links.  Whatever you decide about navigation, remember to provide plenty of text that clearly explains  what s going to happen at every step. Because PHP gives you so much flexibility with forms,  new users  default expectations may be crossed up, and they could end up uncertain whether  they accomplished their mission with your form.  Tip  Cross-  Reference   <br />Please visit <a href="http://domain.g5websitehosting.com">Domain Name Hosting</a> services for high quality webhost to host and run your jsp applications.
</p>
]]></content:encoded>
			<wfw:commentRSS>http://www.g5websitehosting.com/g5/chapter-17-building-forms-from-queries-321-submit-web-site/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Shared web hosting - 320 Part II . PHP and MySQL Listing</title>
		<link>http://www.g5websitehosting.com/g5/shared-web-hosting-320-part-ii-php-and-mysql-listing/</link>
		<comments>http://www.g5websitehosting.com/g5/shared-web-hosting-320-part-ii-php-and-mysql-listing/#comments</comments>
		<pubDate>Wed, 26 Mar 2008 03:07:14 +0000</pubDate>
		<dc:creator>humphreyblogart</dc:creator>
		
	<category>G5</category>
		<guid isPermaLink="false">http://www.g5websitehosting.com/g5/shared-web-hosting-320-part-ii-php-and-mysql-listing/</guid>
		<description><![CDATA[320 Part II . PHP and MySQL  Listing 17-4 (continued)  if (mysql_affected_rows() == 1) {  $message =  Your rating has been submitted. ;  } else {  error_log(mysql_error());  $message =  Something went wrong with your rating  attempt. Try again. ;  $message .= $rate_form;  }  [...]]]></description>
			<content:encoded><![CDATA[<p>320 Part II . PHP and MySQL  Listing 17-4 (continued)  if (mysql_affected_rows() == 1) {  $message =  <P>Your rating has been submitted.</P> ;  } else {  error_log(mysql_error());  $message =  <P>Something went wrong with your rating  attempt. Try again.</P> ;  $message .= $rate_form;  }  } ?>  <HTML>  <HEAD>  <STYLE TYPE= text/css >  <!--  BODY, P {color: black; font-family: verdana;  font-size: 10 pt}  H1 {color: black; font-family: arial; font-size: 12 pt}  -->  </STYLE>  </HEAD>  <BODY>  <TABLE BORDER=0 CELLPADDING=10 WIDTH=100%>  <TR>  <TD BGCOLOR= #F0F8FF  ALIGN=CENTER VALIGN=TOP WIDTH=17%>  </TD>  <TD BGCOLOR= #FFFFFF  ALIGN=LEFT VALIGN=TOP WIDTH=83%>  <H1>Rate your boss anonymously</H1>  <?php echo $message; ?>  </TD>  </TR>  </TABLE>  </BODY>  </HTML>  Figure 17-2 shows the rating form after an error has occurred.  Some of you might be thinking,  Hey, wait! You said logic always comes before display but  then you started this script with a bunch of HTML.  Very perspicacious but not quite right.  Look closely and you will realize that we are merely setting a bunch of text to a couple of  variable strings ($reg_form and $rate_form). In the entire PHP section, we actually don t  display anything. We merely construct a string, $message, which will be plugged in to the  HTML at the bottom. If we took away the HTML, you would see a blank page in the browser.  So it s OK to assemble the text you re going to want to display in the logic part; just don t  echo it out to the browser until the end.   <br />You want to have a cheap webhost for your apache application, then check <a href="http://apache.tomcatjavahosting.com">apache web hosting</a> services.
</p>
]]></content:encoded>
			<wfw:commentRSS>http://www.g5websitehosting.com/g5/shared-web-hosting-320-part-ii-php-and-mysql-listing/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Yahoo web hosting - Chapter 17 . Building Forms from Queries 319</title>
		<link>http://www.g5websitehosting.com/g5/yahoo-web-hosting-chapter-17-building-forms-from-queries-319/</link>
		<comments>http://www.g5websitehosting.com/g5/yahoo-web-hosting-chapter-17-building-forms-from-queries-319/#comments</comments>
		<pubDate>Tue, 25 Mar 2008 15:23:29 +0000</pubDate>
		<dc:creator>humphreyblogart</dc:creator>
		
	<category>G5</category>
		<guid isPermaLink="false">http://www.g5websitehosting.com/g5/yahoo-web-hosting-chapter-17-building-forms-from-queries-319/</guid>
		<description><![CDATA[Chapter 17 . Building Forms from Queries 319  mysql_select_db( test );  // Check to see this name and email have not appeared before  $as_name = addslashes($_POST[ name ]);  $tr_name = trim($as_name);  $as_email = addslashes($_POST[ email ]);  $tr_email = trim($as_email);  $query =  SELECT sub_id FROM raters  WHERE [...]]]></description>
			<content:encoded><![CDATA[<p>Chapter 17 . Building Forms from Queries 319  mysql_select_db( test );  // Check to see this name and email have not appeared before  $as_name = addslashes($_POST[ name ]);  $tr_name = trim($as_name);  $as_email = addslashes($_POST[ email ]);  $tr_email = trim($as_email);  $query =  SELECT sub_id FROM raters  WHERE Name =  $tr_name   AND Email =  $tr_email    ;  $result = mysql_query($query);  if (mysql_num_rows($result) > 0) {  error_log(mysql_error());  $message =  Someone with this name and password has  already rated . If you think a mistake was made, please email  help@example.com. ;  } else {  // Insert name and email address  $query =  INSERT INTO raters (ID, Name, Email)  VALUES(NULL,  $tr_name ,  $tr_email )   ;  $result = mysql_query($query);  if (mysql_affected_rows() == 1) {  $message = $rate_form;  } else {  error_log(mysql_error());  $message =  <P>Something went wrong with your signup  attempt.</P> ;  $message .= $reg_form;  }  }  }  } elseif ($_POST[ submit ] ==  Submit  &#038;&#038; $_POST[ stage ] ==   rate ) {  // Third time, store the rating and boss s name  // Open connection to the database  mysql_connect( localhost ,  phpuser ,  sesame )  or die( Failure to communicate with database );  mysql_select_db( test );  // Insert rating and boss s name  $as_boss = addslashes($_POST[ boss ]);  $tr_boss = trim($as_boss);  $rating = $_POST[ rating ];  $query =  INSERT INTO ratings (ID, Rating, Boss)  VALUES(NULL,  $rating ,  $tr_boss )   ;  $result = mysql_query($query);  Continued   <br />If you are looking for affordable and reliable webhost to host and run your business application visit our <a href="http://domain.smartwebsitehosting.net">ftp web hosting</a> services.
</p>
]]></content:encoded>
			<wfw:commentRSS>http://www.g5websitehosting.com/g5/yahoo-web-hosting-chapter-17-building-forms-from-queries-319/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>318 Part II . PHP and MySQL Listing  (Free web hosting with ftp)</title>
		<link>http://www.g5websitehosting.com/g5/318-part-ii-php-and-mysql-listing-free-web-hosting-with-ftp/</link>
		<comments>http://www.g5websitehosting.com/g5/318-part-ii-php-and-mysql-listing-free-web-hosting-with-ftp/#comments</comments>
		<pubDate>Tue, 25 Mar 2008 03:29:32 +0000</pubDate>
		<dc:creator>humphreyblogart</dc:creator>
		
	<category>G5</category>
		<guid isPermaLink="false">http://www.g5websitehosting.com/g5/318-part-ii-php-and-mysql-listing-free-web-hosting-with-ftp/</guid>
		<description><![CDATA[318 Part II . PHP and MySQL  Listing 17-4 (continued)  information with your rating.    Name:   Email:           EOREGFORM;  $rate_form =  30)) {  $message =  There is a problem. Did you enter a name and  [...]]]></description>
			<content:encoded><![CDATA[<p>318 Part II . PHP and MySQL  Listing 17-4 (continued)  information with your rating.</P>  <FORM METHOD= post  ACTION= $thisfile >  Name: <INPUT TYPE= text  SIZE=25 NAME= name ><BR><BR>  Email: <INPUT TYPE= text  SIZE=25 NAME= email >  <INPUT TYPE= hidden  NAME= stage  VALUE= register >  <BR><BR>  <INPUT TYPE= submit  NAME= submit  VALUE= Submit >  </FORM>  EOREGFORM;  $rate_form = <<< EORATEFORM  <P>My boss is:</P>  <FORM METHOD= post  ACTION= $thisfile >  <INPUT TYPE= radio  NAME= rating  VALUE=1>  Driving me to look for a new job.<BR>  <INPUT TYPE= radio  NAME= rating  VALUE=2>  Not the worst, but pretty bad.<BR>  <INPUT TYPE= radio  NAME= rating  VALUE=3>  Just so-so.<BR>  <INPUT TYPE= radio  NAME= rating  VALUE=4>  Pretty good.<BR>  <INPUT TYPE= radio  NAME= rating  VALUE=5>  A pleasure to work with.<BR><BR>  Boss s name: <INPUT TYPE= text  SIZE=25 NAME= boss ><BR>  <INPUT TYPE= hidden  NAME= stage  VALUE= rate >  <BR><BR>  <INPUT TYPE= submit  NAME= submit  VALUE= Submit >  </FORM>  EORATEFORM;  if (!$_POST[ submit ]) {  // First time, just show the registration form  $message = $reg_form;  } elseif ($_POST[ submit ] ==  Submit  &#038;&#038; $_POST[ stage ] ==   register ) {  // Second time, show the registration form again on error,  // rating form on successful INSERT  if (!$_POST[ name ] || $_POST[ name ] ==    ||  strlen($_POST[ name ] > 30) || !$_POST[ email ] ||  $_POST[ email ] ==    || strlen($_POST[ email ] > 30)) {  $message =  <P>There is a problem. Did you enter a name and  email address?</P> ;  $message .= $reg_form;  } else {  // Open connection to the database  mysql_connect( localhost ,  phpuser ,  sesame )  or die( Failure to communicate with database );   <br />Searching for affordable and reliable webhost to host and run your web applications? Go to our <a href="http://www.smartwebsitehosting.net">java web server</a> services and you will be pleased.
</p>
]]></content:encoded>
			<wfw:commentRSS>http://www.g5websitehosting.com/g5/318-part-ii-php-and-mysql-listing-free-web-hosting-with-ftp/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Chapter 17  (Sex offenders web site) . Building Forms from Queries 317</title>
		<link>http://www.g5websitehosting.com/g5/chapter-17-sex-offenders-web-site-building-forms-from-queries-317/</link>
		<comments>http://www.g5websitehosting.com/g5/chapter-17-sex-offenders-web-site-building-forms-from-queries-317/#comments</comments>
		<pubDate>Mon, 24 Mar 2008 17:07:22 +0000</pubDate>
		<dc:creator>humphreyblogart</dc:creator>
		
	<category>G5</category>
		<guid isPermaLink="false">http://www.g5websitehosting.com/g5/chapter-17-sex-offenders-web-site-building-forms-from-queries-317/</guid>
		<description><![CDATA[Chapter 17 . Building Forms from Queries 317                      Newsletter sign-up form              The first time you load up this page, you should [...]]]></description>
			<content:encoded><![CDATA[<p>Chapter 17 . Building Forms from Queries 317  <STYLE TYPE= text/css >  <!--  BODY, P {color: black; font-family: verdana;  font-size: 10 pt}  H1 {color: black; font-family: arial; font-size: 12 pt}  -->  </STYLE>  </HEAD>  <BODY>  <TABLE BORDER=0 CELLPADDING=10 WIDTH=100%>  <TR>  <TD BGCOLOR= #F0F8FF  ALIGN=CENTER VALIGN=TOP WIDTH=17%>  </TD>  <TD BGCOLOR= #FFFFFF  ALIGN=LEFT VALIGN=TOP WIDTH=83%>  <H1>Newsletter sign-up form</H1>  <?php echo $message; ?>  </TD>  </TR>  </TABLE>  </BODY>  </HTML>  The first time you load up this page, you should see a normal HTML form exactly like the one  in Figure 17-1. If you submit it without any data or with a string that s too long (often a sign of  a cracking attempt), you ll see an error message and the form again. If something goes wrong  with the database INSERT, you ll see an error message and the form again. Only if the INSERT  completes successfully will you not see the form again which is the navigation we want  because we don t want people to sign up for the newsletter more than once.  In the preceding example, we need to check only for two states of the form (unsubmitted or  submitted) so we can use the Submit button as our stage variable. But what if you want to  check for more than one state? You need a variable that is capable of taking more than one  value. You could either give your Submit button different values, which would show up as different  labels in the button itself, or you could set a hidden variable that is capable of taking  more than one value depending on the state. We demonstrate the technique in Listing 17-4,  which collects some information and then allows you to rate your boss anonymously.  Listing 17-4: A three-part form (rate_boss.php)  <?php  // First set the form strings, which will be displayed  //in various cases below  $thisfile = $_SERVER[ PHP_SELF ]; //Have to set this for heredoc  $reg_form = <<< EOREGFORM  <P>We must ask for your name and email address to ensure that no  one votes more than once, but we do not associate your personal  Continued   <br />We recommend cheap and reliable webhost to host and run your web applications: <a href="http://coldfusion.tomcatjavahosting.com">Coldfusion Web Hosting</a> services.
</p>
]]></content:encoded>
			<wfw:commentRSS>http://www.g5websitehosting.com/g5/chapter-17-sex-offenders-web-site-building-forms-from-queries-317/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Web design programs - 316 Part II . PHP and MySQL Listing</title>
		<link>http://www.g5websitehosting.com/g5/web-design-programs-316-part-ii-php-and-mysql-listing/</link>
		<comments>http://www.g5websitehosting.com/g5/web-design-programs-316-part-ii-php-and-mysql-listing/#comments</comments>
		<pubDate>Mon, 24 Mar 2008 06:16:40 +0000</pubDate>
		<dc:creator>humphreyblogart</dc:creator>
		
	<category>G5</category>
		<guid isPermaLink="false">http://www.g5websitehosting.com/g5/web-design-programs-316-part-ii-php-and-mysql-listing/</guid>
		<description><![CDATA[316 Part II . PHP and MySQL  Listing 17-3: Unified form and form-handler (newsletter_signup.php)         Searching for affordable and proven webhost to host and run your servlet applications? Go to Linux Web Hosting services and you will find it.

]]></description>
			<content:encoded><![CDATA[<p>316 Part II . PHP and MySQL  Listing 17-3: Unified form and form-handler (newsletter_signup.php)  <?php  if ($_POST[ submit ] ==  Submit ) {  if (!$_POST[ email ] || $_POST[ email ] ==    ||  strlen($_POST[ email ] > 30)) {  $message =  <P>There is a problem. Did you enter an email  address?</P> ;  } else {  // Open connection to the database  mysql_connect( localhost ,  phpuser ,  sesame )  or die( Failure to communicate with database );  mysql_select_db( test );  // Insert email address  $as_email = addslashes($_POST[ email ]);  $tr_email = trim($as_email);  $query =  INSERT INTO mailinglist (ID, Email, Source)  VALUES(NULL,  $tr_email ,   www.example.com/newsletter_signup.html )   ;  $result = mysql_query($query);  if (mysql_affected_rows() == 1) {  $message =  <P>Your information has been recorded.</P> ;  $noform_var = 1;  } else {  error_log(mysql_error());  $message =  <P>Something went wrong with your signup  attempt.</P> ;  }  } // Show the form in every case except successful submission  if (!$noform_var) {  $thisfile = $_SERVER[ PHP_SELF ];  $message .= <<< EOMSG  <P>Enter your email address and we will send you our weekly  newsletter.</P>  <FORM METHOD= post  ACTION= $thisfile >  <INPUT TYPE= text  SIZE=25 NAME= email >  <BR><BR>  <INPUT TYPE= submit  NAME= submit  VALUE= Submit >  </FORM>  EOMSG;  }  } ?>  <HTML>  <HEAD>   <br />Searching for affordable and proven webhost to host and run your servlet applications? Go to <a href="http://linux.g5websitehosting.com">Linux Web Hosting</a> services and you will find it.
</p>
]]></content:encoded>
			<wfw:commentRSS>http://www.g5websitehosting.com/g5/web-design-programs-316-part-ii-php-and-mysql-listing/feed/</wfw:commentRSS>
		</item>
	</channel>
</rss>
