2 quesions one on logic and one on forms (php)

Associate
Joined
19 Jul 2006
Posts
1,847
Using Php and Mysql I have a form that we fill in.
so it goes impact.php (form) ---> add.php ( the information is entered into the database when this page loads, This page displays a summary of what is entered in a table and theres 2 buttons one that says this info is correct which takes the user back to the start page. the other button says no edit this information.)

If the user clicks edit I want to bring back the record just entered and populate the form again with that info, the form has checkboxs, dropdown selectors and free text areas.

So 1 how do i get the record back thats just been entered?

Then how do i get this back into the form?

Then it would be a update statement.

TIA
 
Just have a form on the add.php that's identical to the form on impact.php, but with all the fields disabled? Then the "Edit" button can be a part of this form which'll post the data back to impact.php.

Or if you don't want to do that, populate a hidden form.

Or if you don't want to use a for on add.php, pass all the info through as URL variables attached to the Edit button/link.

Simples!
 
Thanks Russinating,

But that went totally over my head. Which is the easiest to do?

I send variables as URL from the impact to the add page. how do i get that back into the form?
 
Hmm I wouldn't have it submitting to the database unless the info is correct. If the data the user has inputted is incorrect but they fail to go back to correct it, you'll have incorrect data stored in the database.

I'd have it all on the impact.php page:

Code:
if(isset($_POST["correct"]))
{
# Store data to database
# Show thank you message
}
elseif(isset($_POST["submit"]))
{
# Show submitted data on page
# Put data into hidden fields on form
# Show correct and incorrect button options
}
else
{
# Show form with any posted values inserted into text fields, checkboxes ticked and dropdown options selected
# Show submit button
}
 
Last edited:
Thanks for the help guys,

if i have this
PHP:
$sql = sprintf("INSERT INTO `database`.`Entries` (`Username`, `School`, `Dateofvisit`, `Tspent`, `Activity`, `Management`, `Coords`, `In_School`, `PCP_BSF`, `Learning_Platform`, `SRF`, `eSafety`, `Projects`, `Reprographics`, `FS`, `Evolve`, `Other`, `Wholeschool`, `Headteacher`, `SMT`, `Subjectleader`, `ICTsubjectleader`, `LAOfficer`, `eSafetyperson`, `Goveners`, `Admin`, `Classteacher`, `TA`, `Parents`, `Students`, `Description`, `Impact`, `Action_Plan`, `Success_Criteria`, `Notes`) VALUES ('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')",
																							 mysql_real_escape_string($name),
...... ect
mysql_query($sql); 
mysql_close();

Which at the moment works and puts it into the database when the page loads.( after form been submitted)

I want to move this code now and attach it to the thee details are correct button, which also redirects to another page. ( iwant to submit to database here)
PHP:
<form name=correct type=post action = submited.php>
<input type='submit' value ='These details are correct' onclick="correct.action='submited.php';return true;">
<input type='submit' value ='Edit these details' onclick="correct.action='edit.php';return true;"> </form>
 
Back
Top Bottom