Hello fellows.
I need some help regarding my script.
I have a simple php script contains form to insert First Name and Last Name. This works successfully.
But my problem is when i try to display the posted data to ASP page, the ASP page doesnt come out.
What should I do in this case?
This is my code
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>PHP TO ASP :: testing only</title>
<!-- Submit Form script -->
<script type="text/javascript">
function submitForm()
{
document.forms["hiddenform"].submit();
alert("??");
}
</script>
</head>
<?php
//Connect to DB server
$conn = mysql_connect('localhost','root','') or die(mysql_error());
//Selece database
mysql_select_db('ems',$conn) or die(mysql_error());
$FName = $_POST['FName'];
$LName = $_POST['LName'];
if(isset($_POST['send'])){
$sql = "INSERT INTO `ems`.`tbl_dummy` (`FName`, `LName`) VALUES ('$FName', '$LName');";
mysql_query($sql);
// I dont know whether this correct or not. But it doesnt work
print("<script type=\"text/javascript\">submitForm();</script>");
}
?>
<body>
<form action="" method="post" enctype="application/x-www-form-urlencoded" name="frm_test">
<label>First Name: </label><input name="FName" type="text" /><br />
<label>Last Name: </label><input name="LName" type="text" /><br />
<input name="send" type="submit" value="Save" />
</form>
<!-- Hidden form submitted by javascript to php2asp.asp -->
<form action="http://localhost/php2asp.asp" method="post" enctype="application/x-www-form-urlencoded" name="hiddenform" id="hiddenform">
<input name="FName" type="hidden" value="<?= $FName ?>" />
<input name="LName" type="hidden" value="<?= $LName ?>" />
<input name="submit" type="hidden" value="" />
</form>
</body>
</html>
ASP
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!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>This is ASP :: Data from PHP</title>
</head>
<body>
<h2>These data are from PHP</h2>
<%
dim fname, lname
fname = request.Form("FName")
lname = request.Form("LName")
response.Write(fname& " " &lname)
%>
</body>
</html>
Thank you. :)