PDA

View Full Version : session variables


pinch
05-19-2006, 04:19 PM
Hi all,

am trying to work with session variables to send confirmation mails. getting this PHP Notice:

PHP Notice: Undefined index: mail in c:\Inetpub\wwwroot\tourism bee charter self assessor\thank.php on line 32 PHP Notice: Undefined index: mail in c:\Inetpub\wwwroot\tourism bee charter self assessor\thank.php on line 176 PHP Notice: Undefined index: pass in c:\Inetpub\wwwroot\tourism bee charter self assessor\thank.php on line 177 PHP Warning: mail() [function.mail]: SMTP server response: 501 5.5.4 Invalid Address in c:\Inetpub\wwwroot\tourism bee charter self assessor\thank.php on line 187 PHP Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in c:\Inetpub\wwwroot\tourism bee charter self assessor\thank.php on line 250

the code from the session setting page is as follows:

session_start();
if (isset($HTTP_POST_VARS['Contact_E-mail'])) {$mail = $HTTP_POST_VARS['Contact_E-mail'];
session_register("mail");
}
if (isset($HTTP_POST_VARS['New_Password'])) {$pass = $HTTP_POST_VARS['New_Password'];
session_register("pass");
}

once they click on submit it goes to the next page to update the record with a serial number and send a confirmation mail.

the code is as follows:

28 //session
29 session_start();
30
31 //This is the Serial Updating part
32 $user_id = mysql_query("SELECT id FROM username WHERE mail = ". $_SESSION['mail']);
33 $serial = mysql_query("SELECT valid_serials FROM serial WHERE id = " . $user_id);
34
35 $query_1 = "LOCK TABLES username WRITE, list_of_serials WRITE";
36 mysql_query($query_1);
37
38 $query_2 = "UPDATE username SET valid_serials = " . $serial;
39 mysql_query($query_2);
40
41 $query_3 = "UNLOCK TABLES";
42 mysql_query($query_3);

174 <?php
175
176 $mail_to=$_SESSION['mail'];
177 $pass=$_SESSION['pass'];
178 $mail_from="info@tourismbeecharter.org";
179 $mail_sub="Thank you for using the self assessment software";
180 $mail_mesg="<p>Dear Member </br>
181 Thank you for using the Tourism BEE Charter Self Assessor,</br>
182 Your Details are as follows:</p>
183 <p>Username : $mail_to</br>
184 Password : $pass</p>";
185
186 //Check for success/failure of delivery
187 if(mail($mail_to,$mail_sub,$mail_mesg,"From:$mail_from/r/nReply-to:$mail_from"))
188 echo "<span class='textred'><p align='justify' class='style10'> An e-mail has been sent to ". $mail_to ." with your username and password. Please login to the member's area to get your serial number and download the self assessment software.</p></span>";
189
190 else
191 echo "<span class='textred'>Failed to send the confirmation E-mail to $mail_to , please login to the member's area to get your details or request for the username and password to be resent to you</span>";
192
193 ?>

for some reason it is not picing up the session variable... please help.

GJay
05-19-2006, 07:31 PM
try setting $_SESSION['mail] to the value you want instead

pinch
05-22-2006, 09:43 AM
Thanks, but i have to get them from the form, it's for sending the confirmation mail and assigning a serial number for this new user on registration.

GJay
05-22-2006, 09:45 AM
I'll rephrase:
try setting the $_SESSION variables rather than using session_register, which if it isn't deprecated, is certainly not reccomended.

pinch
05-24-2006, 06:33 PM
thanks, i tried taking out the session_register, but it still didn't work, then i changed the form input names using


$mail = $HTTP_POST_VARS['email'];
$_SESSION['mail'] = $mail;


changing the form input name to email

now i have a error saying "Undefined Index"

....

GJay
05-24-2006, 06:40 PM
use $_POST

pinch
05-25-2006, 10:21 AM
changed that, but it's still the same error msg

PHP Notice: Undefined index: email

pinch
05-25-2006, 10:41 AM
thanks a lot, i fixed it some how, still don't know what went wrong though.... but i went back to the original if(isset) statement, and got it to work with your changes, thanks again