Reply
what do we need to do to process HTML forrm on php-mysql database ?
Old 04-10-2008, 06:00 PM what do we need to do to process HTML forrm on php-mysql database ?
Junior Talker

Posts: 2
I have a software madeup of php and mysql , what do weed to process the HTML form into database with php software ? any help is appreceated.
linux1880 is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 04-10-2008, 06:23 PM Re: what do we need to do to process HTML forrm on php-mysql database ?
Gilligan's Avatar
Dead Like Me

Posts: 1,608
Name: Stefan
Location: London, UK
You mean add the stuff entered from the form into a database?

If so, easy.

for your html.

Code:
<form action="page.php" method="post">
<input type="text" name="Name">
<input type="text" name="Email">
<input type="submit" value="Submit">
</form>
for page.php

PHP Code:
<?php

// Connect to database

$con mysql_connect('localhost''mysql_user''mysql_password');
if (!
$con) {
    die(
mysql_error());
}

// variables



$name $_POST['Name'];

$email $_POST['Email'];



// add to database.

mysql_select_db("mysql_db"$con);     mysql_query("INSERT INTO details (Name, Email) 
VALUES ('$name', '$email')"
);mysql_close($con);
Gilligan is offline
Reply With Quote
View Public Profile
 
Old 04-10-2008, 06:38 PM Re: what do we need to do to process HTML forrm on php-mysql database ?
whym's Avatar
Putting food on my family

Posts: 3,415
Name: Daniel
Location: A sleepy town in Mid Wales
The above way will work fine.

However, I tend to prefer to use the following MySQL query instead as it just seems slightly easier - you can see exactly what it doing what:

PHP Code:
mysql_query("INSERT INTO details SET Name='$name',Email='$email'"); 
It's only a slight difference but you can see exactly what you are putting into each field in the database

Dan
whym is offline
Reply With Quote
View Public Profile Visit whym's homepage!
 
Old 04-10-2008, 06:43 PM Re: what do we need to do to process HTML forrm on php-mysql database ?
Gilligan's Avatar
Dead Like Me

Posts: 1,608
Name: Stefan
Location: London, UK
I never knew that, haha. Thanks for that, I'll be using that much more in future.

By the way, i'm still new to php, so i'm proud of the code I posted above
Gilligan is offline
Reply With Quote
View Public Profile
 
Old 04-10-2008, 06:49 PM Re: what do we need to do to process HTML forrm on php-mysql database ?
whym's Avatar
Putting food on my family

Posts: 3,415
Name: Daniel
Location: A sleepy town in Mid Wales
Quote:
Originally Posted by Gilligan View Post
I never knew that, haha. Thanks for that, I'll be using that much more in future.

By the way, i'm still new to php, so i'm proud of the code I posted above
No problem. I'm still fairly new to PHP too in fact
whym is offline
Reply With Quote
View Public Profile Visit whym's homepage!
 
Reply     « Reply to what do we need to do to process HTML forrm on php-mysql database ?
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12604 seconds with 12 queries