<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>test form</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> </head> <body> <!-- php form that calls up itself ! --> <?php if($_GET['fullname']) { $name=$_GET['fullname']; print "<p> hello $name</p>"; // open mysql connection $link=mysql_connect('localhost','test',''); if(! $link) { print "<p>At this time, I can not tell you how many times you have been greeted.</p>"; } else { mysql_select_db('test'); $query="SELECT * FROM greetings WHERE name='$name'"; #print "my query is $query<br/>"; $result=mysql_query($query); $error=mysql_error(); if($error) { print "mysql error: $error<br/>\n"; } if(! mysql_num_rows($result)) { print "<p>This is my first greeting to you!</p>"; $number=1; $query="INSERT INTO greetings VALUES ('$name','$number')"; #print "my query is $query<br/>"; $error=mysql_error(); if($error) { print "mysql error: $error<br/>\n"; } } else { $columns=mysql_fetch_array($result); $number=$columns['number']+1; $query="UPDATE greetings SET number='$number' WHERE name='$name'"; #print "$query </br>"; $error=mysql_error(); if($error) { print "mysql error: $error<br/>\n"; } print "<p>This is greeting number $number</p>\n"; } } } print "<form action=\"greetings.php\" method=\"get\">\n"; print "<p><label for=\"fullname\">your name</label> <input id=\"fullname\" value=\"$_GET[fullname]\" name=\"fullname\"/></p>"; print "</form>\n"; ?> <p id="validator"> <a href="http://validator.w3.org/check?uri=referer"><img style="border: 0pt" src="http://dlib.info/valid-xhtml10.png" alt="Valid XHTML 1.0!" height="31" width="88" /></a> </p> </body> </html>