April 18, 201313 yr I am killing myself trying to fix my HTML email form. Sorry I cannot post links as I have not enough post. I have uploaded my HTML file so I can narrow it down to my PHP file. Code starts at line 261. Many Thanks,David Reilly index.html
April 18, 201313 yr Feel free to post your link using the following workaround: www[dot]example[dot]com/your/webpage[dot]html Apologies for the inconvenience - we've had trouble with spam recently. As for your question - well, what is your question?!
April 19, 201313 yr Author Hi there, Thank you for the workaround. I cannot get my company’s website email form working. I have been successful with other clients but cannot get it working for my website. First step I was trying to do is find out if the HTML I used is right, then check the PHP file for problems. URL: www[dot]aspirationscotland[dot]co[dot]ukMany Thanks,David Reilly
April 19, 201313 yr You haven't set any name attributes on your form elements. The name attribute is what's used by your server side script (e.g. PHP) to grab the data. This: <input type="text" value="" class="input"> Should be: <input type="text" value="" class="input" name="input1"> The name attribute allows PHP to grab the inputs value, for example: <?php $input1 = $_GET['input1']; //stores value entered in input to variable $input1 ?> Alternatively, add an ID to your input if you wish to manipulate the element with JavaScript: <input type="text" value="" class="input" id="input1" name="input1"> Hope this helps! Lyndsey.
April 19, 201313 yr Author Hi Lyndsey, Thank you for the advice. I will try this later tonight and update you. Hopefully I have not wasted your time Lyndsey? Maybe working too long and I am making mistakes.Many Thanks,David
April 19, 201313 yr Author Still not working, I am sure it is my fault. I am still new here, is there any why to show my PHP file?
April 19, 201313 yr Does the PHP contain links - is that the problem with posting the code? You could always paste it on a website like pastebin and post a workaround link. Sorry about this...
April 19, 201313 yr Author Hope this helps Posted attached PHP file twice. Sorry everyone FormToEmail.php FormToEmail.php Edited April 19, 201313 yr by DavidAndrewReilly
April 19, 201313 yr The names of your input fields are how you access them via $_POST. In your php file you use $_POST['email'], $_POST['name'] etc. but in your form you have named them input1, input2 etc. You need to change your input fields to ensure the name value equals what you are referencing via $_POST e.g. <input type="text" value="" class="input" name="name"> <input type="text" value="" class="input" name="email"> <textarea name="message"> Also you really need to do some sanitisation on these fields before sending them - you are opening yourself up to some security issues and ALOT of spam.
April 20, 201313 yr Author Sorry it is me again. I have uploaded my HTML file and PHP file. I dont know why this is causing me so much trouble. I do prefer design to coding but not sure why I am so stuck. I have used another PHP file from the last time. Many Thanks, index.html send_form_email.php
April 20, 201313 yr There are a couple of errors I can see right off the bat: $last_name = $_POST['email']; // required This line sets a $last_name variable to the value that is entered in the email input field - do you really want to do that? $email_message .= "name: ".clean_string($name)."\n"; You're probably getting a few Call to Undefined Function errors. clean_string() is a user defined function which is not included in your php script. You need to create that function or use another method to secure your data. Look up strip_tags(). Also using preg_match to validate strings is not very efficient. For name and message you just want to make sure something is entered(if requried) and sanitise it with a few php functions.
April 21, 201313 yr Author Thank you everyone, I have still not got it working right but I am happy with all the help I have had on this form. I will come back to this again to finish it off when I have a little more time. Many Thanks,
Create an account or sign in to comment