Francisco_Jfm Posted January 15, 2015 Share Posted January 15, 2015 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 Quote Link to comment Share on other sites More sharing options...
requinix Posted January 15, 2015 Share Posted January 15, 2015 Completely different how? What else is different between the two sets of files? Maybe how you use them? How you send the user to the second page? Where the pages are? Quote Link to comment Share on other sites More sharing options...
NotionCommotion Posted January 15, 2015 Share Posted January 15, 2015 Is there a chance you are overwriting the value of $_SESSION['kamail']? Also, same URL right? Not doing anything fancy with session IDs, right? Quote Link to comment Share on other sites More sharing options...
Francisco_Jfm Posted January 15, 2015 Author Share Posted January 15, 2015 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 Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted January 15, 2015 Share Posted January 15, 2015 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. Quote Link to comment Share on other sites More sharing options...
CroNiX Posted January 15, 2015 Share Posted January 15, 2015 Do all of your pages have session_start() at the very top as the first thing? Quote Link to comment Share on other sites More sharing options...
Francisco_Jfm Posted January 15, 2015 Author Share Posted January 15, 2015 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 ); Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted January 15, 2015 Share Posted January 15, 2015 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? Quote Link to comment Share on other sites More sharing options...
Francisco_Jfm Posted January 15, 2015 Author Share Posted January 15, 2015 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 Quote Link to comment Share on other sites More sharing options...
Barand Posted January 16, 2015 Share Posted January 16, 2015 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 Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted January 16, 2015 Share Posted January 16, 2015 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. Quote Link to comment Share on other sites More sharing options...
Francisco_Jfm Posted January 16, 2015 Author Share Posted January 16, 2015 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 Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted January 16, 2015 Share Posted January 16, 2015 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. 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.