Jump to content

Form Update


spraypray12

Recommended Posts

I have a form that sends data to mysql, and you get shown the submitted data. But i also want the users to be able to update their sent info, after thay see what they've sent, to make changes if something was incorrect. I want to make an update feature that will let them do that, but their is no user authentication on these pages, so i want to use php session. I don't know where to start.

 

I want the form data to be saved in the session, so when they go to the update page, their info is still there.

 

I want the session to end after they update.

 

Any tips on how to do any of this.

Please HELP!

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/43384-form-update/
Share on other sites

if i undertood what you want to do correctly, you shouldnt even be using a session. just post the original form either to itself and just use the $_REQUEST[] constant to retrive the submitted data to be edited before saving it to the database.

something like this:

<html>
<body>
<?php
$text1 = "";
if ($_REQUEST['submit1']){
$text1 = $_REQUEST['text1'];
}
?>
<form action = "thispage.php" method = "post">
<?php
else{
?>
<form action = "saveToDB.php" method = "post">
?>
<input type = "text" name = "text1" value = "$text1">
<input type = "submit" name = "submit1">
</form>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/43384-form-update/#findComment-210719
Share on other sites

Alright man, here is a place to start, hope this helps

 

<?php
session_start();

if (isset($_POST['submit'])) {
    foreach ($_POST as $key => $val) 
         $_SESSION[$key] = $val; // store incase they want to edit.
    print '<form action="index.php" method="POST"><input type="text" name="tst" value="'.$_SESSION['tst'].'" /> <input type="submit" name="verify" value="Verify" /></form>';
}elseif (isset($_POST['verify'])) {
    // sql query here
    print 'Data entered into DB';
}else {
    print '<form action="index.php" method="POST"><input type="text" name="tst" value="'.$_SESSION['tst'].'" /> <input type="submit" name="submit" value="Submit" /></form>';
}
?>

Link to comment
https://forums.phpfreaks.com/topic/43384-form-update/#findComment-210726
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.