MySQL Forums
Forum List  »  Newbie

Re: How do I link my database to my form?
Posted by: Jay Alverson
Date: August 11, 2009 02:28PM

Harry R Wrote:
> Ok, does this make sense - to create a form a html
> form in dreamweaver and link it to mysql database?

Basically you have to place < form > tags around all
the data you'll need in the form's action.

This involves either singular items/values, single NAME=
attributes); or multiple ones using NAME=variable[] (note
the brackets, they're important). Brackets are for an array
of values that all use the same name (like checkboxes).

Next is the METHOD you want to send the data from the page
to the server. If you don't care you can use the GET method
if you don't want the user to see use POST.

The ACTION attribute tells the server which PHP page gets
the data from the form.

You get data by using the $_REQUEST function.

Sample form:

$form = "<form name='BBSForm' action='DownloadSJG.php' method='post' >
		<p><span>Topic URL </span><input name='url' type='text' value=''; size='77' /></p>
		<p><span>Topic Title </span><input name='topictitle' type='text' value='GURPS Spaceship Series' size='77' /></p>
		<p><span>Start Page </span><input name='startpage' type='text' value='1' size='3' /></p>
		<p><span>End Page </span><input name='endpage' type='text' value='1' size='3' /></p>
		<p><span>User Agent</span></p>
		<p><select name='useragent'>
			<option>Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20071127 Firefox/</option>
			<option>Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)</option>
		<p><input name='done' type='submit' value='Download' onclick='document.forms[\"BBSForm\"].submit;' /></p>

So from that form when the form gets submitted, the server will use the POST
method, and it will send the data from the client pc to the "DownloadSJG.php"
page for it to do whatever it needs to do with it.

All the important INPUTs have a NAME= and then you use $_REQUEST['url'] to get
the value of the INPUT name='url' the user placed. You can also get data from
a few other tags as well.

I suggest you download the PHP help file for your system as it is a wealth
of information and has examples, on all sorts of stuff using PHP.

THEN, once you have data, you can use functions like mysql_query (see
the help file) to log into mysql, make a connection, choose a database and
query a table (or insert or update or delete).

There are two separate areas that deal with MySQL: mysql_ and mysqli_

Look them up, read their introductions and see which one you really need.


Thanks, Jay

Edited 1 time(s). Last edit at 08/11/2009 02:30PM by Jay Alverson.

Options: ReplyQuote

Written By
Re: How do I link my database to my form?
August 11, 2009 02:28PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.