• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 193
  • Last Modified:

Simple FORM POST in HTML

I'd like to create a test FORM POST in HTML.  Meaning, the page I'm posting to is HTML.  I only want it to display the information from a single textbox.  Is that possible?

If not, can someone post some PHP code that is able to do this?
0
brettr
Asked:
brettr
2 Solutions
 
john-formbyCommented:
If you are posting to another page, you will need some sort of scripting language.  It is not possible to do with just HTML.

Please have a look at the following simple example.

Hope this helps,

John
page1.php
=========
<html>
<head>
<title>Page 1</title>
</head>
<body>
<?php
$err = $_GET['err'];
if($err == 1) {
	echo 'Error: No Username entered';
}
?>
<form action="page2.php" method="post">
Username: <input type="text" name="username" />
<input type="submit" name="submit" value="Submit" /> 
</form>
</body>
</html>




page2.php
=========
<?php
if(isset($_POST['submit'])) {
	$username = mysql_real_escape_string($_POST['username']);
	if($username == '') {
		header('Location: page1.php?err=1');
	} elseif($username != '') {
		echo '<html>
		<head>
		<title>Page 1</title>
		</head>
		<body>
		Username entered was: '.$username.'
		</body>
		</html>';
	}
}
?>

Open in new window

0
 
Mahdi78Commented:
PHP reg.php

<?
  echo '<b>Your username:</b>'.$_POST['user_name'];
?>

HTML

<form action="reg.php" method="post">
<input type="text" name="user_name">
<input type="submit" />
</form>
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now