Forums
This topic is locked
Submit forms in DreamWeaver MX
Posted 15 Dec 2002 09:54:02
1
has voted
15 Dec 2002 09:54:02 semmie Brandenburg posted:
I have to make a simple submit form. People must be able to insert online things like...name, sexe, e-mail etc. press submit and then I have to get all the inserted information per e-mail. And if not to complicated I would like to send the server a message back to the sender that I received everything.I know how to make a form inside DreamWeaver MX but then?? Do you have to use scripts? I have no idea so hope somebody can help me. Maybe there are some good tutorials?
Thanks
Replies
Replied 16 Dec 2002 05:35:11
16 Dec 2002 05:35:11 Cory Marchasin replied:
Since no-body has responded to my question I posted and I know the answers to yours, I figure karma states I should help you I want to be helped,...so here goes.
You didnt say what you needed to do with the data you received once it was stored, but I am assuming you just want to complie some sort of "member list".
I am also assuming that you are going to store this information into a database. I know/understand the php/MySql model so that is what I will present.
You need to set up a MySql databse on your server. Ask your server admin, or isp or wherever your site is hosted to set one up for you (if you havent already). Often MySql will have a "Admin" Page "/My_Sql_Admin,.. or something similiar) Ask your server admin about this because it makes it real easy to set up the columns in the table you will be storing your data in.
You mentioned that you neede to enter info like "Name, email, sex, favorite food etc..," . These will be the names of your columns in the table you create. You should be able to define all of the column data as "varchar" unless you are going to have to use the data to do some math, or add a shit-load of text. Like "please tell us about yourself", inj which case you will want to use "longtext". Confused already? Look up MySql tutorials in GOOGLE, or buy the book "PHP and MySql for dummies."
keep the names of your columns real simple, because you will need them to be exactly the same in the "form fields" of your html page.
You know where it says textfield after you insert a form field, and underneath the default name is "textfield" also? Change the name to the corresponding "Columnname " in your database table. like "name or email"
Try to keep your entire form in one table, including the submit button. When you look at thye code at the beginning of your form you will see:
<form name="form1" method="post" action="">
we need to assign an action to this form so we can get this info your user has filled out into the database. Lets say the script we are about to write is add_data.php you will make the action of the form action="send_data.php". Just make sure this file we are about to write is in the same directory, otherwise include the path when you assign the action "badassSite/funkyform/send_data.php"
So know when they hit "submit" the information will be sent to this php file called send_file.php so we had better make sure one exists.
So,... send_data.php has to do 3 things. 1)Connect with the database, 2)insert the data into the correct columns,3) let the user know thier info has been added and/or send them back to a place where they can continue navigating your kick_ass site.
I am just going to write out the script with the info you need to add with "** " in the spots where you need to add information you get (or have) about your admin info for your database.
<?php
$hostname= "**localhost";
$database= "**database_name";
$username= "*user_name";
$password= "**password";
$database
mysql_select_db($database,$databasename)
or die ("Couldnt connect to database"
/* Clean the Data*/
$mlsnumber = strip_tags(trim($mlsnumber));
$listingtitle = strip_tags(trim($listingtitle));
$description = strip_tags(trim($description));
$price = strip_tags(trim($price));
$pic = strip_tags(trim($pic));
$acres = strip_tags(trim($acres));
/* Insert your data into the database*/
$query = "INSERT INTO land (name,email,description,favoritefood,shoesize,address)
VALUES
('$name','$email','$description','$favoritefood','$shoesize','$address')";
$result = mysql_query($query)
or die ("Couldnt execute query."
/*Show data added*/
echo "Hey,.. you entered the following data into member info,...or whatever:<br><br>
name = $name <br><br>
email = $email <br><br>
description = $description <br><br>
/* etc.. with as many columns as you need to show*/
/* give user a link back to wherever*/
echo "<a href='**home.html'> Go Back to home Page</a>";
?>
There are great features in DreamWEaver MX that will write alot of this code for you. Especially the "connect to database" bit at the beginning. Go to window->databases, and add a new databse and insert all the admin info and you can just drag and drop th database into the new file. It writes the connect code for you and everything. It will even write which table you are trying to connect to. Get a comprehensive Dreamweaver MX book for all the functions.
This should get you started. We havent discussed any cool ways to display or search through the data you compile, but that is another topic altogether.
It seems complex, but it is actually an easy way to get you started using these PHP and MySql functions in your site.
Its probably going to take you a bit to wrap your brain around how all this works, but keep at it, and buy some good books, ol do mad tutorials on-line.
I took the time to write this, so at least take the time to use the info to get yourself started dammit.
You didnt say what you needed to do with the data you received once it was stored, but I am assuming you just want to complie some sort of "member list".
I am also assuming that you are going to store this information into a database. I know/understand the php/MySql model so that is what I will present.
You need to set up a MySql databse on your server. Ask your server admin, or isp or wherever your site is hosted to set one up for you (if you havent already). Often MySql will have a "Admin" Page "/My_Sql_Admin,.. or something similiar) Ask your server admin about this because it makes it real easy to set up the columns in the table you will be storing your data in.
You mentioned that you neede to enter info like "Name, email, sex, favorite food etc..," . These will be the names of your columns in the table you create. You should be able to define all of the column data as "varchar" unless you are going to have to use the data to do some math, or add a shit-load of text. Like "please tell us about yourself", inj which case you will want to use "longtext". Confused already? Look up MySql tutorials in GOOGLE, or buy the book "PHP and MySql for dummies."
keep the names of your columns real simple, because you will need them to be exactly the same in the "form fields" of your html page.
You know where it says textfield after you insert a form field, and underneath the default name is "textfield" also? Change the name to the corresponding "Columnname " in your database table. like "name or email"
Try to keep your entire form in one table, including the submit button. When you look at thye code at the beginning of your form you will see:
<form name="form1" method="post" action="">
we need to assign an action to this form so we can get this info your user has filled out into the database. Lets say the script we are about to write is add_data.php you will make the action of the form action="send_data.php". Just make sure this file we are about to write is in the same directory, otherwise include the path when you assign the action "badassSite/funkyform/send_data.php"
So know when they hit "submit" the information will be sent to this php file called send_file.php so we had better make sure one exists.
So,... send_data.php has to do 3 things. 1)Connect with the database, 2)insert the data into the correct columns,3) let the user know thier info has been added and/or send them back to a place where they can continue navigating your kick_ass site.
I am just going to write out the script with the info you need to add with "** " in the spots where you need to add information you get (or have) about your admin info for your database.
<?php
$hostname= "**localhost";
$database= "**database_name";
$username= "*user_name";
$password= "**password";
$database
mysql_select_db($database,$databasename)
or die ("Couldnt connect to database"
/* Clean the Data*/
$mlsnumber = strip_tags(trim($mlsnumber));
$listingtitle = strip_tags(trim($listingtitle));
$description = strip_tags(trim($description));
$price = strip_tags(trim($price));
$pic = strip_tags(trim($pic));
$acres = strip_tags(trim($acres));
/* Insert your data into the database*/
$query = "INSERT INTO land (name,email,description,favoritefood,shoesize,address)
VALUES
('$name','$email','$description','$favoritefood','$shoesize','$address')";
$result = mysql_query($query)
or die ("Couldnt execute query."
/*Show data added*/
echo "Hey,.. you entered the following data into member info,...or whatever:<br><br>
name = $name <br><br>
email = $email <br><br>
description = $description <br><br>
/* etc.. with as many columns as you need to show*/
/* give user a link back to wherever*/
echo "<a href='**home.html'> Go Back to home Page</a>";
?>
There are great features in DreamWEaver MX that will write alot of this code for you. Especially the "connect to database" bit at the beginning. Go to window->databases, and add a new databse and insert all the admin info and you can just drag and drop th database into the new file. It writes the connect code for you and everything. It will even write which table you are trying to connect to. Get a comprehensive Dreamweaver MX book for all the functions.
This should get you started. We havent discussed any cool ways to display or search through the data you compile, but that is another topic altogether.
It seems complex, but it is actually an easy way to get you started using these PHP and MySql functions in your site.
Its probably going to take you a bit to wrap your brain around how all this works, but keep at it, and buy some good books, ol do mad tutorials on-line.
I took the time to write this, so at least take the time to use the info to get yourself started dammit.
Replied 16 Dec 2002 05:43:16
16 Dec 2002 05:43:16 Cory Marchasin replied:
Whoops!,... I forgot to augment part of my original script (*burnout*).
ignore the variables added in the "strip tags" part.
/* Clean the Data*/
$mlsnumber = strip_tags(trim($mlsnumber));
$listingtitle = strip_tags(trim($listingtitle));
$description = strip_tags(trim($description));
$price = strip_tags(trim($price));
$pic = strip_tags(trim($pic));
$acres = strip_tags(trim($acres));
obviosly the $things are your form variables and shold correspond to the names of your formFields and Column names. you can leave that whole part out if you want, but it stops future programs from getting confused when you get the info out with PHP. Or from Terrorists from screwing with you buy using your forms to upload weird malicious scripts.
I am sure my mistake adds to your confusion, but I am trying over here!,....
geez,... maybe I should just keep my help to myself,... (*sulk*)
ignore the variables added in the "strip tags" part.
/* Clean the Data*/
$mlsnumber = strip_tags(trim($mlsnumber));
$listingtitle = strip_tags(trim($listingtitle));
$description = strip_tags(trim($description));
$price = strip_tags(trim($price));
$pic = strip_tags(trim($pic));
$acres = strip_tags(trim($acres));
obviosly the $things are your form variables and shold correspond to the names of your formFields and Column names. you can leave that whole part out if you want, but it stops future programs from getting confused when you get the info out with PHP. Or from Terrorists from screwing with you buy using your forms to upload weird malicious scripts.
I am sure my mistake adds to your confusion, but I am trying over here!,....
geez,... maybe I should just keep my help to myself,... (*sulk*)
Replied 16 Dec 2002 08:59:48
16 Dec 2002 08:59:48 semmie Brandenburg replied:
Amazing!! I appreciate this very much. That people take such a long time to help others. Its just great.
But.....maybe I didnt was clear about what I precise wanted. It is gonna be a inquiry form. The most important information is how many people are filling out the form. I suppose that is much more easier. They fill out the inquiry and the form will send to my inbox.
Dont feel that you gave all your imformation for nothing because I think it is even better the way you described. And you can use your knowledge for much more applications. So I will find some books about it. And yes you helped me on the right track. Thanks for that.<b></b><u></u>
But.....maybe I didnt was clear about what I precise wanted. It is gonna be a inquiry form. The most important information is how many people are filling out the form. I suppose that is much more easier. They fill out the inquiry and the form will send to my inbox.
Dont feel that you gave all your imformation for nothing because I think it is even better the way you described. And you can use your knowledge for much more applications. So I will find some books about it. And yes you helped me on the right track. Thanks for that.<b></b><u></u>