/    Sign up×
Community /Pin to ProfileBookmark

help with submission form

Hey guys
I know I am out of my league here, but I am helping a friend out and he really wants a submission form that sends using php. The way I have it set up right now is just a standard submit button that pops open a mail program and then you send it from your email. I am not even sure where to start so if anybody out there can help me even begin to understand what I need to do that would be awesome! Here is my code as I have the form set up on the page.

<div id=”form”>
<FORM NAME=”exampleform” METHOD=”post”
ACTION=”mailto:[email protected]” ENCTYPE=”text/plain”>
<form id=”example-form” method=”post” action=””>
<fieldset>
<legend><span class=”style7 style9 style12″>Personal Information</span></legend>
<label for=”fm-req_forename”><span class=”style7 style9 style12″>First name (<em>optional</em>) </span></label>
<div>
<input type=”text” name=”fm-req_forename” id=”fm-req_forename” />
<br />
</div>
<label for=”fm-req_forename”></label>
<div><br />
</div>
<label for=”fm-eml_email”><span class=”style11″>Email (<em>optional</em>) </span></label>
<div class=”fm-required”>
<input type=”text” name=”fm-eml_email” id=”fm-eml_email” value=” ” />
<br />
</div>
<label for=”fm-eml_phone”><span class=”style7 style9 style12″>Phone Number (<em>optional</em>) </span></label>
<div class=”fm-required”>
<input type=”text” name=”fm-eml_email” id=”fm-eml_email” value=” ” />
</div>
<p>
<label>
<input type=”radio” name=”phone” value=”radio” />
I wish to be contacted by phone </label>
<br />
<label>
<input type=”radio” name=”email” value=”radio” />
I wish to be contacted by email </label>
<br />
<label>
<input type=”radio” name=”none” value=”radio” />
I do not wish to be contacted </label>
<br />
</p>
</fieldset>
<fieldset>
<legend><span class=”style7 style9 style12″> Requests</span> </legend>
<span class=”style12″>
<label for=”fm-req_password”><span class=”style7 style9″>Share Your Requests</span></label>
</span>
<div>
<textarea name=”fm-req_password” cols=”50″ rows=”7″ id=”fm-req_password”></textarea>
<br />
</div>
</fieldset>
<div id=”fm-submit”>
<input type=”submit” name=”Submit” value=”Submit” />
</div>
</form>
</div>

to post a comment
PHP

9 Comments(s)

Copy linkTweet thisAlerts:
@launchpad67aMay 01.2007 — I can make you something right now. Hang tight.
Copy linkTweet thisAlerts:
@launchpad67aMay 01.2007 — Ok, here you go.

Open "email.php" and change the top 2 lines. Your email address and the email subject. I had to change your form coding quite a bit but it works fine.

Upload both files to the Same folder on your server and try it out.

Tested and works perfectly.

[upl-file uuid=9e775375-1073-41e7-8a1b-90621492fe8c size=2kB]email_form.zip[/upl-file]
Copy linkTweet thisAlerts:
@tableforglassesauthorMay 01.2007 — Mike

I am so indebted to you right now. It worked perfectly. This is a huge weight lifted off of my shoulders. Thank you so much for taking the time to do that for me!!!!

Sean
Copy linkTweet thisAlerts:
@tableforglassesauthorMay 01.2007 — hey mike

I just made a change on the radio buttons, before they were all checkable and I didn't realize it, so I changed it so all of the names are group1 instead of contact_phone ect. I changed it on both the php and the html. Only problem is that when you submit it now, it shows up as yes for all of the 3 radio buttons, instead of yes only showing up on on checked radio button. Anyway I can change this.

thanks again for the help

html code:

<div id="form">

<FORM NAME="exampleform" METHOD="post" ACTION="email.php">

<!--<form id="example-form" method="post">-->

<fieldset>

<legend><span class="style7 style9 style12">Personal Information</span></legend>

<label for="fm-req_forename"><span class="style7 style9 style12">First name (<em>optional</em>) </span></label>

<div>

<input type="text" name="name" />

<br />

</div>

<label for="fm-req_forename"></label>

<div><br />

</div>

<label for="fm-eml_email"><span class="style11">Email (<em>optional</em>) </span></label>

<div class="fm-required">

<input type="text" name="email" />

<br />

</div>

<label for="fm-eml_phone"><span class="style7 style9 style12">Phone Number (<em>optional</em>) </span></label>

<div class="fm-required">

<input type="text" name="phone" />

</div>

