Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.