Jump to content

no refresh Session Data :'(


koolaid

Recommended Posts

i am trying to pass session data Between scripts w/o refreshing the browser window. I asked for help on this yesterday, but i was beyond help then. i am a lot closer now. I think i am off on the scope of my vars or something. All my scripts work they just are not correctly passing my session data around. Or maybe i do have to refresh my browser window. i dont know.  I really apreachiate ANY help,  direction, or explaination of why i am so dumb.

 

Tnx in advance

 

My initial page is

<?php 
session_start(); 
error_reporting(E_ALL);

if (isset($_SESSION['mypath'])){
echo "set to";
echo $_SESSION['mypath'];
}else{
setit();
}

function setit()
{
echo "settin it up  ";
unset($mypath);
session_unregister("mypath");

$mypath = 'whatever';
echo "$mypath var is now set to = " . $mypath;
$_SESSION['mypath'] = $mypath;
echo "the session data = ";
echo $_SESSION['mypath'];

if ( !($_SESSION['mypath'] === $mypath) )
$_SESSION['mypath'] = $mypath;
echo "last time = ";
echo $_SESSION['mypath'];
}

?>

 

This above page calls this script first,

i upload a file and write it to my server. _SESSION['mypath']

That all works.

 

i also reset the

<?php

session_start();
error_reporting(E_ALL);
echo "last time = ";
echo $_SESSION['mypath'];

function goaway()
{
unset($mypath);
session_unregister("mypath");
echo "path cleared = ";
}
goaway();

if(!is_dir("./files")) mkdir("./files/", 0755); 

//move the uploaded file
$replaceArr = array(" ", "#","!", "*", "^", "+");
$name = str_replace($replaceArr, "_", $_FILES['Filedata']['name']);

$filename = "./files/".$name;

makemyvar();

function makemyvar()
{

srand(time());
$random = (rand()%9999);
$ext = substr(strrchr($name, "."), 0);
$name2 = str_replace($ext,'',$name);
$arandomname = $name2.$random.$ext;
$mypath = $arandomname;
$_SESSION['mypath'] = $mypath;
echo "session path  = ";
echo $_SESSION['mypath'];

}

if (file_exists($filename)) {
move_uploaded_file($_FILES['Filedata']['tmp_name'], "./files/".$_SESSION['mypath']);
chmod("./files/".$_SESSION['mypath'], 0777);
}else if( !($_SESSION['mypath'] === $mypath) ){
$_SESSION['mypath'] = $mypath;
echo "last time = ";
echo $_SESSION['mypath'];
} else {
    move_uploaded_file($_FILES['Filedata']['tmp_name'], "./files/".$name);
chmod("./files/".$name, 0777);
//$mypath = $name;
//$_SESSION['mypath'] = $mypath;
}


?>

 

next i call this script This script works it just doesn't correctly pass my session var.


session_start(); 
error_reporting(E_ALL); 
//echo $_SESSION['mypath'];

$sendTo = "[email protected]";
$subject = "RESUME SUBMISSION (applicant)";

$headers = 'From:' . $_POST["email"] . "\r\n" .
    'Reply-To:' . $_POST["email"] . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

$headers .= "Content-type: text/html\r\n";

$path =  $_POST["mypartialurl"];

$temp = $_SESSION['mypath'];

/*
if ( !($_SESSION['mypath'] === $temp) )
$_SESSION['mypath'] = $temp;
//echo $temp;
*/

$thelink = $path ."files/";


$message = 'RESUME SUBMISSION,

name -'. $_POST["name"] . "\r\n \r\nTHE SUBMITTED INFO: \r\n \r\nAre you a creative thinker and problem solver? - " . $_POST["quest1"] . "\r\nDo others consider you a natural born leader? - " . $_POST["quest2"] . "\r\nAre you ready to set your own income potential? - " . $_POST["quest3"] . "\r\nAre you ready for responsibility from day one? - " . $_POST["quest4"] . "\r\nemail - " . $_POST["email"] . "\r\n\r\nAdditional comment / question - " . $_POST["message"] . "\r\n\r\nlink to uploaded resume:\r\n" . $thelink . $temp; 

mail($sendTo, $subject, $message, $headers);


?>

 

Link to comment
https://forums.phpfreaks.com/topic/140739-no-refresh-session-data/
Share on other sites

tnx for looking man

 

I call the scripts one at a time from a flash object. Also the $_POST vars u see being posted come from the flash object as well. All that information is being transfered from flash o.k.

 

Here is the order of things

 

1: open page 1

2:  then the user chooses to upload a file. It writes the file to the server.

  3: The user hits submit within my flash object and it calls for the third php script to send an email with a link to the file they uploaded.

 

Everything goes smooth except the link that comes through in the email.

 

The reason i think it is a scope thisg is because

it writes the file to the server and names it what i want With this snippet.

 

if (file_exists($filename)) {
move_uploaded_file($_FILES['Filedata']['tmp_name'], "./files/".$_SESSION['mypath']);
chmod("./files/".$_SESSION['mypath'], 0777);

 

All i need to do is preserve that value $_SESSION['mypath'], so that i can refer to it in the email script.

 

 

 

 

db is usually ideal, but i am not skilled in those areas. i am a flash developer, with html and css skills. Also this is really a very small app. it is just for people to submit their resumes to our HR department.

 

I had that all worked out except every week i had to log in and download the resmes for the manager. ( It is corporate policy that i cannot give her FTP credentials. )

 

So i thought if i could pass just one variable via sessions to 3 scripts it would solve this problem. It would too, only i loose the variable on the very last step of the process.

 

Can anyone offer any insight on my script or a simple workaround?

i would personally try the db alley, i'm not in a position to give large chunks of tested code away for free but if you have a budget(small im not greedy) email me your contact details and i'll figure a best plan 4 u.

 

saying that if you are determined yourself, i would write a simple db that record the filename and locations then a script/page that lists them for your hr to click download. im sure they must exist elsewhere try googlein

 

if you get started on a script i'll certainly give u pointers.

 

:)

I don't know if i need large amounts of tested code.  I really need a shove in the direction of fixing what i have. i am on the verge of having it.

 

Like i said all i need is to pass 1 piece of info via session data.

 

Not even an array of info. 1 string.

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.