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.

HTML forms - (probably) stupid question!

Featured Replies

Here's a silly question for you guys ...

 

In an HTML form, when you specify that the data should got to an email address

 

e.g. action="mailto:someone@whatever.org" how does the email actually get there? Surely it's not enough to just write this, it has to be connected to an email account at the sending end, surely?

 

I expect this shows a basic lack of understanding of how it all works, but I'm keen to be enlightened!

The mailto function opens the user's email client, like Outlook, and fills in the email with the data ready to send.

 

So this method doesn't work if the user is in an internet cafe or at a friend's house where there isn't an email client.

 

It's better to use a PHP web form where the data is sent to a PHP process code and the host's server sends it directly.

  • Author

Thanks for the reply. :)

 

OK, I think I get it. You're saying that even when it's in a form, mailto works the same as when you use it on the page, I can see how that wouldn't be ideal!

 

I'll have a think about the PHP bit and come back when I get it ...

Thanks for the reply. :)

 

OK, I think I get it. You're saying that even when it's in a form, mailto works the same as when you use it on the page, I can see how that wouldn't be ideal!

 

I'll have a think about the PHP bit and come back when I get it ...

 

Using mailto is pretty unsecure, but heres an example of sending form details using phps mail function

 

$to = "admin@mysite.com";//Where the email will go
$subject = "My website";//Subject of email

$name = (isset($_POST['name'])) ? htmlentities($_POST['name'],ENT_QUOTES,'UTF-8') : '';
$email = (isset($_POST['email'])) ? htmlentities($_POST['email'],ENT_QUOTES,'UTF-8') : '';
if($name && $email){
$message = "";
$headers = "";
$message .="
you have a new email from your website<br /><br />
Name:$name<br /><br />
E-mail:$email
";
/**Set headers**/
$headers .= "From:$name <$to>\r\n";
$headers .= "Content-Type:text/html; charset=utf-8\r\n";

if(@mail($to,$subject,$message,$headers)){
print 'Your message has been sent!';
}else{
print 'We have failed sending your message!';
//exit script
exit;
}
}

 

You will also wanna filter the name to contain just letters and numbers to prevent header injections which you can easily do like this

 

$name = preg_replace("^[A-Za-z0-9]","",$name);

Edited by webdesigner93

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.