Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    May 2010
    Location
    Saint Louis, MO
    Posts
    31
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Question My contact form isn't submitting the form correctly!

    Hi everybody - I've posted here a few times basically regarding this issue, and then I finally managed to fix it. However, today I made a mistake and began editing the wrong page, and saved it as the page that I really SHOULD have been editing, and it screwed up all of my code.

    Anyways, all of my PHP was correct for the page, before I saved it incorrectly. The form was submitted successfully and I had absolutely no problems. Here is the code for the ENTIRE page..

    Code:
    <?php
    
    if(isset($_POST['submit']) && $_POST[security] == "secure"  ){
    
    	$fromMail = $_POST['sendFromEmail'];
    	 $toMail = $_POST['sendToEmail'];
    	$email = $_POST['email'];
    	$message = $_POST['message'];
    
    	$headers = 'From: '.$fromMail.'' . "\r\n" .
       	 'Reply-To: '.$fromMail.'' . "\r\n" .
        	'X-Mailer: PHP/' . phpversion();
    		
    		header ('Location: http://www.reboundsusedbooks.com');
    		exit ();
    
    	if(mail("$toMail","$email",$message,$headers)){
    		echo("successfully sent mail to $toMail from $fromMail");
    	}
    	else{
    		 echo("Could not send mail to $toMail from $fromMail  ");
    	}
    
    }
    
    
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <style type="text/css">
    <!--
    td {
    	text-align: left;
    	vertical-align: top;
    	font-family:Tahoma;
    	font-size:11px;
    	color:#000000;
    }
    a {
    	text-decoration: underline;
    	color:#863A1C;
    }
    a.1 {
    	text-decoration: underline;
    	color:#000000;
    	font-weight:bold;
    }
    a.2 {
    	text-decoration: none;
    	color:#FDD4A0;
    }
    
    .t11 {
    	font-family: Tahoma;
    	font-size: 11px;
    	font-style: normal;
    }
    .style1 {color: #000000}
    #boldd {
    	font-weight: bold;
    }
    #as {
    	font-style: italic;
    }
    .k {
    	font-size: 9px;
    }
    #center {
    	text-align: center;
    }
    
    -->
    </style>
    
    <title>Contact Us - Rebounds Used Books</title></HEAD>
    <BODY BGCOLOR=#000000 LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>
    <center>
      <TABLE WIDTH=750 BORDER=0 CELLPADDING=0 CELLSPACING=0>
        <TR>
    		<TD height="100%">			<TABLE WIDTH=152 BORDER=0 CELLPADDING=0 CELLSPACING=0 height="100%">
    		  <TR>
    		    <TD> <IMG SRC="images/1.jpg" WIDTH=152 HEIGHT=64 ALT=""></TD>
    	      </TR>
    		  <TR>
    		    <TD height="100%  " background="images/2.jpg" WIDTH=152  ALT="">
    		      <div style="padding-right:25px;padding-left:21px;padding-top:10px " align="center">
    		        <img src="images/ballroomdancing.jpg">
    		        <div style="padding-top:0px ">
    		          <a href="#" class="1">The Complete Idiot's Guide to Ballroom Dancing -	2nd	Edition</a></div>
    		        <div style="padding-top:15px ">
    		          <img src="images/music.jpg">
    		          <div style="padding-top:0px ">
    		            <a href="#" class="1">Music: A Living Language</a>			</div>
    	            </div>
    		        <div style="padding-top:15px ">
    		          <img src="images/changeheart.jpg">
    		          <div style="padding-top:0px ">
    		            <a href="#" class="1">Change of Heart</a>			</div>
    	            </div>
    	          </div>
    		      
    		      
    	        </TD>
    	      </TR>
    		  <TR>
    		    <TD> <IMG SRC="images/3.jpg" ALT="" WIDTH=152 HEIGHT=70 border="0" usemap="#Map"></TD>
    	      </TR>
          </TABLE></TD>
    		<TD height="100%">			<TABLE WIDTH=439 BORDER=0 CELLPADDING=0 CELLSPACING=0 height="100%">
              <TR>
                <TD> <IMG SRC="images/7under.jpg" WIDTH=439 HEIGHT=52 ALT=""></TD>
              </TR>
              <TR>
                <TD> <IMG SRC="images/8e.jpg" WIDTH=439 HEIGHT=96 ALT=""></TD>
              </TR>
              <TR>
                <TD> <IMG SRC="images/9e.jpg" ALT="" WIDTH=439 HEIGHT=33 border="0" usemap="#Map3"></TD>
              </TR>
              <TR>
                <TD height="100%"> <TABLE WIDTH=439 BORDER=0 CELLPADDING=0 CELLSPACING=0 height="100%">
                  <TR>
                    <TD  height="100%"><TABLE WIDTH=21 BORDER=0 CELLPADDING=0 CELLSPACING=0 height="100%">
                      <TR>
                        <TD> <IMG SRC="images/13.jpg" WIDTH=21 HEIGHT=139 ALT=""></TD>
                      </TR>
    				  <TR>
                        <TD background="images/bak1.jpg" WIDTH=21 HEIGHT=100% ALT=""></TD>
                      </TR>
                      <TR>
                        <TD> <IMG SRC="images/12.jpg" WIDTH=21 HEIGHT=256 ALT=""></TD>
                      </TR>
                    </TABLE></TD>
                    <TD height="100%"> <TABLE WIDTH=400 BORDER=0 CELLPADDING=0 CELLSPACING=0 height="100%">
                      <TR>
                        <TD> <IMG SRC="images/1t1.jpg" WIDTH=400 HEIGHT=2 ALT=""></TD>
                      </TR>
                      <TR>
                        <TD   height="100%"> <TABLE WIDTH=400 BORDER=0 CELLPADDING=0 CELLSPACING=0 height="100%">
                          <TR>
                            <TD background="images/1bak1.jpg" WIDTH=398 HEIGHT=100% ALT="">
    						<div style="padding-top:40px;padding-left:20px" >
    
    						<form name ="emailForm" action="<?php echo($_SERVER['PHP_SELF'])?>" method="post">
                            <input type="hidden" value="customerservice@reboundsusedbooks.com"  name="sendFromEmail" id="sendFromEmail" width="100">
                            <input name="sendToEmail" input type="hidden" id="sendToEmail" width="100" initial value="Customerservice@reboundsusedbooks.com" >
                            
                                       
    <input name="email" id="email" size="100" style=" width:300px; height:18px; font-family:Tahoma; font-size:11px; color:#000; background-color:#D7BC92; border-color:#6D4C1E; border-width:1px; border-style:solid " initial value="Email Address">
    
    
    
    
    
    						<div style="padding-top:15px ">
    									<select style=" width:300px; height:18px; font-family:Tahoma; font-size:11px; color:#000; background-color:#D7BC92; border-color:#6D4C1E; border-width:1px; border-style:solid ">
    									  <option selected>Select a contact from the contact list.</option>
    									  <option>General Inquiries</option>
    									  <option>Sales</option>
    									  <option>Webmaster</option>
                                        </select>
    						</div>
    						<div style="padding-top:15px ">
                                                      <textarea name="message" style=" width:300px; height:60px; overflow:auto; font-family:Tahoma; font-size:11px; color:#000; background-color:#D7BC92; border-color:#6D4C1E; border-width:1px; border-style:solid ">Please type your message here.</textarea>
                                                      <div style="padding-top:5px;padding-right:78px " align="right">
                                                      <input name="security" type="hidden" id="security" value="<?php echo($_GET[security]); ?>">
                                                      <input name="submit" type="submit" id="submit" value="Submit">  
                                                      <span class="k">* After hitting the submit button, you will be redirected back to our homepage.</span>
    						</form></div>
    						
    							  </TD>
                            <TD > <TABLE WIDTH=2 BORDER=0 CELLPADDING=0 CELLSPACING=0 height="100%">
    	<TR>
    		<TD>
    			<IMG SRC="images/20.jpg" WIDTH=2 HEIGHT=105 ALT=""></TD>
    	</TR>
    	<TR>
    		<TD background="images/bak4.jpg" WIDTH=2 HEIGHT=100% ALT=""></TD>
    	</TR>
    	<TR>
    		<TD>
    			<IMG SRC="images/21.jpg" WIDTH=2 HEIGHT=72 ALT=""></TD>
    	</TR>
    </TABLE></TD>
                          </TR>
                        </TABLE></TD>
                      </TR>
                      <TR>
                        <TD> <IMG SRC="images/1t2.jpg" WIDTH=400 HEIGHT=20 ALT=""></TD>
                      </TR>
                      <TR>
                        <TD> <IMG SRC="images/18.jpg" WIDTH=400 HEIGHT=2 ALT=""></TD>
                      </TR>
                      <TR>
                        <TD><TABLE WIDTH=400 BORDER=0 CELLPADDING=0 CELLSPACING=0>
    	<TR>
    		<TD>
    			<IMG SRC="images/2t1.jpg" WIDTH=398 HEIGHT=2 ALT=""></TD>
    		<TD ROWSPAN=3 height="100%" background="images/2bak1.jpg">
    			<IMG SRC="images/2t3.jpg" WIDTH=2 HEIGHT=196 ALT=""></TD>
    	</TR>
    	<TR>
    		<TD background="images/2bak2.jpg" WIDTH=398 HEIGHT=176 ALT="">
    		<table width="100%"  border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="50%"><div style="padding-top:20px ">
    						<table width="100%"  border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><div style="padding-left:8px "><img src="images/2pic7.jpg"></div></td>
        <td><div style="padding-left:10px;padding-right:15px ">
    	<strong>
    	Mari Black<br>
    15.02.2004
    
    <br></strong>
    Vestibulum iaculis lacinia est. Proin dictum elementum velit. Fusce euismod consequat ante.
    
    	</div></td>
      </tr>
    </table>
    
    						</div>
    						<div style="padding-top:5px;padding-left:10px;padding-right:10px ">
    Lorem ipsum dolor sit amet, con- sectetuer adipiscing elit. Praesent vestibulum molestie lacus. Aenean nonummy hendrerit mauris... 
    </div>						</td>
        <td width="50%"><div style="padding-top:20px ">
    						<table width="100%"  border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><div style="padding-left:10px;padding-right:15px ">
    	<strong>
    	CONNECT WITH REBOUNDS<br></strong></div></td>
      </tr>
    </table>
    
    						</div>
    						<div style="padding-top:5px;padding-left:12px;padding-right:10px ">
    						  <p><span style="text-align: center"><img src="images/40px-Facebook_favicon.eps.png" width="40" height="40" /> Facebook</span></p>
    						  <p><span style="text-align: center"><img src="images/Twitter-Icon.png" width="40" height="40" /> Twitter</span></p>
    						  <p><span style="text-align: center"><img src="images/2076144144.png" width="40" height="40" /> Wordpress</span></p>
    						  </span></div></td>
      </tr>
    </table>
    
    		
    		</TD>
    	</TR>
    	<TR>
    		<TD>
    			<IMG SRC="images/2t2.jpg" WIDTH=398 HEIGHT=18 ALT=""></TD>
    	</TR>
    </TABLE></TD>
                      </TR>
                      
                    </TABLE></TD>
                    <TD> <TABLE WIDTH=18 BORDER=0 CELLPADDING=0 CELLSPACING=0 height="100%">
                      <TR>
                        <TD> <IMG SRC="images/14.jpg" WIDTH=18 HEIGHT=107 ALT=""></TD>
                      </TR>
    				  <TR>
                        <TD background="images/bak2.jpg" WIDTH=18 HEIGHT=100% ALT=""></TD>
                      </TR>
                      <TR>
                        <TD> <IMG SRC="images/15.jpg" WIDTH=18 HEIGHT=288 ALT=""></TD>
                      </TR>
                    </TABLE></TD>
                  </TR>
                </TABLE></TD>
              </TR>
              <TR>
                <TD> <IMG SRC="images/10.jpg" WIDTH=439 HEIGHT=19 ALT=""></TD>
              </TR>
              <TR>
                <TD background="images/11.jpg" WIDTH=439 HEIGHT=55 ALT="">
    			<div style="padding-top:8px; font-weight: bold; color: #FDD4A0;" align="center">
    			ReboundsUsedBooks.com © 2010 • <a href="/privacy/index.html" class="2">Privacy Policy</a> • <a href="/tos/index.html" class="2">Terms Of Use</a>			</div>
    			</TD>
              </TR>
            </TABLE></TD>
    		<TD height="100%">			<TABLE WIDTH=159 BORDER=0 CELLPADDING=0 CELLSPACING=0 height="100%">
              <TR>
                <TD><img src="images/4.jpg" width=159 height=64 alt=""></TD>
              </TR>
              <TR>
                <TD background="images/5.jpg" WIDTH=159 HEIGHT=100% ALT="">
    			<div style="padding-right:24px;padding-left:21px;padding-top:10px " align="center">
    			<img src="images/runawayjury.jpg">
    			<div style="padding-top:0px ">
    			  <a href="#" class="1">The Runaway Jury</a>			</div>
    			  <div style="padding-top:15px ">
    			  <img src="images/the7habits.jpg">
    			<div style="padding-top:0px "><a href="#" class="1">The 7 Habits of Highly Effective People</a></div>
    			  </div>
    			  			  <div style="padding-top:15px ">
    			  <img src="images/anseladams.jpg">
    			<div style="padding-top:0px ">
    			  <a href="#" class="1">The Ansel Adams Guide to Basic Techniques of Photography - Book 2</a>			</div>
    			  </div>
    			</div>
    			
    			
    			
    			</TD>
              </TR>
              <TR>
                <TD> <IMG SRC="images/6.jpg" ALT="" WIDTH=159 HEIGHT=70 border="0" usemap="#Map2"></TD>
              </TR>
            </TABLE></TD>
    	</TR>
    </TABLE>
      <p>&nbsp;</p>
    </center>
    <map name="Map">
      <area shape="rect" coords="46,15,91,34" href="http://www.reboundsusedbooks.com/books">
    </map>
    <map name="Map2">
      <area shape="rect" coords="59,15,104,31" href="http://www.reboundsusedbooks.com/books">
    </map>
    <map name="Map3">
      <area shape="rect" coords="35,4,112,20" href="http://www.reboundsusedbooks.com">
      <area shape="rect" coords="132,5,211,21" href="/books">
      <area shape="rect" coords="233,4,308,20" href="/about">
      <area shape="rect" coords="332,4,408,21" href="http://www.reboundsusedbooks.com/contact/index.php?security=secure">
    </map>
    </BODY>
    </HTML>
    Here is the code for the php.. As you can see, the PHP begins at the very top of the page, and then continues on towards the middle, where the actual contact form is..

    PHP Code:
    <?php

    if(isset($_POST['submit']) && $_POST[security] == "secure"  ){

        
    $fromMail $_POST['sendFromEmail'];
         
    $toMail $_POST['sendToEmail'];
        
    $email $_POST['email'];
        
    $message $_POST['message'];

        
    $headers 'From: '.$fromMail.'' "\r\n" .
            
    'Reply-To: '.$fromMail.'' "\r\n" .
            
    'X-Mailer: PHP/' phpversion();
            
            
    header ('Location: http://www.reboundsusedbooks.com');
            exit ();

        if(
    mail("$toMail","$email",$message,$headers)){
            echo(
    "successfully sent mail to $toMail from $fromMail");
        }
        else{
             echo(
    "Could not send mail to $toMail from $fromMail  ");
        }

    }


    ?>
    PHP Code:
    <form name ="emailForm" action="<?php echo($_SERVER['PHP_SELF'])?>" method="post">
                            <input type="hidden" value="customerservice@reboundsusedbooks.com"  name="sendFromEmail" id="sendFromEmail" width="100">
                            <input name="sendToEmail" input type="hidden" id="sendToEmail" width="100" initial value="Customerservice@reboundsusedbooks.com" >
                            
                                       
    <input name="email" id="email" size="100" style=" width:300px; height:18px; font-family:Tahoma; font-size:11px; color:#000; background-color:#D7BC92; border-color:#6D4C1E; border-width:1px; border-style:solid " initial value="Email Address">





                            <div style="padding-top:15px ">
                                        <select style=" width:300px; height:18px; font-family:Tahoma; font-size:11px; color:#000; background-color:#D7BC92; border-color:#6D4C1E; border-width:1px; border-style:solid ">
                                          <option selected>Select a contact from the contact list.</option>
                                          <option>General Inquiries</option>
                                          <option>Sales</option>
                                          <option>Webmaster</option>
                                        </select>
                            </div>
                            <div style="padding-top:15px ">
                                                      <textarea name="message" style=" width:300px; height:60px; overflow:auto; font-family:Tahoma; font-size:11px; color:#000; background-color:#D7BC92; border-color:#6D4C1E; border-width:1px; border-style:solid ">Please type your message here.</textarea>
                                                      <div style="padding-top:5px;padding-right:78px " align="right">
                                                      <input name="security" type="hidden" id="security" value="<?php echo($_GET[security]); ?>">
                                                      <input name="submit" type="submit" id="submit" value="Submit">  
                                                      <span class="k">* After hitting the submit button, you will be redirected back to our homepage.</span>
                            </form></div>
    Everything seems okay to me, but I'm not an expert! Any help would be greatly appreciated.

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,471
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    The redirect in the middle looks wrong to me ...

    I think it should be after the email is sent ... but there's another catch,
    you can't redirect if you've echoed some text. So either redirect to
    a thankyou page, or display the "successful" message, but not both.

    In my example, I moved the redirect, but commented it out, because you're
    already displaying the "successful" message. Also, the quotes removed from
    the variables in mail().

    Try my version:
    PHP Code:
    <?php

    if(isset($_POST['submit']) && $_POST[security] == "secure"  ){

        
    $fromMail $_POST['sendFromEmail'];
        
    $toMail $_POST['sendToEmail'];
        
    $email $_POST['email'];
        
    $message $_POST['message'];

        
    $headers 'From: '.$fromMail.'' "\r\n" .
            
    'Reply-To: '.$fromMail.'' "\r\n" .
            
    'X-Mailer: PHP/' phpversion();

        if(
    mail($toMail,$email,$message,$headers)){
            echo(
    "successfully sent mail to $toMail from $fromMail");
        }
        else{
             echo(
    "Could not send mail to $toMail from $fromMail  ");
        }

            
    // header ('Location: http://www.reboundsusedbooks.com');
            // exit ();

    }


    ?>


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •