Jump to content

Need help with php form


pburgner

Recommended Posts

Hello,

I've been working on this for quite awhile now and stumped, someone helping me with this previously proved it worked perfectly on their server.. so I think my server GoDaddy is just a bit more fussy about proper coding, so I'm sure the problem must lie in something that's just not coded in ideal etiquette, but I can't find it..

 

I've got a form (link to follow), which is working partially - it sends me email as it should showing the different fields in my form: First Name, Last Name, Address Line 1, Address Line 2, City, State, ZipCode, Email, Phone, Message - but the only inputted fields that come through are first name and last name... although mysteriously once the contents of the email and message fields came through too, but the remaining 99 times I tried only the contents of first name and last name came through.  You can find the form here:

 

www.northernlightswebsitedesign.com/test6.html  (go to the "Rates & Contact" tab)

 

which uses the thanks.php script attached. 

 

Any advice would be so appreciated!!!!

 

 

 

 

 

 

 

[attachment deleted by admin]

Link to comment
Share on other sites

Ok here's the script for the form, followed by the php script:

 

 


<form class="appnitro">
    	            <ul >
			<li id="li_1" >
				<label class="description">*Name </label>
				<span>
				<input name= "First Name" type="text" class="element text" id="FirstName" onblur="MM_validateForm('First Name','','R');return document.MM_returnValue" value="" size="10" maxlength="200" />
				<label for="FirstName">First</label>
				</span>
				<span>
				<input name= "Last Name" type="text" class="element text"  id="LastName" onblur="MM_validateForm('Last Name','','R');return document.MM_returnValue"   maxlength="200" size="25" value="" />
				<label for="LastName">Last</label>
				</span> 
			</li>		
                                <li id="li_2" >
				<label class="description">Address </label>
					<div>
					<input id="AddressOne" name="Address Line 1" class="element text large" value="" type="text" />
					<label for="AddressOne">Street Address</label>
					</div>

                                               <div>
                                               <input id="AddressTwo" name="Address Line 2" class="element text large" value="" type="text" />
				       <label for="AddressTwo">Address Line 2</label>
					</div>

                        <div class="left">
                        <input id="City" name="City" class="element text medium" value="" type="text" />
					<label for="City">City</label>
					</div>

					<div class="right">
					<input id="State" name="State" class="element text medium" value="" type="text" />
					<label for="State">State / Province / Region</label>
					</div>

					<div class="left">
					<input id="ZipCode" name="Zip Code" class="element text medium" maxlength="15" value="" type="text" />
					<label for="ZipCode">Postal / Zip Code</label>
					</div>

					<div class="right">
					<select class="element select medium" id="Country" name="Country"> 
					<option value="" selected="selected"></option>
                                                <option value="United States" >United States</option>
				        </select>
				<label for="Country">Country</label>
				</div> 
                </li>		
        		<li id="li_3" >
                	<div class="left">
				<label class="description" for="Phone">Phone </label>
				<input id="Phone" name="Phone" class="element text medium" type="text" value="" /> 
				</div> 
				<div class="right">
                    <label class="description" for="Email">*Email </label>
				<input name="Email" type="text" class="element text medium" id="Email" onblur="MM_validateForm('Email','','RisEmail');return document.MM_returnValue" value="" /> 
				</div> 
			</li>		
                <li id="li_6" >
				<label class="description" for="Message">*Message </label>
				<div>
				<textarea name="Message" class="element textarea medium" id="Message" rows="7" cols="38" onblur="MM_validateForm('Message','','R');return document.MM_returnValue"></textarea> 
			    </div> 
			</li>
			<li class="buttons">
                	<center>
		    	<input id="btn" class="button_text" type="button" name="send" value="Submit" /> 
                    </center>
                    <script type="text/javascript"> 
                    $("#btn").click(function () { 
					var fname	=	document.getElementById('FirstName').value;
					var lname	=	document.getElementById('LastName').value;
					var adrone	=	document.getElementById('AddressOne').value;
					var adrtwo	=	document.getElementById('AddressTwo').value;
					var city	=	document.getElementById('City').value;
					var state	=	document.getElementById('State').value;
					var zipcode	=	document.getElementById('ZipCode').value;
					var country	=	document.getElementById('Country').value;
					var phone	=	document.getElementById('Phone').value;
					var email	=	document.getElementById('Email').value;
					var msg		=	document.getElementById('Message').value;
					if(fname=="")
					{
						alert("Name could not be empty");
					}
					else if(email=="")
					{
						alert("Email could not be empty");
					}
					else if(msg=="")
					{
						alert("Message could not be empty");
					}
					else
					{
						var val_goes	=	"<a href=thanks.php?fname=" + fname + "&lname=" + lname + "&adrone=" + adrone + "&adrtwo=" + adrtwo + "&city=" + city + "&state=" + state + "&zipcode=" + zipcode + "&country=" + country + "&phone=" + phone + "&email=" + email + "&msg=" + msg + ">Thank You</a>"
						$(val_goes).fancybox({ 
							'overlayShow': true,
							'width': 482, 
							'height': 290, 
							'scrolling': 'no',
							'autoScale': false, 
							'transitionIn': 'none', 
							'transitionOut': 'none', 
							'type': 'iframe',
						}).click();
					}
                    });
            	    </script> 
        
                    
			</li>
            </ul>
        </form>

 

