I am new to this kind of things... I need to submit the data in 3 text areas to another page...
How do I do that?
P.S. I would have used inputs, if I could.
You need to create your page with form... For example call it form.html use this code for example:
<form id="form1" name="form1" method="post" action="acceptpage.php">
<input type="text" name="input" id="textfield" />
<textarea name="text" id="textarea" cols="45" rows="5"></textarea>
<input type="submit" name="button" id="button" value="Send" />
</form>
After that create page called acceptpage.php Put this in between body tags
<?php
$frominput = $_POST[input]; // Variable who accept your data from input
$fromtextarea = $_POST[text]; // Variable who accept your data from textarea
// You don't need to use variables, but if you starter, easier to understand.
// Do something with your arrived data...
// Stupid, but for short explanation... for example echo it...
echo $fromtextarea;
echo $frominput;
?>
Of course, you can send data with html, but you can't accept data, for accepting data you need a programming language like php. I use php above to show you how it works...
Edit...(I just now saw that you want to you put the data into the database)... Here is code:
<?php
$frominput = mysql_real_escape_string($_POST[input]);
$fromtextarea = mysql_real_escape_string($_POST[text]);
// Do something with your arrived data...
$query = mysql_query("INSERT INTO table (rowforinput, rowfortextarea) VALUES
('$frominput','$fromtextarea')") or die (mysql_error());
?>
As you can see, there are little modifications at variables which accept data, I called mysql_real_escape_string function, to make data more secure. If you want to learn more about mysql_real_escape_string function, mysql_real_escape_string
Don't forget that first you make a connection to the database. For it I usually make my own function:
function connect_db() {
mysql_connect("localhost", "username", "password");
mysql_select_db("database");
}
And call function with <?php connect_db(); ?>
UPDATE 03.15.2015
A lot of changes since 2011 in PHP. Function mysql_connect will be deprecated in future. Use mysqli or PDO instead.
Reference:
mysql_connect deprecated
MySQL Improved Extension (Mysqli)
PHP Data Objects Interface (PDO)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With