Good Day Everone
Just wanna ask for a suggestion if it is possible to Save data in DB and at the same time Print the form when the submit button is clicked? and if possible how can i obtain it?
Here's what ive tried
form.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=iso-8859-1" />
<title>test</title>
<style type="text/css">
<!--
.style1 {
font-size: 18px;
font-weight: bold;
}
-->
</style>
</head>
<body>
<span class="style1">Sample RA</span><br><br>
<form action="save.php" method="post">
I <input name="Name" type="text" placeholder="State your Name"/> certified that the info on this form is true and legitimate<br><br><br>
<input name="" type="submit" value="Print/Save"/>
</form>
</body>
</html>
and this part is the Save file
<?php
require_once('config.php');
$errmsg_arr = array();
$errflag = false;
$link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
if(!$link) {
die('Failed to connect to server: ' . mysql_error());
}
$db = mysql_select_db(DB_NAME);
if(!$db) {
die("Unable to select database");
}
function clean($str) {
$str = @trim($str);
if(get_magic_quotes_gpc()) {
$str = stripslashes($str);
}
return mysql_real_escape_string($str);
}
//Sanitize the POST values
$name = clean($_POST['Name']);
$sql="INSERT INTO data(name) VALUES('$name')";
if (!mysql_query($sql,$link))
{
//ERROR MESSAGE
echo "<script type='text/javascript'>alert('There was an error processing your request, Please Try Again'); window.location.href = 'index.php';</script>";
}
//SUCCESS WILL REDIRECT TO PRINT.php ///////////////////////////
header("location:print.php");
mysql_close($conn)
?>
and the print file
<!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=iso-8859-1" />
<title>test</title>
<style type="text/css">
<!--
.style1 {
font-size: 18px;
font-weight: bold;
}
-->
</style>
</head>
<body onload="window.print()">
<span class="style1">Sample RA</span><br><br>
<?php
$name = $_POST['Name'];
?>
I <?php echo"$name"; ?> certified that the info on this form is true and legitimate
</body>
</html>
but its not capturing the name in the print part it will just show *Sample RA
I certified that the info on this form is true and legitimate *
is there anyway to achieve this in a simpler manner?
Thanks