homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Using PHP to write form data in to MySQL
Lost, confused, and desperate-
SEO Speedster

 12:05 am on Nov 5, 2001 (gmt 0)

I am having great pains trying to get my form data into a mySQL database - and cannot find any suitable resources out there to help me out. I'm not a big PHP guy, or a MySQL guy, so pardon my inaccuracies or faults here!

I am used to ASP and SQL Server, and typically, I use a request.form(fieldname) to get the form contents, then I will insert it into my SQL statement...

But how on earth do you get form values in PHP to be put into a mySQL database.

It would be ideal if there were a script out there, written in PHP that collects all the form data and puts it into a nice SQL string for insertion... Assuming of course that the field names in the form are the same as the column names in the table.

Any chance I'd get lucky on this one?

Thanks if so~
~ Speedster



 11:38 am on Nov 5, 2001 (gmt 0)

PHP will automatically place form values into variables, so you don't need to worry about retrieving the contents of the form.

Say you had form fields called 'foo', 'bar' and 'baz' that you wanted to insert into a table 'widgets' with columns 'one', 'two' and 'three', your PHP would look something like:

$query="INSERT INTO widgets (one, two, three) VALUES ('$foo', '$bar', '$baz')";
mysql_query($query, $mysql_link);

Hope this helps

SEO Speedster

 2:20 pm on Nov 5, 2001 (gmt 0)

thank you sugarkane! I will make an attempt at the script again later today when more time becomes available - of course it's a monday! ;)

Again, much thanks.
~ Speedster

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved