Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Sep 2012
    Posts
    2
    Thanks
    0
    Thanked 1 Time in 1 Post

    Unhappy Html get post method

    I have created a webpage and am send the user data through get/post method. but i don't know that on next page how to capture that data and dsiplay it. Kindly help.

    i have send data through this code

    Code:
    <html>
    
    <head>
    
    <title>Employee Details</title>
    </head>
    
    <body>
    <form name="input" target="_blank" action="new_page_1.htm" method="post">
    <p>Employee Details</p>
    <p>Name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <!--webbot bot="Validation" s-display-name="Name" s-data-type="String" b-allow-letters="TRUE" b-allow-whitespace="TRUE" --><input type="text" name="T1" size="30"></p>
    <p>Designation:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="text" name="T2" size="30"></p>
    <p>Salary:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <!--webbot bot="Validation" s-display-name="Salary" s-data-type="Number" s-number-separators=",." --><input type="text" name="T3" size="30"></p>
    <p>Mobile:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <!--webbot bot="Validation" s-display-name="Mobile Number" s-data-type="Integer" s-number-separators="x" b-value-required="TRUE" i-minimum-length="10" i-maximum-length="10" --><input type="text" name="T4" size="30" maxlength="10"></p>
    <input type="Submit" name="B1" value= "Submit"> <input type="reset" onClick="return confirm('Are you sure you want to reset the form?')" value="Reset" name="B2"></p>
      
    </form>
    </body>
    
    
    
    
    
    
    </html>

  2. Users who have thanked coolguyvarun01 for this post:

    Derricks (09-18-2012)

  • #2
    New Coder
    Join Date
    Sep 2012
    Location
    Murcia, Spain
    Posts
    21
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Hi there, on the page you are posting to -> "new_page_1.htm"

    you first need to call the page "new_page_1.php" if your wishing to send it through POST or GET

    Then the code that would be on this new page for you to caputre it would be:

    if(isset($_POST['B1'])){

    $variable1 = $_POST['T1'];
    $variable2 = $_POST['T2'];
    $variable3 = $_POST['T3'];
    $variable4 = $_POST['T4'];

    }

    This is how you capture your data...

    user "echo $variable1" for example to display the data on the screen once posted.

  • #3
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,677
    Thanks
    6
    Thanked 1,008 Times in 981 Posts
    Note that it doesn’t have to be PHP but the form data has to be processed by some server side script, be it ASP.NET, PHP, JSP, ColdFusion, or whatever. Static HTML alone can’t do this.

  • #4
    New to the CF scene
    Join Date
    Sep 2012
    Posts
    2
    Thanks
    0
    Thanked 1 Time in 1 Post

    Smile

    Guys issue is Solved.
    But now my senior wants me to save the data Entered in user forms to be saved in a text file. any help on that???

    Also I don't have to use PHP or ASP. it has to be done with the use of Javascript and/Or HTML.

    I have done this

    Source Page

    Code:
    <html>
    
    <head>
    
    <title>Employee Details</title>
    </head>
    
    <body>
    <form name="Form1" target="_blank" action="destination.htm" method="get" onsubmit="return FrontPage_Form1_Validator(this)" language="JavaScript">
    <p>Employee Details</p>
    <p>Name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <!--webbot bot="Validation" s-display-name="Name" s-data-type="String" b-allow-letters="TRUE" b-allow-whitespace="TRUE" --><input type="text" name="T1" size="30"></p>
    <p>Designation:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="text" name="T2" size="30"></p>
    <p>Salary:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <!--webbot bot="Validation" s-display-name="Salary" s-data-type="Number" s-number-separators=",." --><input type="text" name="T3" size="30"></p>
    <p>Mobile:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <!--webbot bot="Validation" s-display-name="Mobile Number" s-data-type="Integer" s-number-separators="x" b-value-required="TRUE" i-minimum-length="10" i-maximum-length="10" --><input type="text" name="T4" size="30" maxlength="10"></p>
    <input type="Submit" name="B1" value= "Submit"> <input type="reset" onClick="return confirm('Are you sure you want to reset the form?')" value="Reset" name="B2"></p>
      
    </form>
    </body>
    
    
    
    
    
    
    </html>
    Destination Page

    Code:
    <html>
    <head>
    <!-- head stuff -->
    <script type="text/javascript">
    <!-- hide from old browsers
    
    function getValue(varname)
    {
      // First, we load the URL into a variable
      var url = window.location.href;
    
      // Next, split the url by the ?
      var qparts = url.split("?");
    
      // Check that there is a querystring, return "" if not
      if (qparts.length == 0)
      {
        return "";
      }
    
      // Then find the querystring, everything after the ?
      var query = qparts[1];
    
      // Split the query string into variables (separates by &s)
      var vars = query.split("&");
    
      // Initialize the value with "" as default
      var value = "";
    
      // Iterate through vars, checking each one for varname
      for (i=0;i<vars.length;i++)
      {
        // Split the variable by =, which splits name and value
        var parts = vars[i].split("=");
        
        // Check if the correct variable
        if (parts[0] == varname)
        {
          // Load value into variable
          value = parts[1];
    
          // End the loop
          break;
        }
      }
      
      // Convert escape code
      value = unescape(value);
    
      // Convert "+"s to " "s
      value.replace(/\+/g," ");
    
      // Return the value
      return value;
    }
    
    // end hide -->
    </script>
    <title>Destination Page</title>
    </head>
    <body>
    <h1>Data Entered is <br></h1>
    <h3>
    <script type="text/javascript">
    <!-- hide
    var name = getValue("T1");
    var desi = getValue("T2");
    var sala = getValue("T3");
    var mob = getValue("T4");
    document.write("Name  " +name +"   ");
    document.write("Designation   "+desi +"   ");
    document.write("Salary   " +sala +"   ");
    document.write("Mobile Number " +mob +"   ");
    // end hide -->
    </script>
    </h3>
    </body>
    </html>

  • #5
    Registered User
    Join Date
    Jun 2011
    Posts
    1,063
    Thanks
    12
    Thanked 241 Times in 240 Posts
    Quote Originally Posted by coolguyvarun01 View Post
    But now my senior wants me to save the data Entered in user forms to be saved in a text file. any help on that???

    it has to be done with the use of Javascript and/Or HTML.
    Unfortunately, you cannot do this without a server-side language. JavaScript and HTML are client-side, meaning they have nothing to do with saving information or interacting with your server.

    Accomplishing this in PHP is very simple:

    PHP Code:
    $data $_GET['username'] . $_GET['password'];
    file_put_contents("users.txt"$dataFILE_APPEND LOCK_EX); 
    http://www.w3schools.com/php/func_fi...t_contents.asp

    You should also look into using a mySQL database, like phpmyadmin, saving information in a text file is not very efficient or safe.
    I honestly can't think of many reasons why you would want to save information in a text file or not use PHP for that matter...
    Last edited by Sammy12; 09-19-2012 at 07:03 AM.


  •  

    Posting Permissions

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