Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-18-2012, 10:36 AM   PM User | #1
coolguyvarun01
New to the CF scene

 
Join Date: Sep 2012
Posts: 2
Thanks: 0
Thanked 1 Time in 1 Post
coolguyvarun01 is an unknown quantity at this point
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>
coolguyvarun01 is offline   Reply With Quote
Users who have thanked coolguyvarun01 for this post:
Derricks (09-18-2012)
Old 09-18-2012, 10:45 AM   PM User | #2
vnbenny88
New Coder

 
Join Date: Sep 2012
Posts: 11
Thanks: 0
Thanked 1 Time in 1 Post
vnbenny88 is an unknown quantity at this point
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.
vnbenny88 is offline   Reply With Quote
Old 09-18-2012, 12:47 PM   PM User | #3
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,615
Thanks: 5
Thanked 865 Times in 842 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
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.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 09-19-2012, 06:47 AM   PM User | #4
coolguyvarun01
New to the CF scene

 
Join Date: Sep 2012
Posts: 2
Thanks: 0
Thanked 1 Time in 1 Post
coolguyvarun01 is an unknown quantity at this point
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>
coolguyvarun01 is offline   Reply With Quote
Old 09-19-2012, 06:54 AM   PM User | #5
Sammy12
Registered User

 
Join Date: Jun 2011
Posts: 1,063
Thanks: 12
Thanked 241 Times in 240 Posts
Sammy12 is on a distinguished road
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..
Sammy12 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:29 PM.


Advertisement
Log in to turn off these ads.