Searching: How to asking user input data into TEXT BOX

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
sarjanajava
Forum Newbie
Posts: 3
Joined: Mon Dec 02, 2002 10:29 am

Searching: How to asking user input data into TEXT BOX

Post by sarjanajava »

Hi There!

I have a problem in order to making / writting SQL. The problem is I want to ask user input any 'data' such as name or other related into TEXT BOX. After data have been inputed, SUBMIT BUTTON will perform a query regarding 'data' and produce a result in table.

What should I put in ? name=?. The above code is for instance
filename: form.html; to provide a FORM

Code: Select all

html>
<body>

<form action="databaseSQL.php" method="post">
  <TEXTAREA cols=20 name=sql rows=5>
  <?PHP
  echo(stripslashes($_POST&#1111;"sql"]));
   ?></TEXTAREA>
  <input type="submit" name="sql_post">
</form>
</BODY>
</html>
And this is code for databaseSQL.php; to process QUERY

Code: Select all

<HTML>
<HEAD>
<TITLE>Listing 17.3</TITLE>
</HEAD>
<BODY>
<?
	//connect to server, then test for failure
	if(!($dbLink = mysql_pconnect("localhost", "user ","password")))
	&#123;
		print("Failed to connect to database!<BR>\n");
		print("Aborting!<BR>\n");
		exit();
	&#125;

	//select database, then test for failure
	if(!mysql_select_db("maildb", $dbLink))
	&#123;
		print("Can't use the test database!<BR>\n");
		print("Aborting!<BR>\n");
		exit();
	&#125;

	// get everything from catalog table
	$Query = "SELECT '$sql'";
	$Query .= "FROM addressbook";
	if(!($dbResult = mysql_query($Query, $dbLink)))
	&#123;
		print("Couldn't execute query!<BR>\n");
		print("MySQL reports:tak jumpa "); //. mysql_error() . "<BR>\n");
		print("Query was: $Query<BR>\n");
		exit();
	&#125;

	//start table

	print("<TABLE BORDER="1">\n");

	//create header row
	print("<TR>\n");
   // print("<TD BGCOLOR="#CCCCCC"><B>id</B></TD>\n");
	print("<TD BGCOLOR="#CCCCCD"><B>name</B></TD>\n");
	print("<TD BGCOLOR="#CCCCCC"><B>email</B></TD>\n");
	print("</TR>\n");

	// get each row
	while($dbRow = mysql_fetch_object($dbResult))
	&#123;
		print("<TR>\n");
	   //	print("<TD>$dbrow->id</TD>\n");
		print("<TD ALIGN="right">$dbRow->name</TD>\n");
        print("<TD ALIGN="left">$dbRow->email</TD>\n");

		print("</TR>\n");
	&#125;

	//end table
	print("</TABLE>\n");
?>
</BODY>
</HTML>
PLEASE HELP ME!. yOU CAN visit this site for information and look at SUBMIT BUTTON ; http://www.kopkastam.org.my/ahli
Post Reply