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.

Please Help With Simple Php Contact Form!

Featured Replies

Hi All,

 

I'm sure you get this all a lot but I'm struggling to get a simple contact form to work. Here's the html side of things:

 

------------------------------------------------------------------------------------------------------------------

 

<form action="sendmail.php" method="post" name="ContactForm" id="ContactForm">

<div class="col1">

<div class="row">

<input name="name" type="text" class="input" id="name" value="Name:" />

</div>

<div class="row">

<input name="email" type="text" class="input" id="email" value="Email:" />

</div>

</div>

<div class="col2">

<div class="row1">

<textarea name="message" cols="1" rows="1" id="message">Message:</textarea>

<br />

<div class="div">

<input type="submit" name="submit" value="Submit" class="submit-button" />

</div>

 

 

------------------------------------------------------------------------------------------------------------------

 

which can be found at: http://www.stleonardshouse.co.uk/contact.html

 

now I have tried a hundred different php scrips to get this SIMPLE form to work, with no luck. I need the users name, email and message to be sent to email of enquiries@stleonardshouse.co.uk with the subject of 'Enquiry from St Leonard's House Website. If they dont enter an email I want it to display error.html and if its successful I need it to display thanks.html or something along those lines. Thats it! I'm not really worried about too much validation or spam protection or anything too complex, I just need something simple.

 

I was wondering if my server had anything to do with it and found this page on my hosts tech support pages:

 

http://www.fasthosts.co.uk/knowledge-base/?article_id=70

 

 

I do not have much experience with PHP scripting and I know someone out there could clear up this confusion for me in minutes with a simple script that I can upload and get this thing working once and for all!

 

Many thanks in advance,

Daniel

Hi there.

 

I think This is what you are looking for.

 

It's a solution posted on this forum by one of the members.

 

HTH

 

Scott

The page that you linked to: http://www.fasthosts.co.uk/knowledge-base/?article_id=70

 

Has the solution on it.

 

<?
ini_set("sendmail_from", " user@yourdomain.com ");

mail( "yourname@yourdomain.com", "Feedback Form

results",$_POST['message'], "From: $_POST['email']", "-fuser@yourdomain.com" );

header( "Location: http://www.yourdomain.com/thankyou.html" ); ?>

 

you need to save this as sendmail.php

 

You will have to change the urls to point the the right things and change "-fuser@yourdomain.com" to something like

"-f".$_POST['name']

I think? I think to use the from name you need the -f.

 

"Feedback Form results" is the subject line

 

The full details of the php mail function are here: http://uk.php.net/manual/en/function.mail.php

  • Author

<?php

ini_set("sendmail_from", "enquiries@stleonardshouse.co.uk");

mail("enquiries@stleonardshouse.co.uk", "Enquiry From St Leonard's House Website",

$_POST['message'], "From"$_POST['email'], "Name"$_POST['name']  "-f"enquiries@stleonardshouse.co.uk" );

header( "Location:http://www.stleonardshouse.co.uk/thanks.html" ); 

?>

 

Ive used this code in sendmail.php and it still doesnt work. The hosting company states:

 

'In order for the script to work, you need to specify, via a fifth -f parameter, the domain from which the mail is being sent. The PHP component uses SMTP, and all Fasthosts' SMTP servers have filters which ensure that the data returned by either the first or fifth mail parameter relates to one of your domains hosted by Fasthosts. The final part of the script thanks the visitor for the message. This is done by sending an HTTP header back to the visitor's browser telling it to load a file called thankyou.html from your domain. The header function allows you to send any HTTP header back to the browser.

 

I'm not sure what is wrong here... please help!

Thanks

"-f"enquiries@stleonardshouse.co.uk" ?

shouldn't that be "-fenquiries@stleonardshouse.co.uk" according to the fasthosts guide?

  • Author
"-f"enquiries@stleonardshouse.co.uk" ?

shouldn't that be "-fenquiries@stleonardshouse.co.uk" according to the fasthosts guide?

 

Yes, but it doesnt work either! Can anyone help me please?!

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.