0

I have a form for a website where people can make orders. I have a form with the correct inputs and a submit button. The thing is, i don't really know what ways there are for me to get that info that the user has typed in. Should it create a txt file or should the info be sent to me via email? In that case how? I haven't used php at all and would like to avoid it for now if possible...

This is the form

HTML

<form id="TheForm"> <div id="Row"> <input type="text" id="Name" placeholder="*Förnamn" required> <input type="text" id="Surname" placeholder="*Efternamn" required> </div> <div id="Row"> <input type="email" id="FirstEmail" placeholder="*e-postadress" autocomplete="on" required> <input type="email" id="SecondEmail" placeholder="*Verifiera e-postadress" autocomplete="off" required> </div> <div id="Row"> <input type="text" id="Town" placeholder="*Ort" required> </div> <div id="Row"> <input type="text" id="Address" placeholder="*Adress" required> </div> <div id="Row"> <input type="text" id="PostCode" placeholder="*Postnummer" required> </div> <div id="Row"> <input type="text" id="MobileNumber" placeholder="*Mobilnummer" required> <input type="text" id="TelephoneNumber" placeholder="Telefonnummer"> </div> <textarea id="Comment" placeholder="Förslag på hur vi skulle kunna förbättra oss!"></textarea> <input type="submit" id="Submit" value="Skicka"> </form> 

ps. The placeholders are in swedish so don't worry about that ;)

2
  • This link should be a good resource for you. It breaks down the process of sending/retrieving form data and the different ways to handle it. developer.mozilla.org/en-US/docs/Web/Guide/HTML/Forms/… Commented Nov 25, 2013 at 22:46
  • Thanks mate! feel like thats a good place to start :D Commented Nov 25, 2013 at 22:48

3 Answers 3

2

Don't get intimidated by PHP it's so many ressource out there to help you if you decide to chose it then you can use either POST or GET:

POST

HTML:

<form id="TheForm" action="data.php" method="POST"> <input type="text" id="Surname" placeholder="*Efternamn" required> 

PHP:

$surname = $_POST["Surname"]; echo $surname; 


GET

HTML:

<form id="TheForm" action="data.php" method="GET"> <input type="text" id="Surname" placeholder="*Efternamn" required> 

PHP:

$surname = $_GET["Surname"]; echo $surname; 
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! wasn't expecting this much help! really awesome!
1

php is by far the easiest way

first off, add a name attribute to all your html input fields like this:

<input name="surname" type="text" id="Surname" placeholder="*Efternamn" required>` 

also add metode & action to your form:

<form action="some_php_file.php" metode="POST" id="TheForm"> 

then in your php you can do like this:

<?PHP //get data from html, using the post metode $name = $_POST['name']; $surname = $_POST['surname']; //specify a txt file $file = 'people.txt'; // Open the file to get existing content $current = file_get_contents($file); // Append a new person to the file $current .= $name." ".$surname.PHP_EOL; // Write the contents back to the file file_put_contents($file, $current); ?> 

This is a very simple example, just to get you startet. By the way, PHP_EOL is a linebreak

Comments

0

For as far as I know is PHP by far the best for communicating between a server and a client (when using a form for example). You could indeed maybe use javascript for making a txt file and mailing it but that would be a bit of overkill i think. Cheers!

3 Comments

I guess so.. was hoping to avoid it but i'll trust you ;)
PHP is probably the best, but avoid w3schools like the plague. If you're interested you can read about why here: w3fools.com
removed the w3schools part :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.