<p>

<label>

<input type="radio" name="group1" value="yes" />

I wish to be contacted by phone </label>

<br />

<label>

<input type="radio" name="group1" value="yes" />

I wish to be contacted by email </label>

<br />

<label>

<input type="radio" name="group1" value="yes" />

I do not wish to be contacted </label>

<br />

</p>

</fieldset>

<fieldset>

<legend><span class="style7 style9 style12"> Requests</span> </legend>

<span class="style12">

<label for="fm-req_password"><span class="style7 style9">Share Your Requests</span></label>

</span>

<div>

<textarea name="requests" cols="50" rows="7" /></textarea>

<br />

</div>

</fieldset>

<div id="fm-submit">

<input type="submit" name="Submit" value="Submit" />

</div>

</form>

</div>

php

<?php

/* PHP-FLASH EMAIL/CONTACT FORM

Designed By: Mike Kreidel 2007

http://www.azwebdesigns.com

*
/


// The $sendTo = [email][email protected][/email]

// The $subject = prayer requests

// !!!! EDIT THE NEXT TWO LINES !!!!

$sendTo = "[email protected]";


$subject = "Prayer Requests";


///////////// Everything Below can remain unchanged /////////////////

// Header Info: these all go in one variable. This displays in the email you recieve like: 'From:Mike <[email protected]>'

$headers = "From: " . $_POST["name"] ." <" . $_POST["email"] .">rn";


// next include a replyto

$headers .= "Reply-To: " . $_POST["email"] . "rn";


// often email servers won't allow emails to be sent to domains other than their own.


// The return path here will often lift that restriction,

// so technically bounced email is supposed to go to the return-path email.

$headers .= "Return-path: " . $_POST["email"];


// now we can add the content of the input text boxes to a body variable. Seperated by line breaks

// NOTE: If you add more input text boxes in your flash movie, this is where you would add their Var names !

$message = "First Name: ".$_POST["name"] ."rn". "Phone: ".$_POST["phone"] ."rn". "Email: ".$_POST["email"] ."rn". "Requests: ".$_POST["requests"] ."rn". "Contact by Phone: ".$_POST["group1"] ."rn". "Contact by Email: ".$_POST["group1"] ."rn". "No Contact: ".$_POST["group1"];


// Next 2 lines are used to prevent hackers and spammers from populating the headers with special values and characters !!!

function hasNewlines($str) {

return preg_match("/(%0A|%0D|n+|r+)/i", $str);

}

if (hasNewlines($_POST['name']) || hasNewlines($_POST['email'])) {

die('No email for you!');

}


// once the variables have been defined, they can be included in the mail function, which will send you an email !!

mail($sendTo, $subject, $message, $headers);
Copy linkTweet thisAlerts:
@launchpad67aMay 01.2007 — Why did you need to change anything? It worked just as it should.

You have to have a different name for each checkbox if you want to get a different result for each.

You have them all named 'group1', it doesn't work like that.

The way the checkbox should display it's result is a "yes" or no". In your case the "no" is just blank. So when you get the email, you will only see a "yes" next to the boxes the user selected.

Understand?

Also, you don't need to post ALL the code here on the forum. Just post what you changed or need help with. It makes for very long posts. Thanks.
Copy linkTweet thisAlerts:
@tableforglassesauthorMay 01.2007 — I understand completely what you said, the only problem I had was when you click one radio button and then click the next radio button it doesn't change to the newly clicked button, so basically you can click all three radio button and have them checked, also you cannot uncheck them, so I changed the name to group1 so if I clicked one or the other it would uncheck the previously checked one. Thank you again for the help!
Copy linkTweet thisAlerts:
@launchpad67aMay 01.2007 — You're welcome for the help.

I understand what you mean about the checkboxes. The names still have to be different but we need some extra coding in the form. Let me work on it and I'll post back within a hour.
Copy linkTweet thisAlerts:
@launchpad67aMay 01.2007 — Sean,

Change the value=" " to a unique name for each checkbox.

value="contact by phone"

value="contact by email"

value="do not contact"

This should solve the problem. I was wrong in saying that the name="" cannot be the same. this how you make each selectable. You had it right.

Let me know how that works as I haven't tested it.
Copy linkTweet thisAlerts:
@tableforglassesauthorMay 01.2007 — that takes care of the problem! Thank you again so much and thanks for putting notes on the code, so I can take it apart and figure out how it works and not just copy and paste. thanks for the time

Sean
×

Success!

Help @tableforglasses spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...