Jump to content

Recommended Posts

Ok i'm trying to create a page after a form is submitted so the user can review and edit their posted variables. I'm not sure about the best way to do this but i'm trying to save them in a session then echo them. Like This:

<php
/session start
session_start();

// variables
session_register('name');
session_register('last');
session_register('mi');
session_register('hp');
session_register('cp');
session_register('work');
session_register('email');
session_register('add');
session_register('add2');
session_register('city');
session_register('state');
session_register('zip');
session_register('password');


//finally, let's store our posted values in the session variables
$_SESSION['name'] = $_POST['name'];
$_SESSION['last'] = $_POST['last'];
$_SESSION['mi'] = $_POST['mi'];
$_SESSION['hp'] = $_POST['hp'];
$_SESSION['cp'] = $_POST['cp'];
$_SESSION['work'] = $_POST['work'];
$_SESSION['email'] = $_POST['email'];
$_SESSION['add'] = $_POST['add'];
$_SESSION['add2'] = $_POST['add2'];
$_SESSION['city'] = $_POST['city'];
$_SESSION['state'] = $_POST['state'];
$_SESSION['zip'] = $_POST['zip'];
$_SESSION['password'] = $_POST['password'];


?>
<HTML>
<HEAD>
</HEAD>
<body>
<php echo"$_SESSION['name']"?>
</body>
</HTML>

Is this the best way, or is there a better way??

Link to comment
https://forums.phpfreaks.com/topic/176339-echo-_sessionname/
Share on other sites

first off, you do not need to use session_register.  In fact, it's already deprecated and being removed as of php6.

 

2nd...what exactly is your overall goal here?  I'm not really seeing the point of having the user enter in editable stuff in a form, only to turn around and let them edit it again... perhaps you can explain what you're trying to do on a more "top" level?

 

Regardless though, what you have is technically right, minus the session_register which technically works but is superfluous and deprecated.

 

edit:

 

oh just noticed also you have the session var wrapped in quotes when you echo it.  That is not necessary either.

Link to comment
https://forums.phpfreaks.com/topic/176339-echo-_sessionname/#findComment-929434
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.