How Can I post a registration form by HTML code?
Normally you send input from a HTML form back to a server-side script, specified in the form’s action attribute.
The script will then do something with the input it receives, such as store it in a database.
E.g.
<form action="myScript.php" method="post">
...some form stuff here...
</form>
If you want a simple form to email script then [URL=“http://uk.search.yahoo.com/search?fr=mcafee&p=form+to+email+scripts”]there are plenty of ready made scripts about.
<form action="registration.php" method="post">
<input type='text' name='fname' />
</form>
registration.php
mail("your@email.com","The Registration" ,"Submitted by $fname") ;
Whoa! First off, please try not to use w3schools.com for any examples, they are notorious for using insecure examples.
For example the following problems exist with the code chunk above.
- It assumes register globals is enabled, register globals should NEVER be enabled, it is such a security risk the PHP developers eventually removed the feature all together.
- It performs no validation, minor as it may be, this is necessary when wanting to prevent XSS and CSRF attacks
An updated example:
<form action="registration.php" method="post">
<input type='text' name='fname' />
</form>
registration.php
$fname = filter_var($_POST['fname'], FILTER_SANITIZE_STRING);
mail("your@email.com","The Registration" ,"Submitted by $fname") ;
You can read more about [fphp]filter_var[/fphp] on the PHP manual and the type of filters as well.