Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

0penCr8

macrumors newbie
Original poster
Jul 8, 2012
28
0
California, USA
I am not very good with HTML and have basically no knowledge of PHP, JavaScript, MySQL, etc... I am trying to create a form for my website. I used to use a great program called CoffeeCup Web Form Builder. Unfortunately, I found out that is t was discontinued and replaced by Web Form Builder 2.0. Now, Web Form Builder 2.0 is great, but it costs $69. I don't really want to spend money on this when I know I can build one for cheaper. I have read through the W3schools.com 'walkthrough' on HTML forms, but they don't look very good and they don't cover everything.

If someone could send me a link to a thorough tutorial or some well-built freeware, it would be greatly appreciated.
Thanks.
 
It's incredibly easy to make a php web form if all you are doing is creating a contact form. Just create the form in HTML:
Code:
<form action="sendmail.php" method="post">
Name: <input type="text" name="name" /><br />
Email: <input type="text" name="email" /><br />
Comments: <textarea rows="2" Cols="20" name="comments"></textarea>
 <input type="submit" value="Submit" />
</form>


Then create a new page called "sendmail.php" and put this in it:
PHP:
<?
$email = $_POST['email'] ;
$message = $_POST['name'] ;
$message = .$_POST['comments'] ;
mail( "yourname@example.com", "Email Subject", $message, "From: $email" );
print "Congratulations your email has been sent";
?>

That is CRAZY basic. But it's really not too hard to grasp once you get the hang of it.

DISCLAIMER: Darth.Titan is the internet police, and would like me to tell you that this is not a best practice, even though I never stated this was the best way to do it, only the easiest. Thank you.
 
Last edited:
It's incredibly easy to make a php web form if all you are doing is creating a contact form. Just create the form in HTML:
Code:
<form action="sendmail.php" method="post">
Name: <input type="text" name="name" /><br />
Email: <input type="text" name="email" /><br />
Comments: <textarea rows="2" Cols="20" name="comments"></textarea>
 <input type="submit" value="Submit" />
</form>


Then create a new page called "sendmail.php" and put this in it:
PHP:
<?
$email = $_GET['email'] ;
$message = $_GET['name'] ;
$message = .$_GET['comments'] ;
mail( "yourname@example.com", "Email Subject", $message, "From: $email" );
print "Congratulations your email has been sent";
?>

That is CRAZY basic. But it's really not too hard to grasp once you get the hang of it.

pretty sure you should be using the $_POST array in your php since you're submitting this form as a post ( method="post" ).
 
...

That is CRAZY basic. But it's really not too hard to grasp once you get the hang of it.

Then you obviously don't have the hang of it yet.

Like jamesbot noted, you're trying to access $_POST variables with $_GET. You also did no sanitation of the user input whatsoever. You just plugged the input into mail() and fired away. That's terrible practice.

You also left out several of the mail headers that should be included. That message will be more likely to be caught by a spam filter than to arrive at its intended destination.

If you're going to try to give potential programmers a hand, show them good code.
 
Then you obviously don't have the hang of it yet.

Like jamesbot noted, you're trying to access $_POST variables with $_GET. You also did no sanitation of the user input whatsoever. You just plugged the input into mail() and fired away. That's terrible practice.

You also left out several of the mail headers that should be included. That message will be more likely to be caught by a spam filter than to arrive at its intended destination.

If you're going to try to give potential programmers a hand, show them good code.
As I said, it's INCREDIBLY basic, and big deal, I forgot to change GET to POST on the code I copied. I threw that it in there from a website, without even looking at it.

Also, where in my post did I say this was best practice OR that he should use my exact solution.

And like he is going to understand form sanitation? From the sounds of it, he doesn't require anything that needs really any security anyways.

He asked how to send mail, not how to sanitize forms, dodge spam filters, etc.

You can sit there and be a dick all you want, but I gave a basic answer for a basic question.

But if it gets your incredibly small panties out of a bunch, I'll put in my post that it isn't a "best practice". Which I was aware of from the beginning. But going on here giving links to someone to like the SendMail plugin is going to do nothing but overwhelm and confuse.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.