I am facing three problems with a feedback form.The code of all three pages
ie;quote.html,preview.php and preview1.php is given below.
1) I need all my data to be there in same text area when i press "Edit" button in preview (preview.php) page.How can i achive that ? .Is there some method so that i can store the values and transfer.Im using "header(Location:quote.html)" on the "Edit" though it takes me to the quote page the data is not there in textarea.Please help
quote.html
<html>
<head><title>quote</title></head>
<body>
<form action=preview.php method=post>
Address:<textarea name=address rows=3></textarea><br>
<INPUT type="submit" value="Preview"/>
<INPUT type=reset value="Clear"/>
</form>
</body>
</html>
preview.php
<?php
$addr=$_POST['address'];
echo'<form action=preview1.php method=post>';
echo $addr,'<input type=hidden name=address2 value="'.$addr.'">';
echo'<INPUT type="submit" value="Edit"/ name=edit><INPUT type="submit" value="Save"/ name=save>';
echo'</form>';
?>
preview1.php
<?php
$addr1=$_POST['address2'];
if(isset($_POST['edit'])) {
header('Location: quote.html');
}
elseif(isset($_POST['save'])) {
$host = "localhost";
$user = "username";
$pass = "password";
$dbname = "dbname";
$conn = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."<BR>");
mysql_select_db($dbname);
$request = "INSERT INTO tablename (address)value('".$addr1."')";
$results = mysql_query($request,$conn);
if($results)
{
echo "Document SAVED<br>";
}
else
{
echo "There was an error. Try Again.";
}
}
?>
2) Here is there any method for storing the input in three lines(The address) like carriage return or something as it is entered in text area and to display it the same way as it is filled up.(Now it is stored as single string...should i use three distinct text boxes or somebody here can help me?).
3) After clicking the save button in preview1.php if i refresh the page the data is being stored again in the database.How to prevent it(Should i use preventing duplicate entry or is there something i can do with "save" button)
Please help me for solving these probs.....
Thanking You
anoopd