Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

php mail form


  • Please log in to reply

#1
TaNkZ101

TaNkZ101

    Member

  • Member
  • PipPipPip
  • 327 posts
I'm having a hard time finding a php script which would allow users to fill a form on my site and have it send the content to my email address, BUT that it also checks if the email address that the user inputs is existing. also, need a clear button (but i could prob figure it out myself), and, when clicked "submit", i need it to show a message on the same page (so i don't have to create another file just for it) for 2 seconds, before redirecting to the contact page at the beginning. i spent about an hour searching for one but can't find it, does anyone here have one?
  • 0

Advertisements


#2
Major Payne

Major Payne

    Retired Staff

  • Retired Staff
  • 5,307 posts
Are you by any chance using a paid hosting service? If so, most have a Form Utility you can use to set your page up just the way you want. Check the Help/How to Use for the utility if you do have CPanel.

There are many Email PHP scripts out there, but beware that many are not as secure as some. Got to go to VA, but will try to track down one or two scripts for you if you do not have free hosting and a CPanel Form Utility.

Maybe someone else will come up with the info you need while I'm gone.

Ron
  • 0

#3
TaNkZ101

TaNkZ101

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 327 posts
no, i'm not using ANY hosting service for now, am still building the basics of my site. when i finish my site about 80-90%, i think i'll go for gtg hosting (i hear it's a really good deal and see it is). does the cpanel that gtg hosting have such an option?

p.s. also i'm gonna need some radio buttons in it, and in the email it sends me it should tell me something that i determine it to say when a certain radio button is checked. reason for all this pickiness is because i'll start a web design company with a few guys, and wouldn't want to get AS MUCH spam as i would if i didn't go through all these measures. also, the radio buttons would be like: web design, logo design, banner design etc

Edited by TaNkZ101, 10 May 2006 - 11:51 AM.

  • 0

#4
Michael

Michael

    Retired Staff

  • Retired Staff
  • 1,869 posts
I had a good look into this when I was putting an email forum togeather for my site. As it turned out there is no way to verify if an e-mail exists short of sending an e-mail to it asking for a responce of some sort. There are scripts that try to do something in the way of working out if the domain is valid, but they can end up blocking real e-mail adress and not the spamers.

I seteled for a very simple form you can see it in action on my e-mail page http://site.frih.net/email.php it is easy to add more things to it, and I will help you with that if you want. The form, error page, sucess page, and script is all in the same file 3KB file.

Edited by Michael, 13 May 2006 - 05:13 AM.

  • 0

#5
TaNkZ101

TaNkZ101

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 327 posts
i realize i should've put this earlier, but i guess i forgot: i want one with an anti-spam system that you see in many places- i want it to show a random picture with a number on it (like when sigining up for a hotmail email address, or at http://ec-labs.com/contact.php. so then i'll drop the email-check, thx for the info @Michael.

Conclusion: Now that I know what I want, I need a php mail form (script) that will allow people to send me an email with php and has radio/check buttons (at least one must be checked/selected!), and also has an anti-robot-spam system like described above. I'm constantly searching for a script like this, but help is welcome!!!
  • 0

#6
Michael

Michael

    Retired Staff

  • Retired Staff
  • 1,869 posts
You could include http://cutephp.com/f...showtopic=12954
into the form I use? I going to do it since it looks like a good idea.

Edited by Michael, 13 May 2006 - 06:06 AM.

  • 0

#7
Michael

Michael

    Retired Staff

  • Retired Staff
  • 1,869 posts
or maybe I am not going to use of after reading http://www.w3.org/TR/turingtest/

It seams that doing anything in the way of stoping bots, ends up blocking some users out. And why is anyone going to target you anyway? Do you have something they (the spamers) want?

Edited by Michael, 14 May 2006 - 05:47 PM.

  • 0

#8
TaNkZ101

TaNkZ101

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 327 posts
k well i still need a form with buttons that will tell me what button(s) is/are selected in the email it sends me. DOES CPANEL IN GTGHOSTING COME WITH SUCH A SCRIPT GENERATOR THAT CAN DO THIS?
  • 0

#9
Michael

Michael

    Retired Staff

  • Retired Staff
  • 1,869 posts
I don't know, I changed mine to add the radio buttons, sending myself an e-mail with it gave.

Name: Your Name
Radio button selected: radio three
Comments: Enter Comments Here


There is a copy of the script http://site.frih.net/email.txt
Make sure you rename it to email.php other wise it will not work.

Edited by Michael, 15 May 2006 - 05:47 PM.

  • 0

#10
knexor2

knexor2

    Member

  • Member
  • PipPip
  • 28 posts
I don't know anything about spam blocking in a php form, but, as Michael said, you might not need to worry about it anyway.

As for including radio buttons and such, it's easy enough to email the contents of the form to yourself in an intelligibale email. All you have to do is give each field a sensible name/value pair, then, when processing the form, build a custom email body using the form names as PHP variables.

But I think it would make more sense with an example.

Here's a form with radio buttons, text fields, and check boxes, just to cover all bases:

<form name="myform" action="sendform.php" method="post">
<input type="hidden" name="submitted" value="true">
<table>
<tr>
<td><input type="radio" name="vehicle" value="car">Car
<td><input type="radio" name="vehicle" value="truck">Truck
<td><input type="radio" name="vehicle" value="van">Van
<tr>
<td colspan=3>Email:<input type="text" name="email">
<tr>
<td><input type="checkbox" name="drive">Drive
<td><input type="checkbox" name="ride">Ride
<td>&nbsp;
</table>
</form>

This form would look horrible in a page. But, hey, that's on-the-fly examples for ya.
Then, your processing script would go something like:

<?PHP

if ($_POST["submitted"]) {
// build body of email as $body using $_POST variables.
$body = ...;
mail("[email protected]", "Form Submitted", "$body", "$_POST[email]");
}

?>

To check to make sure all forms have been filled in, I would suggest using javascript, but if you insist that it be solely PHP, you can just check to make sure each individual variable associated with each field is available.

You could also use regular expressions to make sure the email given is valid.
  • 0

Advertisements


#11
TaNkZ101

TaNkZ101

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 327 posts
how would i get it to check that at LEAST one of the check boxes is checked? (this is all shortened out to show u my idea).
maybe something like
if check1 or check2 or che3 are not checked, (code to execute).

i'm asking for as much help as possible, im as new to php as one can be!
  • 0

#12
Hai Mac

Hai Mac

    Member

  • Member
  • PipPipPip
  • 260 posts
<?php
  if (!($check1) && !($check2) && !($check3)) {
	 echo "You haven't checked any checkbox. Please check it";
  }
?>

A small explanation (just in case):
"!" means not
"&&" means and

Hope it makes sense. :whistling:
  • 0

#13
TaNkZ101

TaNkZ101

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 327 posts
@Hai Mac: yeah i know the operators, just not how to use them lol. thanks though!

can anyone tell me exactly in which format to put things after $body? do i have to use echo? give me an example please! and how would i make it say (if check1 is checked, echo "customer selected search engine optimization")? are u guys sure i don't have to use request anywhere?

Edited by TaNkZ101, 21 May 2006 - 09:40 AM.

  • 0

#14
knexor2

knexor2

    Member

  • Member
  • PipPip
  • 28 posts
No, echo just prints the string to the browser. You just want to assign the string to the $body variable. Something like:

$body = "$check1 was checked\n(radio buttons' name): $radio\nComments: $comments";

PHP will automatically expand the $-variables to their respective values inside the quotes.

and how would i make it say (if check1 is checked, echo "customer selected search engine optimization")?


if ($check1) {
echo "Customer selected search engine optimization.\n";
}

An alternative to Hai Mac's multiple-checkbox-check is:

if ($check1 || $check2 || $check3 || .....) {
// process checked items
}
else {
echo "error message";
}

Edited by knexor2, 21 May 2006 - 10:49 AM.

  • 0

#15
TaNkZ101

TaNkZ101

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 327 posts
well it's been about 10 minutes since i submitted, and it seemed to work, only i never got the email. i think i know what i'm doing wrong.
how do i make a submit button (that will work with the form above, i.e. send it)?
can u explainthe first code u posted in ur last replay knexor please? like what are the "/n"s for etc.
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP