Jump to content

Php Contact Form Question


Recommended Posts

I was wondering when one makes a php contact form. Is there a way to have in the e-mail all of the follow:Drop Down choiceRadio Bullet choiceNameE-mailMessageI'm trying to make one to replace my flash contact form, but I haven't messed with PHP any really, and wasn't sure if I have my coding right.Here is the PHP code that I am trying to use.

<?php  function spamcheck($field)	{	//filter_var() sanitizes the e-mail	//address using FILTER_SANITIZE_EMAIL	$field=filter_var($field, FILTER_SANITIZE_EMAIL);		//filter_var() validates the e-mail	//address using FILTER_VALIDATE_EMAIL	if(filter_var($field, FILTER_VALIDATE_EMAIL))	  {	  return TRUE;	  }	else	  {	  return FALSE;	  }	}    if (isset($_REQUEST['email']))	{	//if "email" is filled out, proceed  //check if the email address is invalid	$mailcheck = spamcheck($_REQUEST['email']);	if ($mailcheck==FALSE)	  {	  echo "Invalid input";	  }	else	{	//send email	$request = $_REQUEST['request'];	$type = $_REQUEST['type'];	$name = $_REQUEST['name'];	$email = $_REQUEST['email'];	$message = $_REQUEST['message'];	mail( "matt@mlhwebdesigns.com", "Contact Form", $request, $type, $name, $email, $message, "From: $email" );	echo "Thank you for your message!";	}  else  //if "email" is not filled out, display the form	{	echo "<form action="sendmail.php" method="post">	<label>Request</label><br />	 <select name="request">	  <option value="quote">I need a Free quote</option>	  <option value="designed">I need my web site designed</option>	  <option value="information">I need information about your other hosting plans</option>	  <option value="hosted">I need my web site hosted</option>	  <option value="upgrade">I to my upgrad my account</option>	  <option value="specials">I would like to know about your specials</option>	  <option value="support">I need support for my web site</option>	  <option value="update">I need my web site updated</option>	 </select><br />	 <input name="type" type="radio" value="Business Site" />Business Site	 <input name="type" type="radio" value="Religious Site" />Religious Site<br />	 <input name="type" type="radio" valie="Personal Site" />Personal Site	 <input name="type" type="radio" value="Other" />Other<br /><br />	 <label>Name:</label><br />	 <input maxlength="200" name="mame" type="text" /><br />	 <label>E-mail:</label><br />	 <input maxlength="200" name="email" type="text" /><br />	 <label>Message:</label><br />	 <textarea cols="40" name="message" rows="8"></textarea><br /><br />	 <input name="Submit" type="button" value="Send" />	</form>";	}  ?>

Thanks for any help that I get back,Matt

Link to post
Share on other sites

The third parameter of mail() is the contents of the message, just as one big string...http://www.php.net/manual/en/function.mail.phpSo you can just concatenate all your variables together into one string and send that as the third argument.

Link to post
Share on other sites
Matt I'm having similar problems. If you solve this can you let me know please? Cheers.
If I can I'll try and help you on yours. I'm not really good at PHP, but I guess I should learn that and the other stuff since I'm trying to do a web designing business.
Link to post
Share on other sites
The third parameter of mail() is the contents of the message, just as one big string...http://www.php.net/manual/en/function.mail.phpSo you can just concatenate all your variables together into one string and send that as the third argument.
I'm sure I'm miss reading this. So I would have what I want to be sent to me in the email and have this coding in there to separate it? \n. Is this right or am I way off base?
Link to post
Share on other sites

Sounds right. The example should help:

<?php// The message$message = "Line 1\nLine 2\nLine 3";// In case any of our lines are larger than 70 characters, we should use wordwrap()$message = wordwrap($message, 70);// Sendmail('caffeinated@example.com', 'My Subject', $message);?>

That would send an email with 3 lines in the body.

Link to post
Share on other sites

I think phpmailer class is better option than mail().Because there may be some problems with mail(). phpmailer is the best way to send mail using php script.you can download phpmailer class and use that with using the help file with that.If you use phpmailer, then you will never face spamming problem that is not sure in the case of mail().So, if you want to make your contact us form in a perfect way, then phpmailer is the best option for you.

Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...