Jump to content

Recommended Posts

This is my first trip into the magical land of PHP.

 

I successfully wrote 2 different forms for a friend of mine, and they both use the mail(). They work correctly. Now that the scripts work, I am wondering how to make them secure. I just want to make sure that my server is not used to send SPAM.

 

Here is the code for the one form:

<?php
  
$name=$_REQUEST['name'];
$cell=$_REQUEST['cell'];
$email=$_REQUEST['email'];
$address=$_REQUEST['address'];
$city=$_REQUEST['city'];
$state=$_REQUEST['state'];
$zip=$_REQUEST['zip'];
$areas=$_REQUEST['areas'];
$propertytype=$_REQUEST['propertytype'];
$pricerange=$_REQUEST['pricerange'];
$timeframe=$_REQUEST['timeframe'];
$questions=$_REQUEST['questions'];

  $toaddress = 'toaddress@mailserver.com';
  $subject = 'Ideal Home Client Response '.$name;
  $mailcontent = 'Customer name: '.$name."\n"
  				.'Customer cell: '.$cell. "\n"
                .'Customer email: '.$email."\n"
			.'Customer address: '.$address."\n"
			.'Customer city: '.$city."\n"
			.'Customer state: '.$state."\n"
			.'Customer zip: '.$zip."\n"
			.'Customer areas of interest: '.$areas."\n"
			.'Customer looking for: '.$propertytype."\n"
			.'Customer price range: '.$pricerange."\n"
			.'Customer timeframe: '.$timeframe."\n"
			.'Customer questions / comments: '.$questions."\n";

                
  $fromaddress = 'From: IdealHome';

  mail($toaddress, $subject, $mailcontent, $fromaddress);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Thank You</title>
</head>
<body>
      <h3>Thank You!</h3>
      <p>Your Ideal Home request has been sent successfully!</p>

</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/120871-securing-an-email-form/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.