Dear group, Description: Following is the code which I tried for learning propuses. It is a mail sending program which checks weather the user enters a correct mail id If he enters the correct mail ID then user name and e-mail will get stored in the mysql data base table. After getting stored then mail will sent to the user as a accknoledg process. For the propus of mail subject and mail body, I have created two external files. The problem: Filling the rows and col in the data base is no problem at all. The value getting stored. But after clicking the button for accknoledg the browser takes lot of time in execution. I doubt with either the file handling functions or infinit loop. Or Am I missing somthing basic? Pls mention if you faced a similear situation with file handling and infinit loop. Thanks. NOTE: Sorry for the very long code ============================== the code===================================== The html file: ^^^^^^^^^^^^ <HTML> <body> <form method="post" name="my_frm" action="mail.php"> <TABLE align ="center"> <tr> <td> Name: </td> <td> <input id="text" name="user_name"> </td> </tr> <tr> <td> E-mail: </td> <td> <input id="text" name="user_email"> </td> </tr> </TABLE> <table align = "center"> <tr> <td> <input type="submit" name="click_btn" value="yes,I want my 'CMS' NewsLetter NOW!" align=middle onClick="validt()"> </td> </tr> </table> <table align="center"> <tr> <td> <a href="test.html"><font size=2>Or click here to see how you can learn everything <br> you need to know about CMS without signing up for our free newsletter </font> </a> </td> </tr> </table> <script language="javascript"> function validt() { var str= document.my_frm.user_email.value; var name = document.my_frm.user_name.value; if(str.indexOf("@") <0 || str.indexOf(".") < 0) { my_error() } else alert("thanks for entering valid e-mail"); } function my_error() { alert("pls enter a correct e-mail ID"); document.my_frm.user_email.value = " "; } </script> </form> </body> </HTML> the mail.php file: ^^^^^^^^^^^^^^^ <?php /*mail body file*/ function cnd($fname) { $fil = fopen($fname,"r"); if(!$fil) die("fopen error"); while(!feof($fil)) $buffer = fgets($fil); while($buffer != NULL) { if($buffer == "\n.") /*a line should not start with .*/ $buffer = str_replace("\n.","\n..", $buffer); if($buffer == "\n" && $buffer > 70) /*should be less than 70*/ $buffer = '\n'; } fclose($fil); return $buffer; } /*mail sub file*/ function sub($fname) { $fil = fopen($fname,"r"); if(!$fil) die("fopen err in sub file"); while(!feof($fil)) $buff = fgets($fil); while($buff != NULL) { if($buff > 15) { ?> <script language="javascript"> alert("the subject line should not be less than 15, pls check the sub.txtfile"); </script> <?php } } fclose($fil); return $buff; } function fetch_names() { $var = mysql_connect("localhost","root",""); if(!$var) die("could not connect".mysql_error()); $db = mysql_select_db("sathya_clon",$var); if(!$db) die("could not find the data base".mysql_error()); $result = mysql_query("select name from users",$var) or die("unable to fetch rows"); $rows = mysql_fetch_array($result); while($rows) { for($i=0; $i<= $rows ; $i++) for($j=0;$j <= i-1 ; $j++) $names[$i] = $rows[$j]; } return $names; } function fetch_emails() { $var = mysql_connect("localhost","root",""); if(!$var) die("could not connect".mysql_error()); $db = mysql_select_db("sathya_clon",$var); if(!$db) die("could not find the data base".mysql_error()); $result = mysql_query("select email from users",$var) or die("unable to fetch rows"); $rows = mysql_fetch_array($result); while($rows) { for($i=0; $i<= $rows ; $i++) for($j=0;$j <= i-1 ; $j++) $email[$i] = $rows[$j]; } return $email; } $var = mysql_connect("localhost","root",""); if(!$var) die("could not connect".mysql_error()); $db = mysql_select_db("sathya_clon",$var); if(!$db) die("could not find the data base".mysql_error()); $name = $_POST['user_name']; $mail = $_POST['user_email']; $db_q = mysql_query("insert into users values('$name','$mail')"); if(!$db_q) die("mysql error"); $condt = cnd("cond.txt"); $sub = sub ("sub.txt"); $name = fetch_names(); $email = fetch_emails(); $mail_stat = mail($email,$sub,$condt,"from:comp@xxxxxxxxxx"); if($mail_stat == NULL) echo "mail sent failed"; else echo "mail sent sucess. Pls check for mail for further acction"; ?> ==================code ends======================== sorry english is not my native language.