sstangle73 Posted January 29, 2008 Share Posted January 29, 2008 my script is sooooo slow anyone know a way to optimize it? <?php error_reporting(E_ALL); if(isset($_POST['sendemail'])){ $pass = $_POST['password']; if($pass == 'Shenentaha'){ $to = $_POST['emailto']; $subject = stripslashes($_POST['subject']); $amessage = nl2br($_POST['emailbody']); $message = stripslashes($amessage); $from = $_POST['from']; $reply = $_POST['reply']; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: ' . $from . "\r\n"; $headers .= 'Reply-to: ' . $reply . "\r\n"; $ex = explode(",",$to); if(count($ex) > 0){ foreach($ex AS $emails){ $email = trim($emails); mail($email,$subject,$message,$headers); } }else { mail($email,$subject,$message,$headers); } echo "Success<br><br><br><hr><br><br><br>New Email:"; } else { echo "Wrong Password. Contact Steven"; } } ?> <form action="<? echo $HTTP_SERVER_VARS['PHP_SELF']; ?>" method="post"> <table> <tr><td> <textarea name="emailto" rows="15" cols="50">email@domain.com, email@domain.com, email@domain.com</textarea> </td></tr> <tr><td> <input type="text" name="subject" size="67" maxlength="100" value="subject"> </td></tr> <tr><td> <textarea name="emailbody" rows="15" cols="50">Message Here</textarea> </td></tr> <tr><td> <input type="text" name="from" maxlength="100" size="67" value="From Name: Name <email@domain.com>"> </td></tr> <tr><td> <input type="text" name="reply" maxlength="100" size="67" value="Reply To: email@domain.com"> </td></tr> <tr><td>Enter Password:</td></tr><tr><td> <input type="text" name="password" maxlength="50" size="67" value="Password"> </td></tr> <tr><td> <input type="submit" name="sendemail" value="Send!"> </td></tr> </table> </form> Quote Link to comment Share on other sites More sharing options...
valtido Posted January 29, 2008 Share Posted January 29, 2008 ermm it might just be that the webserver is down loool or maybe change this ? echo $HTTP_SERVER_VARS['PHP_SELF']; ?>" to ? echo $_SERVER['PHP_SELF']; ?>" otherwise your coding looks fine Quote Link to comment Share on other sites More sharing options...
sstangle73 Posted January 29, 2008 Author Share Posted January 29, 2008 naw stil took a while the server is up >.< Quote Link to comment Share on other sites More sharing options...
valtido Posted January 29, 2008 Share Posted January 29, 2008 try and enter primery html codes like <html><head></head>..... etc browsers may act funny that way Quote Link to comment Share on other sites More sharing options...
sstangle73 Posted January 29, 2008 Author Share Posted January 29, 2008 i have 2 versions a stand alone and a something built into another page the one built in has the same outcome Quote Link to comment Share on other sites More sharing options...
valtido Posted January 29, 2008 Share Posted January 29, 2008 try a different file if they do the same then its a server fault loool or where you looped on the line starting "foreach(......." sometimes you make errors there loool and it will loop forever untill the browser times it out Quote Link to comment Share on other sites More sharing options...
sstangle73 Posted January 29, 2008 Author Share Posted January 29, 2008 no its not the servers fault. . . . . . . . . . im almost positive thats where the problem is i just dont know how to do it. someone else helped me add the foreach part cuz i had something that didnt work at all! Quote Link to comment Share on other sites More sharing options...
valtido Posted January 29, 2008 Share Posted January 29, 2008 yea u dnt need to use that foreach rule coz trim means to take away white spaces. and u have said if $ex > 0 or maybe test if the count($ex) may not give a number base on a array:D but u deffently have a loop problem Quote Link to comment Share on other sites More sharing options...
hamza Posted January 29, 2008 Share Posted January 29, 2008 I have also have a problem with sending email using php. Actually when i press the button for sending it will take too much long time to send. and it stops in between. And get stuck Any suggestion , help etc Please help me ................................... Quote Link to comment Share on other sites More sharing options...
legohead6 Posted January 29, 2008 Share Posted January 29, 2008 its gotta be either your webserver, or your hosts mail server. you code looks nearly identical to mine and mine works fine... Quote Link to comment Share on other sites More sharing options...
sstangle73 Posted January 29, 2008 Author Share Posted January 29, 2008 have you tried sending to many people at once say 50? does it take forever then? whos your webhosting from? Quote Link to comment Share on other sites More sharing options...
valtido Posted January 29, 2008 Share Posted January 29, 2008 add the comments tags around this code and telll me if the server is faster loool comment tags like so /* i am a comment balbla $ex = explode(",",$to); if(count($ex) > 0){ foreach($ex AS $emails){ $email = trim($emails); mail($email,$subject,$message,$headers); } */ The email might not work but it will defently b faster. If its faster then the problem is at foreach section coz you have not specified how many times it will loop and it goes n loops infinity number of times till a web browser such as internet explorer stops responding. PS let me no if its faster then i help you re write that bit. Quote Link to comment Share on other sites More sharing options...
sstangle73 Posted January 29, 2008 Author Share Posted January 29, 2008 anyone? Quote Link to comment Share on other sites More sharing options...
sstangle73 Posted January 29, 2008 Author Share Posted January 29, 2008 hmm? Quote Link to comment Share on other sites More sharing options...
sstangle73 Posted January 30, 2008 Author Share Posted January 30, 2008 mabie someone over night will get it 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.