SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: form

  1. #1
    SitePoint Member
    Join Date
    Oct 2012
    Location
    Chittogong, Bangladesh
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cool form

    How Can I post a registration form by HTML code?

  2. #2
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,941
    Mentioned
    215 Post(s)
    Tagged
    12 Thread(s)
    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.
    HTML Code:
    <form action="myScript.php" method="post">
    ...some form stuff here...
    </form>

  3. #3

  4. #4
    SitePoint Addict Shaydez's Avatar
    Join Date
    Jul 2006
    Location
    Boca Raton, Florida
    Posts
    356
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    HTML Code:
    <form action="registration.php" method="post">
     <input type='text' name='fname' />
    </form>
    registration.php
    PHP Code:
    mail("your@email.com","The Registration" ,"Submitted by $fname") ; 

    http://www.w3schools.com/php/php_mail.asp
    Sr. Website Developer and Internet Marketing
    www.CarlosJa.com Note: If anyone
    needs to get ahold of me please feel free to email me through
    my site. Apparently i missed quite a few private messages.

  5. #5
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,164
    Mentioned
    153 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Shaydez View Post
    HTML Code:
    <form action="registration.php" method="post">
     <input type='text' name='fname' />
    </form>
    registration.php
    PHP Code:
    mail("your@email.com","The Registration" ,"Submitted by $fname") ; 

    http://www.w3schools.com/php/php_mail.asp
    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.
    1. 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.
    2. It performs no validation, minor as it may be, this is necessary when wanting to prevent XSS and CSRF attacks


    An updated example:
    HTML Code:
    <form action="registration.php" method="post">
     <input type='text' name='fname' />
    </form>
    registration.php
    PHP Code:
    $fname filter_var($_POST['fname'], FILTER_SANITIZE_STRING);
    mail("your@email.com","The Registration" ,"Submitted by $fname") ; 
    You can read more about filter_var on the PHP manual and the type of filters as well.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •