Get latest news and Web Designing tutoria

Friday, 29 May 2015

PHP and the Action Attribute of HTML Forms

The Action attribute is crucial. It means, "Where do you want the form sent?". If you miss it out, your form won't get sent anywhere. You can send the form data to another PHP script, the same PHP script, an email address, a CGI script, or any other form of script.
In PHP, a popular technique is to send the script to the same page that the form is on – send it to itself, in other words. We'll use that technique first, but you'll see both techniques in action.

So you need to change the form you have been creating in the previous section the one that should be called basicForm.php. Locate the following, and amend the ACTION line to this:
<Form Name ="form1" Method ="POST" ACTION = "basicForm.php">
So we're going to be sending the form data to exactly the same page as the one we have loaded – to itself. We'll put some PHP on the page to handle the form data. But for now, save your work again and then click your submit button. You won't see anything different, but you shouldn't see any error message either!
Once your script has an Action attribute set, you can then Submit it. Which we'll see in the next part.

Related Posts:

  • How to Set up a PHP Array First you type out what you want your array to be called ($Order_Number, in the array above) and, after an equals sign, you type this: array( ); So setting up an array just involves typing the word array followed by a p… Read More
  • PHP Functions What is a Function? A function is just a segment of code, separate from the rest of your code. You separate it because it's nice and handy, and you want to use it not once but over and over. It's a chunk of code that … Read More
  • Geting Values from Arrays Here's an example for you to try: <?php $seasons = array("Autumn", "Winter", "Spring", "Summer"); print $seasons[0]; ?> The array is the same one we set up before To get at what is inside of an array, just … Read More
  • PHP Functions and Arguments Arguments Functions can be handed variables, so that you can do something with what's inside of them. You pass the variable over to your functions by typing them inside of the round brackets of the function name… Read More
  • Sorting PHP Array values There may be times when you want to sort the values inside of an array. For example, suppose your array values are not in alphabetical order. Like this one: $full_name = array(); $full_name["Roger"] = "Wate… Read More

0 comments:

Post a Comment