Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MySQL with web-based forms

Status
Not open for further replies.

itsh

Programmer
Nov 26, 2000
1
JO
Hi: Is there a program for submitting and manipulating collected web information from a form to an MySQL db,thanks?
 
No program that I know of, but you can do it yourself...

********************
echo "
<HTML>
<HEAD>
<TITLE>Your Title</TITLE>
</HEAD>
<BODY>
<A href='#beginform'>Submit</A><P>
&quot;;
mysql_connect(DBhost,DBusername,DBpassword);
if($didsubmit){
$insertsuccessful=mysql(DBname,&quot;insert into tablename (fieldname) values ($field)&quot;);
if($insertsuccessful){
echo &quot;Successfully inserted &quot;,$field,&quot; into the MySQL database&quot;;
}else{
echo &quot;Error! Not able to insert &quot;,$field,&quot; into the MySQL database&quot;;
}
}
$allsubmissions=mysql(DBname,&quot;select * from tablename&quot;);
$numsubmissions=mysql_numrows($allsubmissions);
for($i=0;$i<$numsubmissions;$i++){
$submission=mysql_result($allsubmissions,$i,&quot;fieldname&quot;);
echo $submission,&quot;<BR>&quot;;
}
echo&quot;
<P>
<A name=beginform>&nbsp;</A>
<FORM method=post action='&quot;,$PHP_SELF,&quot;'>
<INPUT type=text name=field value='Initial Form Value'>
<INPUT type=submit name=didsubmit>
</FORM>
</BODY>
</HTML>
&quot;;
******************

That's it. Sans my typos, there's what you need for a basic thing. I bolded the variable/field names that are free for you to change so that, in case you're really new at this, you know what to keep and what doesn't have to stay the same. Make sure matching words in bold still match if you change them though, and the database names does have to change according to your own database. Look it over carefully, and just ask if you have questions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top