Hello everyone,
I have created one page ("CSite.php") for my website which includes a form where the user has to complete 4 fields.When the user clicks on the submit button he/she will be redirected on another page(without saving the data into the database) called "checkCSite.php". The new page has another form where displays the data that the user entered in the previous form("CSite.php"). In this form the user has two click one of the two buttons that exist: "Submit" or "Change". If the user clicks on the "Submit" button then the data will be stored in the database and will be redirected to another page called("CSiteresults.php") where a message will inform the user if the data was added in the database.Now if the user wish to change the data that has put clicks on the "Change" button and be redirected on the previous page("CSite.php") in order the user to change the data and then to submit again.So i want the data to be stored in the database in the second form("checkCSite.php").
What happens now is that the data is being inserted from the first form.
I know that the problem should be in the page ("checkCSite.php") as i have create a form inside another form so when the user submit it goes straight away to insert the data.
Here i have put the code from the page ("checkCSite.php"):
PHP Code:
<?
$mgr=$_POST['sitemgr']; $const=$_POST['construction']; $location=$_POST['location']; $info=$_POST['info'];
?>
<html> <head></head> <body>
<br> <table width="100%" border="1" > <tr> <td> <form name="changeCSite" method="POST" action="CSite.php" > <table width="345" border="1" align="center"> <tr> <th align="left" colspan="5">Site mgr</th> <td ><? echo $_REQUEST['sitemgr'];?> </td> </tr> <tr> <th align="left" colspan="5">Construction Co</th> <td><? echo $_REQUEST ['construction'];?></td> </tr> <th align="left" colspan="5">Location</th> <td><? echo $_REQUEST['location'];?></td> </tr> <tr> <th align="left" colspan="5">Other information</th> <td><? echo $_REQUEST['info'];?></td> </tr>
<table align="center"> <tr> <td></td> <td><input type="button" value="Change" name="back" onclick="history.go(-1)"></form></td>
<td> <form name="submitresults" method="POST" action="CSiteResults.php"> <input type="submit" value="Submit" name='submitDB'></td>
<? $query="Insert INTO CSite (SiteMgr,ConstructionCo,Location,OtherInfo) values ('$mgr','$const','$location','$info')"; mysql_query($query);
mysql_close(); ?> </tr>
</table> </form>
</table> </td> </tr> </table> </body> </html>
I have also include the code from the first page CSite.php:
PHP Code:
<html> <head>
<script type="text/javascript"> <!-- // check that they entered an amount tested, an amount passed, // and that they didn't pass units than they more than tested
function checkData(){ var flag="true";
if(document.getElementById("sitemgr").value==""){ alert("Please fill in the Site Mgr field"); flag="false"; }else if (document.getElementById("construction").value==""){ alert("Please fill in the Construction Co field"); flag="false"; }else if (document.getElementById("location").value==""){ alert("Please fill in the location field!"); flag="false"; }else if (document.getElementById("info").value==""){ alert("Please fill in the information field"); flag="false"; } if (flag=="false") return false; }
// --> </SCRIPT>
</head> <body> <br> <table width="100%" border="1"> <tr> <td>
<form action="checkCSite.php" method="POST" name="csite" onSubmit="return checkData()" > <table width="100%" border="0" align="center" > <tr> <th align="left">Site mgr</th> <td> <input type="text" name="sitemgr" id="sitemgr"></td> </tr> <tr> <th align="left">Construction Co</th> <td><input type="text" name="construction" id="construction"></td> </tr> <tr> <th align="left">Location</th> <td><input type="text" name="location" id= "location"></td> </tr> <tr> <th align="left">Other information</th> <td><input type="text" name="info" id="info"></td> </tr> <tr>
<table align="center">
<tr> <td><input type="submit" value="Submit" name="submit"></td>
<td><input type="reset" value="Clear"></td> </tr> </tr> </form> </table> </td> </tr> </table> </body> </html>
Probably is very easy but i don't know how to solve it.So i would appreciate your help.
Thank you in advance,
Xenia
|