Web page form is not sending email

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nargis2009
    New Member
    • Sep 2009
    • 3

    Web page form is not sending email

    Hi,

    I have been encountering problems with my web page which is supposed to send email, and wondered if anybody can help find error.

    Initially I had all codes in one page and on click of Submit it would send email.
    But then I wanted to give a user an opportunity to go back and edit the entries if incorrect before submitting. I separted the codes into two pages.
    On the second page when Submit button is clicked it should send email. But it is not working.
    My code in the second page is following. Can anybody help please:

    Code:
    <style type="text/css">
    <!--
    .style1 {color: #FF0000}
    -->
    </style>
    <? 
     if (!isset($Submit)) 
     ?>
    <table width=570 border=0 align=center cellpadding="0" cellspacing="0" bordercolor="#eaeaea"> 
      <form action="?do=river-ride_pay" method="post" enctype="multipart/form-data" name="form1" id="form1" /> <tr> 
        <td bgcolor="#eaeaea" width="5"></td> 
        <td bgcolor="#eaeaea"><p><b>YOUR PROFILE </b></p></td> 
        <td bgcolor="#eaeaea" width="5"></td> 
      </tr> 
      <tr>  
      <tr> 
        <td width="5" background="http://crca.caloosahatchee.org/img/tablebgrwr.jpg"></td> 
        <td> <p><b>You have entered the following information </b>(The information has been sent to your email address as well for your records)<strong>:</strong><br> 
            <br> 
            <?php echo "
    				
    						<b>Name:</b> ".stripslashes($first)." ".stripslashes($last)."<br>
    						<b>E-mail:</b> <a href=\"mailto:$email\">$email</a><br>
    						<b>Phone (day):</b> $home_phone<br>
    						<b>Phone (evening):</b> $mobile\n<br>
    						<b>Address:</b> $address, $city, $state $zip<br>
    						<b>City:</b> $city <br>
    						<b>State:</b> $state <br>
    						<b>Zip:</b> $zip <br>
    						<b>Fax:</b> $fax <br>
    						<b>Emergency Contact Name: </b> $emerg_contact<br>
    						<b>Emergency Phone Number: </b> $emerg_phone<br>
    						<b>Shirt Size: </b> $shirt<br>
    						<b>Amount:</b> $amount_d<br>
    						<b>Miles: </b> $miles<br>
    						<b>CRCA Membership: </b> $crca_mem<br> "; ?> 
          <p>Please check if the information you have provided is correct, if not <a href='?do=river-ride&first=<?php echo"$first"; ?>&last=<?php echo"$last"; ?>&email=<?php echo"$email"; ?>&home_phone=<?php echo"$home_phone"; ?>&mobile=<?php echo"$mobile"; ?>&address=<?php echo"$address"; ?>&city=<?php echo"$city"; ?>&state=<?php echo"$state"; ?>&fax=<?php echo"$fax"; ?>&zip=<?php echo"$zip"; ?>&state=<?php echo"$state"; ?>&emerg_contact=<?php echo"$emerg_contact"; ?>&emerg_phone=<?php echo"$emerg_phone"; ?>&shirt=<?php echo"$shirt"; ?>&amount=<?php echo"$amount"; ?>&miles=<?php echo"$miles"; ?>&crca_mem=<?php echo"$crca_mem"; ?>'>Go Back and Correct</a>!</p> 
          <p align='center'> 
            <input type="submit" name="Submit" value="Submit" class="normal" /> 
            </form> </td> 
        <td width="5" background="http://crca.caloosahatchee.org/img/tablebgrwl.jpg"></td> 
      </tr> 
      <tr> 
        <td><img src="http://crca.caloosahatchee.org/img/tablebgl.jpg"></td> 
        <td background="http://crca.caloosahatchee.org/img/tablebgrb.jpg"></td> 
        <td><img src="http://crca.caloosahatchee.org/img/tablebgr.jpg"></td> 
      </tr> 
    </table> 
    <?php
    		
    		
    			$date=date("Y-m-d");
    			$id=date("Y-m-d H:i:s");
    				
    			$id_array=explode(" ", $id);  
    			$id1=explode("-", $id_array[0]);
    			$id2=explode(":", $id_array[1]);
    			$id=$id1[0].$id1[1].$id1[2].$id2[0].$id2[1].$id2[2];
    			
    	$reg1="insert into donors values ('$id','$date','$last','$first','$email','$address','$city','$state','$zip','$home_phone','$mobile','$fax','emerg_contact','emerg_phone','shirt','miles','crca_mem','$amount_d')"; 
    		
    		$query1=mysql_query($reg1);
    			
    		if (!$query1) 
    		{
    			echo "Can't register in donors";
    			include("http://crca.caloosahatchee.org/includes/close.php");
    			exit;
    		}
    	
    
    		// sending confirmation messages
    			if ($email<>NULL) 
    			{
    				$header = "Content-Type: text/html; charset=iso-8859-1\r\n";
    				
    				$message = "Dear $first $last, \n\n";
    				$message .= "Thank you for your great interest in participating in our 13th Annual Caloosahatchee River Ride Event! \n\n";
    				$message .= "Following is your profile information you submitted to us:\n\n";
    				$message .= "Email: $email\n";
    				$message .= "Phone (day): $home_phone\n";
    				$message .= "Phone (evening): $mobile\n";
    				$message .= "Address: $address\n";
    				$message .= "City: $city\n";
    				$message .= "State: $state\n";
    				$message .= "Zip Code: $zip\n";
    				$message .= "Fax: $fax\n";
    				$message .= "Emergency Contact Name: $emerg_contact\n";
    				$message .= "Emergency Phone Number: $emerg_phone\n";
    				$message .= "Shirt Size: $shirt\n";
    				$message .= "Amount: $amount_d\n";
    				$message .= "Miles: $miles\n";
    				$message .= "CRCA Membership: $crca_mem\n\n";
    
    				$message .= "If you have not yet paid your registration fee of $25.00, please do so now at https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8215269	 \n\n";
    				$message .= "As soon as we receive your payment we will confirm your registration to be complete. Thank you!\n\n";
    
    				$message .= "Sincerely,\n";
    				$message .= "CRCA Administration \n\n";
    				//$message .= "P. S.<br>";
    				//$message .= "Your payment amount: $ $amount_d<br>";
    				//$message .= "Date:".date("Y-m-d")."<br>";
    				
    				$from = "From: riverride09@caloosahatchee.org\n";
    				$reply = "Reply-To: riverride09@caloosahatchee.org";
    				
    				$header .= $from . $reply;
    				
    				$sentmail = mail($email, "River Ride Registration Confirmation", $message, $header);
    			}
    			
    			if ($sentmail) 
    			{
    				//$message = "*** THIS IS A POSSIBLE PAYMENT CONFIRMATION FOR RIVER RIDE EVENT *** \n\n";
    				$message = "River Ride Registration Confirmation message sent by $first $last on ".date("Y-m-d")."\n\n";
    				$message .= "Other Details are:\n";
    				$message .= "Email: $email\n";
    				$message .= "Phone (day): $home_phone\n";
    				$message .= "Phone (evening): $mobile\n";
    				$message .= "Address: $address\n";
    				$message .= "City: $city\n";
    				$message .= "State: $state\n";
    				$message .= "Zip Code: $zip\n";
    				$message .= "Fax: $fax\n";
    				$message .= "Emergency Contact Name: $emerg_contact\n";
    				$message .= "Emergency Phone Number: $emerg_phone\n";
    				$message .= "Shirt Size: $shirt\n";
    				$message .= "Amount: $amount_d\n";
    				$message .= "Miles: $miles\n";
    				$message .= "CRCA Membership: $crca_mem\n\n";
    				$message .= "Sincerely,\n";
    				$message .= "CRCA Administration\n";
    				$from = "From: riverride09@caloosahatchee.org\n";
    				$reply = "Reply-To: riverride09@caloosahatchee.org";
    				$header = $from . $reply;
    				$email2 = "riverride09@caloosahatchee.org";
    				mail($email2, "River Ride Registration Confirmation", $message, $header);
    			}
    	?>
    Last edited by Markus; Sep 21 '09, 05:57 PM. Reason: Added [code
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    What part isn't working exactly? Do you get any errors?

    Comment

    • TheServant
      Recognized Expert Top Contributor
      • Feb 2008
      • 1168

      #3
      When something like this doesn't work, try do something simple. Try send a simple email and then add each component so you can narrow it down to whether it's the message, to, email, or from component that it stopping it from working.

      Comment

      • prabirchoudhury
        New Member
        • May 2009
        • 162

        #4
        Web page form is not sending email

        hey

        i think you are having problem with first argument with if ($email<>NULL) argument. it is returning false all the time coz it is not a valid argument for checking "NULL" value in php.

        you could try with those bellow
        Code:
        if (isset($email){
         	
         	}
        if (!empty($email){
         	
         	}
        if (!is_null($email){
         	
         	}
        you dont have any problem with mail() function.

        have a look on this


        cheers

        :)

        Comment

        • Dormilich
          Recognized Expert Expert
          • Aug 2008
          • 8694

          #5
          two further ways to test for null:
          Code:
          if ($email != NULL) // also triggered by 0, false, ""
          
          if ($email !== NULL) // must match the type also

          Comment

          • nargis2009
            New Member
            • Sep 2009
            • 3

            #6
            Php

            Originally posted by Markus
            What part isn't working exactly? Do you get any errors?
            I am a beginner, and it is hard for me to find the error in codes once the codes get complicated. In fact is not showing any error when I browse the pages. It is just not sending email.

            When I first had all the codes is one page, I had no problem, it would send email just fine. But when i am trying to separate codes into two or three pages it is not working any more.
            My only purpose of separating pages is not let the information emailed right away after submission as it would do when I had just one page.

            Nargis

            Comment

            • prabirchoudhury
              New Member
              • May 2009
              • 162

              #7
              you are right, you have an logical problem thats why it is not showing any error. coz how is ur argument working if the first if ($email<>NULL) is false then it would not assign "$sentmail" variable and then if ($sentmail) is false so no mail is being sent . both cases it is not going inside the if statement.

              here you go

              1. you are getting all the personal details along with $email from some form submit or other place
              2. then why you are checking $mail <> NULL then ISSET() or empty()
              3. I don’t think you are getting all this details from database then you could check <> NULL value
              4. but you are inserting those details into table first and then.

              my understanding is

              a. validate the email address first that is assign to $email
              b. check $email if (isset($email)) {} or if (!empty($email) ){}

              then you should be alright

              cheers
              :)

              Comment

              • nargis2009
                New Member
                • Sep 2009
                • 3

                #8
                PHP code

                Hi, Prabir,
                Thank you all for your help. I tried all your suggestions, but I seem not succeeding.

                I think I have complicated everything by trying to split the codes into 3 pages.
                My objective was:
                Page1- to fill out the form - submit
                Page2- if the infomation is incorrect - go back and correct - but if correct click on the 'submit' to send email
                Page3 - make payment

                I have attached the codes of the 3 pages, so as to make it more clear.
                If anybody has time, I would greatly appreciate your response.

                Thank you.
                Nargis
                Attached Files

                Comment

                • TheServant
                  Recognized Expert Top Contributor
                  • Feb 2008
                  • 1168

                  #9
                  OK. It looks like you are sending your email from page one, so it's really page 1 that is not working. Before I go much further, can you confirm that besides the email not sending it is going onto the next page and all else is good?

                  If so, try and replace your email line with an echo and see if it fires. If so, it's your mail function and if not, obviously it's surrounding code.

                  Just focus on one page at a time, and first page is a good start.

                  Comment

                  Working...