pancgom Posted January 18, 2008 Share Posted January 18, 2008 Hi Guys, I am trying to build a form in php to insert data into mysql database. The fields can be name, staff number, department for a start. Can some one please give me a script to do this and also to display the data from the database on to a php page. Any help much appreciated. Please help. Thanks Guys. Quote Link to comment https://forums.phpfreaks.com/topic/86630-php-form/ Share on other sites More sharing options...
adam291086 Posted January 18, 2008 Share Posted January 18, 2008 People here will not write code for you. If you dont want to do it try the freelancing forum. Use google to find some tutorials. Then if you face any problems then post them here Quote Link to comment https://forums.phpfreaks.com/topic/86630-php-form/#findComment-442676 Share on other sites More sharing options...
pdkv2 Posted January 18, 2008 Share Posted January 18, 2008 it is worth to write the code on your own coz the ppl here are discussing the problems the face in the coding the php stuff Quote Link to comment https://forums.phpfreaks.com/topic/86630-php-form/#findComment-442678 Share on other sites More sharing options...
pancgom Posted January 18, 2008 Author Share Posted January 18, 2008 Alright guys..thanks Quote Link to comment https://forums.phpfreaks.com/topic/86630-php-form/#findComment-442802 Share on other sites More sharing options...
Malevolence Posted January 18, 2008 Share Posted January 18, 2008 What a horrible bunch. I can't believe how unhelpful that is... Anyway, here you go: name staff number department <?php $db_host = "localhost"; $db_user = "Database Username Here"; $db_pwd = "Database Password Here"; $db_name = "Database Name Here"; mysql_connect($db_host, $db_user, $db_pwd); mysql_select_db($db_name); ?> <h2>Database Submission Form</h2> <?php if (!isset($_POST['submit'])) { ?> <form action="" method="post"> <p>Name:<br> <input type="text" name="name" id="name"></p> <p>Staff Number:<br> <input type="text" name="staffnumber" id="staffnumber"></p> <p>Department:<br> <input type="text" name="department" id="department"></p> <input type="submit" name="submit" value="Submit New Item"> <input name="reset" type="reset" id="reset2" value="Clear Form"> </form> <?php } else { $name = $_POST['name']; $staffnumber = $_POST['staffnumber']; $department = $_POST['department']; mysql_query("INSERT INTO `tablenamehere` (name, staffnumber, department) VALUES ('$name', '$staffnumber', '$department')"); echo "Successfully Submitted!"; } ?> The Above code is a simple form that submits data to the chosen database and table. Change the values where needed. OK, so now we need to SHOW the data that is in the database. I'm not sure what format you want this in, so I'll put it in a table. ILL FINISH THIS LATER Quote Link to comment https://forums.phpfreaks.com/topic/86630-php-form/#findComment-442860 Share on other sites More sharing options...
pancgom Posted January 19, 2008 Author Share Posted January 19, 2008 Thanks a million Malevolence...i am a new bie to php and learning it still. I had an urgent need of this form though simple but me completely clueless. I understand the other 2 they just wanted me to learn which i am. Atleast i know i can get help is some form. Again thank you thank you thank you guys. Quote Link to comment https://forums.phpfreaks.com/topic/86630-php-form/#findComment-443328 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.