pburgner Posted June 13, 2011 Share Posted June 13, 2011 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] Quote Link to comment https://forums.phpfreaks.com/topic/239199-need-help-with-php-form/ Share on other sites More sharing options...
Pikachu2000 Posted June 13, 2011 Share Posted June 13, 2011 You'll get a better response by posting the code for the form and the processing script in the thread, within . . . BBCode tags. Most people won't bother to download attachments. Quote Link to comment https://forums.phpfreaks.com/topic/239199-need-help-with-php-form/#findComment-1228923 Share on other sites More sharing options...
pburgner Posted June 13, 2011 Author Share Posted June 13, 2011 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('[email protected]',$subject, $messageproper, "From:<[email protected]>\n" . "MIME-Version: 1.0\n" . "Content-type: text/html; charset=iso-8859-1"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/239199-need-help-with-php-form/#findComment-1228929 Share on other sites More sharing options...
Pikachu2000 Posted June 13, 2011 Share Posted June 13, 2011 The name= attributes of the form fields must match the indices of the $_REQUEST array that you're using, and should not have spaces. I.E. $_REQUEST['email'] would correspond to the field with the attribute name="email", etc. Quote Link to comment https://forums.phpfreaks.com/topic/239199-need-help-with-php-form/#findComment-1228935 Share on other sites More sharing options...
kenrbnsn Posted June 13, 2011 Share Posted June 13, 2011 The OP's code shows that the target of the form is being created & populated via Javascript, so that the name attribute has no bearing in this case. Ken Quote Link to comment https://forums.phpfreaks.com/topic/239199-need-help-with-php-form/#findComment-1228945 Share on other sites More sharing options...
Pikachu2000 Posted June 13, 2011 Share Posted June 13, 2011 Ah, yes. I missed that when I thought I had spotted the obvious problem . . . Quote Link to comment https://forums.phpfreaks.com/topic/239199-need-help-with-php-form/#findComment-1229131 Share on other sites More sharing options...
pburgner Posted June 13, 2011 Author Share Posted June 13, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/239199-need-help-with-php-form/#findComment-1229249 Share on other sites More sharing options...
pburgner Posted June 18, 2011 Author Share Posted June 18, 2011 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!!! Quote Link to comment https://forums.phpfreaks.com/topic/239199-need-help-with-php-form/#findComment-1231350 Share on other sites More sharing options...
xyph Posted June 18, 2011 Share Posted June 18, 2011 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>" Quote Link to comment https://forums.phpfreaks.com/topic/239199-need-help-with-php-form/#findComment-1231381 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.