Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
PHP Email script for my form
Old 03-03-2011, 01:09 PM PHP Email script for my form
Junior Talker

Posts: 1
Trades: 0
Hello all,

I am trying to create a mailer.php file for the form below. I am having a horrible time with this. Every time I put the code together with the radio button variables the script fails. Can someone be so great as to just give me the proper .php script to make this email form work? I would be so grateful and so will my hair that is being pulling out at the moment.

<form name="form1" method="post" action="">
<p align="left"><span class="style5">Name</span>
<input name="textfield" type="text" size="25">
</p>
<p align="left"><span class="style5">Phone</span>
<input name="textfield2" type="text" size="25">
</p>
<p align="left"><span class="style5">Email</span>
<input name="textfield3" type="text" size="25">
</p>
<p class="style5">Please select one </p>
<p><span class="style5">Make an appointment</span>
<input name="radiobutton" type="radio" value="radiobutton">
<span class="style5">Egg Donor application</span>
<input name="radiobutton" type="radio" value="radiobutton">
<span class="style5">Have a comment</span>
<input name="radiobutton" type="radio" value="radiobutton">
</p>
<p align="left">&nbsp;</p>
<p align="center" class="style5">Comment</p>
<p>
<textarea name="textarea" cols="40" rows="10"></textarea>
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>
Vanw1ld3r is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-03-2011, 08:46 PM Re: PHP Email script for my form
Marik's Avatar
Skilled Talker

Posts: 99
Trades: 0
I haven't tested it but this should work:

PHP Code:
<?php

if (isset($_POST['Submit'])) {

    
$name htmlentities($_POST['name']);
    
$phone htmlentities($_POST['phone']);
    
$email htmlentities($_POST['email']);
    
$make_appt htmlentities($_POST['make_appt']);
    
$donor_app htmlentities($_POST['donor_app']);
    
$have_comment htmlentities($_POST['have_comment']);
    
$comment htmlentities($_POST['comment']);

    
$to 'recieversemailaddress@somedomain.com';
    
$subject 'You\'ve got mail!';
    
$message =

<<<heredoc

You have recieved the following email: \n\n

Name: 
$name \n
Phone: 
$phone \n
Email: 
$email \n
Why: 
{$make_appt}{$donor_app}{$have_comment}\n
Comment: 
$comment

heredoc;

    
$sendMail mail($to$subject$message);

    echo (
$sendMail) ? 'Message Sent' 'Message could not be sent';

}

?>
HTML Code:
<form name="form1" method="post" action="">
    <p align="left">
        <span class="style5">Name</span>
        <input name="name" type="text" size="25">
    </p>
    <p align="left">
        <span class="style5">Phone</span>
        <input name="phone" type="text" size="25">
    </p>
    <p align="left">
        <span class="style5">Email</span>
        <input name="email" type="text" size="25">
    </p>
    <p class="style5">Please select one </p>
    <p>
        <span class="style5">Make an appointment</span>
        <input name="make_appt" type="radio" value="make appointment">

        <span class="style5">Egg Donor application</span>
        <input name="donor_app" type="radio" value="egg donor application">

        <span class="style5">Have a comment</span>
        <input name="have_comment" type="radio" value="have comment">
    </p>
    <p align="left">&nbsp;</p>
    <p align="center" class="style5">Comment</p>
    <p>
        <textarea name="comment" cols="40" rows="10"></textarea>
    </p>
    <p>
        <input type="submit" name="Submit" value="Submit">
    </p>
</form>
As you can see I changed your form a bit, 1st try to use relevant names for your form fields. Don't name a radio button "radio button" name it "egg donor application" for example. Also each field name must be unique, in your original form you had multiple radio buttons with the same name.
__________________

Please login or register to view this content. Registration is FREE

Last edited by Marik; 03-03-2011 at 08:50 PM..
Marik is offline
Reply With Quote
View Public Profile
 
Old 03-05-2011, 05:59 PM Re: PHP Email script for my form
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
Also each field name must be unique, in your original form you had multiple radio buttons with the same name.
Wrong! For radio buttons to act AS radio they HAVE to have the same names.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-06-2011, 03:59 PM Re: PHP Email script for my form
Marik's Avatar
Skilled Talker

Posts: 99
Trades: 0
Quote:
Originally Posted by chrishirst View Post
Wrong! For radio buttons to act AS radio they HAVE to have the same names.
Yeah my bad, got mixed up. The original form had the same values for all radio buttons but yes the names should be the same.
__________________

Please login or register to view this content. Registration is FREE
Marik is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to PHP Email script for my form
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.24030 seconds with 12 queries