Sending form data to PHP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • amrsor
    New Member
    • Aug 2007
    • 1

    Sending form data to PHP

    how can I write a php code to from HTML form to send parameters to web server
  • gregerly
    Recognized Expert New Member
    • Sep 2006
    • 192

    #2
    Originally posted by amrsor
    how can I write a php code to from HTML form to send parameters to web server
    This can be done several ways. I'm going to assume that you are just beginning with PHP so I'm going to give you some basics to research on your own.

    1. Forms - The main way to get user data into your scripts is by the use of HTML forms. Forms have one of two actions, GET and POST. POST sends the data in the forms behind the scenes, while GET adds the data to the URL of the accepting page.

    EX: [HTML]<form action='myphpsc ript.php' method='post'>
    <form action='myphpsc ript.php' method='get'>[/HTML] You then access the post values in your action script using the POST / GET array. Like this: [PHP]<?=$_POST['fieldname']; ?>
    <?=$_GET['fieldname']; ?>[/PHP] which would echo out the field value.

    2. Sessions - You can set session variable using the $_SESSION super global.

    EX: [PHP]<? $_SESSION['fname']='bob'; ?> [/PHP] which sets a session variable of fname with a value of bob. Remember you must use a [PHP]session_start()[/PHP] at the top of every page in which you want to access session variables.

    Hope that helps!

    Greg
    Last edited by pbmods; Aug 21 '07, 04:00 AM. Reason: Remove edit reason. Sorry, G. Not safe for kids.

    Comment

    • ak1dnar
      Recognized Expert Top Contributor
      • Jan 2007
      • 1584

      #3
      Originally posted by amrsor
      how can I write a php code to from HTML form to send parameters to web server
      Read this article too which created by Atli.
      Thanks

      Comment

      • pbmods
        Recognized Expert Expert
        • Apr 2007
        • 5821

        #4
        Changed thread title to better describe the problem.

        Comment

        Working...