Scud Posted March 20, 2008 Share Posted March 20, 2008 Hey guys; i dont have much knowledge about mysql and php as such, however i was wondering if it was possible and how to do it, so that if a user enters details in a form field on my webpage, what code i need to send this data to the database as well as if someone wants to call up their data by entering a code and it bring up the info stored in a field in the database. Please as simple as possible, lol Thanks Link to comment https://forums.phpfreaks.com/topic/97047-mysql-database-and-html-fields/ Share on other sites More sharing options...
berridgeab Posted March 20, 2008 Share Posted March 20, 2008 Simply Google PHP tutorials and start reading for a couple of hours, past programming experience would be a bonus (VB, C++, Java) as the language is similar to these. I could post a script, but if you want to implement it correctly and understand how it works your much better learning the tutorials and coming up with your own script. What your asking is a very easy thing to learn, it gets more complex when you have to learn about Security, etc. Link to comment https://forums.phpfreaks.com/topic/97047-mysql-database-and-html-fields/#findComment-496612 Share on other sites More sharing options...
huhn_m Posted March 20, 2008 Share Posted March 20, 2008 You should read up on some simple SQL Tutorials Assuming you have a Database and are connected. The database has a table with users (ID,Name,Surname) And you have a form that directs to the folowing PHP file. The form has the fields "Name" and "Surname" and submits using "POST". $name = $_POST["Name"]; $surname = $_POST["Surname"]; $query = "INSERT INTO users (Name,Surname) VALUES ('$name','$surname')"; mysql_query($query) or die("Error inserting ".mysql_error()); echo "Your magic user ID is: ".mysql_inser.id(); To get the user info let them input their ID (in a form field named id) and post the form to a PHP file like this: $id = $_POST["id"] $query = "SELECT * FROM users WHERE ID='$id'"; $result = mysql_query($query) or die("Error reading Data! ".mysql_error()); $values = mysql_fetch_assoc($result); echo "You are ".$values["Name"]." ".$values["Surname"]; Link to comment https://forums.phpfreaks.com/topic/97047-mysql-database-and-html-fields/#findComment-496621 Share on other sites More sharing options...
berridgeab Posted March 20, 2008 Share Posted March 20, 2008 Dont use the above script for a Public site though as it is Vunerable to all sorts of Malious attacks (MySQL Injection, etc). YOu'd have to parse the data sent by the user first in order for it to be put in a database securely. Link to comment https://forums.phpfreaks.com/topic/97047-mysql-database-and-html-fields/#findComment-496632 Share on other sites More sharing options...
Scud Posted March 20, 2008 Author Share Posted March 20, 2008 thanks for the quick responses. i have vb experience only. its all so confusing, could somebody please write up a pretty secure script so i can read and write to the database, im lost! also what code do i put in the html file to say when the submit button is clicked send the data to database? Link to comment https://forums.phpfreaks.com/topic/97047-mysql-database-and-html-fields/#findComment-496650 Share on other sites More sharing options...
clown[NOR] Posted March 20, 2008 Share Posted March 20, 2008 could somebody please write up a pretty secure script so i can read and write to the database, im lost! i think that's a job for the Freelance section of these forums.. this section is for people who want's to make their own script but need some guidance Link to comment https://forums.phpfreaks.com/topic/97047-mysql-database-and-html-fields/#findComment-496658 Share on other sites More sharing options...
Scud Posted March 20, 2008 Author Share Posted March 20, 2008 i could do with some guidance too in that case, im really new to php Link to comment https://forums.phpfreaks.com/topic/97047-mysql-database-and-html-fields/#findComment-496674 Share on other sites More sharing options...
Scud Posted March 20, 2008 Author Share Posted March 20, 2008 how do you parse data sent through? Link to comment https://forums.phpfreaks.com/topic/97047-mysql-database-and-html-fields/#findComment-497145 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.