AND HERE's THE PHP SCRIPT:

 

<?php 
	$email		=	$_REQUEST['email'];
	$name		=	$_REQUEST['fname'] . ' ' . $_REQUEST['lname'];
	$address	=	$_REQUEST['adrone'] . ' ' . $_REQUEST['adrtwo'];
	$city		=	$_REQUEST['city'];
	$state		=	$_REQUEST['state'];
	$zipcode	=	$_REQUEST['zipcode'];
	$country	=	$_REQUEST['country'];
	$phone		=	$_REQUEST['phone'];
	$msg		=	$_REQUEST['msg'];
	$subject	=	$name . " send you message from Northern Lights Website Design";
	$messageproper ="\n\n" .
	"Name: " .
	$name .
	"<br>" .
   "Address: " .
   $address .
  "<br>" .
	   "City: " .
	   $city .
  "<br>" .
	   "State: " .
	   $state .
  "<br>" .
	   "Zip Code: " .
	   $zipcode .
  "<br>" .
	   "Country: " .
	   $country .
  "<br>" .
	   "Phone: " .
	   $phone .
  "<br>" .
	   "Email: " .
	   $email .
	  "<br>" .
  "Message: " .
  "<br>" .
  $msg .
  "<br>" .
  "\n\n" ;
mail('paula@northernlightswebsitedesign.com',$subject,   
    $messageproper,   
    "From:<paula@northernlightswebsitedesign.com>\n" . 
    "MIME-Version: 1.0\n" .   
    "Content-type: text/html; charset=iso-8859-1");	
?>

 

 

 

Link to comment
Share on other sites

that is correct, the name attribute is not being used (although just to be sure I tried making them match and it still didn't work).. I checked for spaces too and didn't find anything out of place here, but you never know sometimes these type errors are hard to pinpoint.. it's just so bizarre only the first name and last name come through consistently ok, and (I didn't realize this before to mention it but) part of the address line 1 comes through - for example if I put "P.O. Box 90" in the address line 1, only "P.O." comes through in the contents of the email.. it doesn't go past the space... maybe this is a clue?

 

 

Link to comment
Share on other sites

OK I've figured out then as soon as a space is encountered in the form's contents - the php script doesn't process the rest of the form and only sends me an email with the contents of the form, up until the space was entered.  So something in my code does not like spaces in the forms content fields.  How do I fix this?  I'm totally stumped!!!

Link to comment
Share on other sites

You have to urlencode($strings) in query strings.

 

<a href=thanks.php?fname=" + fname + "&lname=" + lname + "&adrone=" + adrone + "&adrtwo=" + adrtwo + "&city=" + city + "&state=" + state + "&zipcode=" + zipcode + "&country=" + country + "&phone=" + phone + "&email=" + email + "&msg=" + msg + ">Thank You</a>"

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.