denoteone Posted February 28, 2008 Share Posted February 28, 2008 there are a few things I am trying to accomplish... make sure they are logged in if not redirect them to the login page. Make sure that they _post is set if it is mail the info. if mail is successful show html page with thank you. if it is not echo error. and give them a chance to go back. Also if they are logged in and they somehow get to this page with out posting data from the previous page redirect them to the form page... <?php session_start(); if(isset($_SESSION['user'])) { if(isset($POST)) { $email = $_POST['docemail']; $name = $_POST['name']; $message = $_POST['docname']; $subject = 'doc request'; mail('email@email.com',$subject,$headers) if(mail)! //if mail fails { echo "error sending mail please click her to go back"; } else { <html> thanks page</html> } } else{ The user got to this page with out posting data from the previous page redirect them } }else { redirect back to login } ?> Is there an easier way to do this or am I even doing it correctly...Any ideas would be awesome. Quote Link to comment Share on other sites More sharing options...
premiso Posted February 28, 2008 Share Posted February 28, 2008 Just some side notes. Alot of syntaxish errors. First mail is not a good system to check if it was sent or not, as the mail function may return false although the mail was sent. Another issue is the isset($POST) should be isset($_POST) Another issue as stated syntax: mail('email@email.com',$subject,$headers) ; need semicolon here/ if(mail)! //if mail fails formated wrong Should be : if (!mail('email@email.com',$subject,$headers)) which would disregard the above line as it can be consolidated. Anyhow aside from those issues it looks like you have the right idea. Quote Link to comment Share on other sites More sharing options...
denoteone Posted February 28, 2008 Author Share Posted February 28, 2008 thank you for the advice. What would you recommend me check to make sure the mail was sent successful. Thanks again. Quote Link to comment Share on other sites More sharing options...
premiso Posted February 28, 2008 Share Posted February 28, 2008 thank you for the advice. What would you recommend me check to make sure the mail was sent successful. Thanks again. Short of going to an inbox and checking, there is no sure fire way to check. Just the facts of life there, or more or less the facts of mail(). 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.