This topic is locked

AfterEdit OR BeforeEdit

2/20/2007 8:45:06 AM
PHPRunner General questions
G
gje author

Hello,
In the AfterAdd function of my products table I resize the uploaded image to 2 sizes and rename them to the [id] ([id]th.jpg and [id].jpg) and then delete the original file. This works perfect.

But in AfterEdit it doesn't seem possible to get the values from the form.. ( I also need to know if the file has been updated).

What I need is the following:

  1. Know if file has been update
  2. Get the id of the edited file
  3. Get the name of the uploaded file
    Hope somebody can help me out on this one!
    Kind Regards,
    Geert

Sergey Kornilov admin 2/20/2007

Use BeforeEdit event for this purpose where you can access form variables.

G
gje author 2/20/2007

Hi, I have tried that, but it doesn't work for me... If I put:
echo $values["prod_foto"];
it doesn't do anything...
What do I do wrong ??

J
Jane 2/20/2007

Hi,
if prod_foto is readonly on the edit and add pages use the following code to obtain field value:

echo postvalue("value_event");


If it doesn't help post your event code here and I'll help you.

G
gje author 2/20/2007

Hi,
With postvalue I get the info I need, but I have ran into an other problem...
I need to resize the image I am uploading, but it isn't uploaded yet in BeforeEdit....
Then I also need to update the image value in the database wich I can only do after it has been updated by normal edit...
P L E A S E H E L P !

J
Jane 2/21/2007

Jan,
you can save id of edited record in the $_SESSION variable in the Before record updated event:

$_SESSION["prod_foto"]= postvalue("value_prod_foto");



And then use it in the AfterEdit event:

function AfterEdit()

{

global $conn;

$str = "select ImageField from TableName where prod_foto=".$_SESSION["prod_foto"];

$rs = db_query($str,$conn);

$data = db_fetch_array($rs);
//$data["ImageField"] contains your resulting image
}



where ImageField is your actual field name, TableName is your actual table name.