Sunday, 9 April 2017

Display values from 1 form to another form




Index.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="JavaScript">
function url_validate(userUrl)
{
var regUrl = /^(((ht|f){1}(tp:[/][/]){1})|((www.))){1}[-a-zA-Z0-9@:%_\+.~#?&//=]+$/;
if(regUrl.test(userUrl) == false)
{
document.getElementById("status").innerHTML = "Website URL is not valid yet.";
}
else
{
document.getElementById("status").innerHTML = "You have entered a valid website URL!";
}
}
</script>
</head>
<body>
<form name="form1" method="post" action="demo.php">
<p>First Name<input type="text" name="name" value="" required="required"  />
Last Name<input type="text" name="last" value="" required="required" />
url<input type="text" name="url" value=""  onkeyup="url_validate(this.value);"/>
<em id="status"></em>
</p>
<p><input type="submit" name="sudmit" value="submit" /></p>
</form>
</body>
</html>

Demo.php

<?php
$name=$_POST['name'];
$last=$_POST['last'];
$url=$_POST['url'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form name="form2" method="post" action="">
<p>First Name<input type="text" name="name" value="<?php echo $name; ?>" />
Last Name<input type="text" name="last" value="<?php echo $last ?>" />
<a href="<?php echo $url; ?>"><?php echo $url; ?></a>
</p>
<p><input type="submit" name="sudmit" value="submit" /></p>
</form>
</body>
</html>