Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

later evaluation of variables?? Php variables Problem!!!

Posted on 2003-11-17
4
Medium Priority
?
190 Views
Last Modified: 2012-05-04
hi,

i wrote a script to send some one an email when he changed his password and i have a language.php where i have every shown word listed and set so i can change the languages easily.

but i have a problem the $user_password which i have to send to the user wont show in the email because the language.inc.php is loaded before with the $user_password.

now, i need a way how to pass my variables from my language.inc.php to my forgotpasswort.php and get the mail function not only to send the text of $forgotpassword_mail but also the content of $user_password

heres the code:


### language.inc.php
$forgotpassword_mail = "Dear User, \n this is your new pw: \n $user_password  ";

### forgotpassword.php
include "inc/laguage.inc.php";

                  $connection = mysql_connect("$mysql_host","$mysql_user","$mysql_pass") or die ("Cannot connect to Mysql\n");
                  $selectdb = mysql_select_db("$mysql_db", $connection) or die ("could not select the database");
                  
                  $user_password = randomPassword(12);
                  $q = "Update $mysql_table SET user_password = md5('$user_password') WHERE user_loginname = '$user_loginname' and user_email = '$user_email' ";
                  $r = mysql_query($q);
                  echo "$forgotpassword_succsessful";
                  mail("$user_email","$forgotpassword_mail_subject","$forgotpassword_mail" );       


thanks
dope

0
Comment
Question by:Dopeman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 6

Accepted Solution

by:
DoppyNL earned 200 total points
ID: 9763057
you can do this:

change this line:
  $forgotpassword_mail = "Dear User, \n this is your new pw: \n $user_password  ";
to:
  $forgotpassword_mail = "Dear User, \n this is your new pw: \n ----NEWPASSWORD----  ";

and this:
  mail("$user_email","$forgotpassword_mail_subject","$forgotpassword_mail" );  
with:
  $forgotpassword_mail = str_replace('----NEWPASSWORD----', $user_password, $forgotpassword_mail);
  mail("$user_email","$forgotpassword_mail_subject","$forgotpassword_mail" );  

get the idea?
0
 

Author Comment

by:Dopeman
ID: 9763514
yeah,

thought about that too,
 sounds really good but what about the performance isnt that very slow (just asking because of interest)

if there is no other solution ill try yours DoppyNL

thanks
dope
0
 
LVL 6

Expert Comment

by:DoppyNL
ID: 9763534
str_replace is quite fast; I doubt you will notice a speed difference; even if you do this 1000 times per page you probably won't notice much difference.
0
 

Author Comment

by:Dopeman
ID: 9763722
i did it with str_replace and it work perfect

and thanks for answering so fast

Dope
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question