Jump to content

php5 session variables from $_POST


jalea148

Recommended Posts

:-X

here's  a snippit - code worked in php4; not in php5. Form variables First, Last etc are blank.

 

<?php

session_start();

session_register('sessFirst');

session_register('sessLast');

session_register('sessAddr');

session_register('sessAddr2');

session_register('sessCity');

session_register('sessZip');

session_register('sessPhone');

session_register('sessEmail');

$sessFirst = $_POST['First'];

$sessLast = $_POST['Last'];

$sessAddr = $_POST['Addr'];

$sessAddr2 = $_POST['Addr2'];

$sessCity = $_POST['City'];

$sessZip = $_POST['Zip'];

$sessPhone = $_POST['Phone'];

$sessXmail = $_POST['Email'];

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Untitled Document</title>

</head>

..................

 

<form action="..........................  >

..................

  <p>

<input name="First" id="First" type="text" class="req"  size="20" tabindex="1" value="<?php echo $sessFirst; ?>"/> <span class="style12">   Last    </span>

<input name="Last" id="Last" type="text" class="req" size="20" tabindex="2"  value="<?php echo $sessLast; ?>" />

  </p>

....................

<body>

</body>

</html>

 

Link to comment
https://forums.phpfreaks.com/topic/114534-php5-session-variables-from-_post/
Share on other sites

This has nothing to do with php4 vs php5. The code is using an old depreciated function session_register(). session_register only works when register globals are on (register globals were turned off by default in php 4.2 in the year 2002 and have completely been eliminated in php6.)

 

You need to use the session_start() function and the $_SESSION variable array instead.

This has nothing to do with php4 vs php5. The code is using an old depreciated function session_register(). session_register only works when register globals are on (register globals were turned off by default in php 4.2 in the year 2002 and have completely been eliminated in php6.)

 

You need to use the session_start() function and the $_SESSION variable array instead.

 

Thanks - you sent me in the right direction. However, in

              <p>

        <input name="First" id="First" type="text" class="req"  size="20" tabindex="1" value="<?php echo $sessFirst; ?>"/> <span class="style12">   Last    </span>

        <input name="Last" id="Last" type="text" class="req" size="20" tabindex="2"  value="<?php echo $sessLast; ?>" />

              </p>

the passed data does not appear. Instead, when you double click in the field a pull down menu appears and the session variable value is one of the menu items.

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.