+ 17

How to I submit data of my html program?

I have created "Student Info Form.html", which takes student info such as FName, rollNo, fees, mobile no. How to store its contents?

8th Mar 2017, 6:55 PM
Ajay Agrawal
Ajay Agrawal - avatar
33 Respostas
+ 28
index.html <form action="processdata.php" method="post"> <input type="text" name="info"> <button type="submit">Send data</button> </form> processdata.php // get the data $info = filter_input(INPUT_POST, 'info', FILTER_SANITIZE_SPECIAL_CHARS); // db connection $host = "localhost"; $dbname = "test"; $user = "root"; $pass = "password"; $conn = new PDO("mysql:host=$host;dbname=$dbname","$user","$pass"); // statement $stmt = $conn->prepare("INSERT INTO test (column_name) VALUES (?)"); $stmt->bind_param("s", $info); $stmt->execute();
8th Mar 2017, 9:56 PM
Patrik Sokol
Patrik Sokol - avatar
+ 16
If a local server is installed on your phone then yes. You need something like https://play.google.com/store/apps/details?id=ru.kslabs.ksweb on android
9th Mar 2017, 2:19 AM
Patrik Sokol
Patrik Sokol - avatar
+ 15
awesome guysšŸ˜Ž, but one more thing I wanna to know, will it work on phone or only PC?
9th Mar 2017, 1:30 AM
Ajay Agrawal
Ajay Agrawal - avatar
+ 15
to avoid mess in your database, limit user's freedom in text inputs as much as possible. Prefere select, raddio buttons, check boxes and limit to the minimum text areas as you may end up wondering how twisted is human fantasy when it comes to simple form filling. If text areas are indispensable like for name or email ecc... you can use regular expressions to evaluate the type of input enterd before submitting: for example you'd like to avoid user to enter numbers and special char in their name input; or you may want to define a pattern for the email input that expects text separated by at least an @ and a . chars without illegal chars. There is a very comprehensive tutorial about that on w3schools named php form input. consider this your primary filtering. People fantasy can mess up the standard you have in mind to manage the data on your db. after that, follow @Patrik Sokol instruction to avoid the risk of sql injection in your db. Setting up the server in your school to be accessible from the internet may involve port forwarding and firewall exeption that are intrinsic security flaws. you may want to consider an online hosting service. A free one that has what you need (http-php-sql) is 000webhost.com. Whatever option you chose, any(one) student will be able to connect to the web interface using a browser.
10th Mar 2017, 12:23 PM
seamiki
seamiki - avatar
+ 11
good joke @LeonšŸ˜Ž
13th Mar 2017, 8:23 AM
Ajay Agrawal
Ajay Agrawal - avatar
+ 10
@Isaac Adavize thank you for idea, I'm trying it now
11th Mar 2017, 9:53 PM
Ajay Agrawal
Ajay Agrawal - avatar
+ 9
Database.... U shud have one.... For now use wamp server
10th Mar 2017, 9:57 AM
Aravind
Aravind - avatar
+ 8
Big +1 for seamiki!
10th Mar 2017, 1:12 PM
Patrik Sokol
Patrik Sokol - avatar
+ 8
you need to create a processing script in php/asp/jsp or as you choice . then submit the data to the script by the Action attribute in form element of HTML. it looks like <form action ="check.php">
11th Mar 2017, 12:37 PM
Anik Hasibul
Anik Hasibul - avatar
+ 7
To collect data set a database.
12th Mar 2017, 5:35 PM
BBBB Ghh GgBB
+ 6
use <form action="filename.php" method="post" >...</form> where filename.php is the name of the file where you will process the form data. in this file extract the data using the superglobal $_POST. e.g to get FName use $_POST["FName"] and assign it to a variable that you can save.
8th Mar 2017, 7:43 PM
mwaka
+ 5
you need local server such as xampp or wamp and create database then create a table that will store input in the form you have created, search validate form register in w3school.com for tutorial
9th Mar 2017, 4:55 PM
Raji Abdulafeez Okikiola
Raji Abdulafeez Okikiola - avatar
+ 4
you need to create a processing script in php/asp/jsp or as you choice . then submit the data to the script by the Action attribute in form element of HTML. it looks like <form action ="check.php">
11th Mar 2017, 12:36 PM
Anik Hasibul
Anik Hasibul - avatar
+ 3
how can i learn every thing on html
9th Mar 2017, 4:58 PM
Negadi Moumen
Negadi Moumen - avatar
+ 3
<form action="executor.php" method="post"> take your form and button <input type="submit" value="submit"/> close the form with </form>
10th Mar 2017, 2:51 PM
Zainal Mubarok
Zainal Mubarok - avatar
+ 3
@Negadi, you can start by taking the HTML course, understand the basics, then progress to the more advance concepts
11th Mar 2017, 9:39 PM
Isaac Adavize
Isaac Adavize - avatar
+ 3
@Ajay, if you want to test your form page on your phone, you can install mobile applications like Palapa Web Server (PWS). It's a very cool app for devolopers
11th Mar 2017, 9:41 PM
Isaac Adavize
Isaac Adavize - avatar
+ 3
Post it to letterbox hahaha
12th Mar 2017, 2:31 AM
Leon
Leon - avatar
+ 3
you need a server side scripting language & connectivity to a database server like MySql & then go for scripting queries & connectivity queries
14th Mar 2017, 10:46 AM
Saurav Kumawat
Saurav Kumawat - avatar
+ 2
you may use form action and also submit button
11th Mar 2017, 12:07 PM
yaamini rajkumar
yaamini rajkumar - avatar