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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie Form help

Status
Not open for further replies.

elentz

Technical User
Jan 9, 2007
81
US
I am in need of a simple form to take two pieces of information from the page user and insert that into a MySql update query. I have no clue how to get this started. Can someone point me to a sample or something to get me started. I just want something that can be used infrequently.


Thanks in advance
 
how about:

Code:
<form action=thisformspage.php method=post>
<input type=text name="info1">
<input type=text name="info2">
<input type=submit name="send" value="Submit to DB">
</form>

<?PHP
if(isset($_POST['send'])){
[green]\\check if the form has been submitted, and act accordingly.  Make data safe to be posted into DB[/green]

$fieldvalue1=mysql_real_escape_string($_POST['info1']);
$fieldvalue2=mysql_real_escape_string($_POST['info2']);

$query="INSERT INTO mytablename field1,field2 values('" . $fieldvalue1 . "','" . $fieldvalue2 . "')";
 
[green]\\connect to db, select db[/green]
$res=mysql_query($query);
}
?>

note i wrote this straight into the reply box here, so there might be errors, but you can play around with that, and if you have any questions post back.

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Thanks for the push start!

I got it working perfectly!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top