Jump to content

Recommended Posts

Hello everybody.

I'm changing  some php in one wordpress website.

What I'm trying to do is to pass some values from one website page to the other.

 

When I do it this way, everything works fine:

 

Example 1:

                First php file: (the one sending the value)

                $Variable1 ='Hello';
                $_SESSION['kamail']=$Variable1;
                printf('<li> Variable value:'. $Variable1 .'</li>');

                Second php file: (the one getting the value)

                $Variable2=($_SESSION['kamail']);

In the previous "Example 1" I get the correct value in $Variable2 and the print_f also prints the correct value

 

In the next "Example 2", it does print the correct value, but in the second file, $Variable2 gets a completely different value.

 

Example 2:

                First php file: (the one sending the value)

                $Variable1 =($javo_directory_query->get('email'));
                $_SESSION['kamail']=$Variable1;
                printf('<li> Variable value:'. $Variable1 .'</li>');

                Second php file: (the one getting the value)

                $Variable2=($_SESSION['kamail']);

I guess that this haves something to do with pointers or something similar, but I'm a completely PHP beginner, so I'm stuck with this :(

 

Francisco

Hi, no nothing. 

When I do it with  "$Variable1 ='Hello';" I get "Hello" in $Variable2.

When I do it with "$Variable1 =($javo_directory_query->get('email'));" and printf it on the first file, it prints the correct email, but $Variable2 then has a different email as value.  

​I guess that $Variable1 is not getting a string of characters, but some kind of pointer to a value, but I'm still a perfect ignorant about php, so I can't solve this apparently simple problem :(

 

Francisco 

In your second example, did you try outputting the SESSION variable instead of $Variable1?

<?php
$Variable1 =($javo_directory_query->get('email'));
$_SESSION['kamail']=$Variable1;
printf('<li> Variable value:'. $_SESSION['kamail'] .'</li>');
?>

If it displays the correct email, the problem occurs later in your script...or before $Variable2 is displayed.

Hello again!

 

Do all of your pages have session_start() at the very top as the first thing?

I tried with both with and without session_start..

 

 

 

In your second example, did you try outputting the SESSION variable instead of $Variable1?

<?php
$Variable1 =($javo_directory_query->get('email'));
$_SESSION['kamail']=$Variable1;
printf('<li> Variable value:'. $_SESSION['kamail'] .'</li>');
?>

If it displays the correct email, the problem occurs later in your script...or before $Variable2 is displayed.

 

Yes I tried using $_SESSION['kamail'] directly. But in the second file I don't printf the var, what I do is send one email, like this: wp_mail( $recipient, $_SESSION['kamail'], $body, $headers, $attachments );

Yes I tried using $_SESSION['kamail'] directly. But in the second file I don't printf the var, what I do is send one email, like this: wp_mail( $recipient, $_SESSION['kamail'], $body, $headers, $attachments );

 

Now it looks like you are using the SESSION variable as the "subject" argument. Is that what you intended?

Now it looks like you are using the SESSION variable as the "subject" argument. Is that what you intended?

Dear cyberRobot, I would like to be able to answer your question, but even after googling for "subject argument", I couldn't find out what it means! 

 

I thought that doing something like "$_SESSION['kamail']=($javo_directory_query->get('email'));" what would happen would be to put in $_SESSION['kamail'] a string with the contents of $javo_directory_query->get('email'), .

But I guess that what's in $_SESSION['kamail'] is not a string but some other kind of data. 

Maybe I should post here the full code of both files?

 

Francisco

 

 

Dear cyberRobot, I would like to be able to answer your question, but even after googling for "subject argument", I couldn't find out what it means!

 

You need look no further than the PHP manual for mail() function

Dear cyberRobot, I would like to be able to answer your question, but even after googling for "subject argument", I couldn't find out what it means!

 

Sorry for the confusion, the wp_mail() function  accepts up to 5 arguments. The second argument, the one after the first comma, is where you put the subject of the email.

 

I guess what I was getting at is what are you looking at to know that the email is wrong. Are you looking at the subject of the email? Does that contain the expected email address from $_SESSION['kamail']?

 

Note that the "To" field is being populated from $recipient in the function call below:

wp_mail( $recipient, $_SESSION['kamail'], $body, $headers, $attachments );

And the "From" field is set through $headers.

Haaa ok, THAT subject! I know that! I'm just using that field so I get the email with the value of the variable! I installed FirePHP to check the values of the variables, but it was not working, so I'm sending the value of the variable as the subject, just to test it! 

The website I'm working in and that is getting this problem is http://algarve-dreamweddings.com/partners/thestoryteller/   In that page the field "Email2" is where I printf the value of  $_SESSION['kamail'] and it gets the right email address "info@thestoryteller...", but then in the tab "Location", when the form sends the email with the value of the same variable, the variable instead of "info@thestoryteller..", has another email. In this case it has the email of the last item I posted in the website. 

 

Francisco

Perhaps if you post the code where you see another email, we may be able to identify the problem. Note that when / if you paste the code, please surround it with


tags. It will make your post and code easier to follow.  :happy-04:

 

For what it's worth, I would try to trace the variable which contains the email address of interest to see where it's going wrong. Assuming that you used a SESSION variable, I echo the variable out right after using session_start(). If it is correct, I would continue through the script trying to echo out the variable to see where it's getting changed.

 

 

In this case it has the email of the last item I posted in the website.

 

It sounds like you are overwriting the variable somewhere in the script. What do you use to write your code? Have you tried using that program to search for the variable containing the email. It should give you a basic idea of how the variable is used and where it was potentially overwritten. Note that you'll also want to check any of the scripts being imported into the script having the problem.

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.