Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Email Form Hell

Featured Replies

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

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?!

  • 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]uk

Many Thanks,

David Reilly

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.

  • 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

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.

  • 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

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.

  • 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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.