[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 12-30-2006, 05:21 PM   #1 (permalink)
Senior Member
 
Join Date: Nov 2003
Location: Florida
Posts: 2,010
117.50 NP$ (Donate)

slipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to behold


Need some help with a contect form

Hey everyone.

I am working on a site and I need to get a contact form working. It sounds dumb but I have it on the page, but what do I need to do to get it to work. Its done in dreamweaver

</style>
<form name="form1" method="post" action="">
<table width="450" border="0">
<tr>
<td width="73">Name</td>
<td width="367"><label>
<input name="name" type="text" id="name">
</label></td>
</tr>
<tr>
<td>Email</td>
<td><label>
<input name="email" type="text" id="email">
</label></td>
</tr>
<tr>
<td>Comment</td>
<td><label>
<textarea name="comment" id="comment"></textarea>
</label></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><label>
<input name="Submit" type="submit" class="button" value="Send">
<input name="Submit2" type="reset" class="button" value="Clear">
</label></td>
</tr>
</table>
</form>
slipondajimmy is offline  
Old 12-30-2006, 05:48 PM   #2 (permalink)
Munky Designs
 
Join Date: May 2005
Posts: 997
417.00 NP$ (Donate)

Albino is a jewel in the roughAlbino is a jewel in the roughAlbino is a jewel in the rough


you need to use a language like php or javascript to get it to grab the variables
Albino is offline  
Old 12-30-2006, 07:01 PM   #3 (permalink)
Senior Member
 
Join Date: Nov 2003
Location: Florida
Posts: 2,010
117.50 NP$ (Donate)

slipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to behold


any ideas on a easy way to get it done?
slipondajimmy is offline  
Old 12-30-2006, 07:27 PM   #4 (permalink)
Senior Member
 
Join Date: May 2005
Location: Ontario Canada
Posts: 2,928
1,675.13 NP$ (Donate)

unknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to beholdunknowngiver is a splendid one to behold


hm first of all do you have PHP on your server?
add me on msn i will help u make 1 in php [mzubair01@hotmail.com]
unknowngiver is offline  
Old 12-30-2006, 07:31 PM   #5 (permalink)
Senior Member
 
Join Date: Nov 2003
Location: Florida
Posts: 2,010
117.50 NP$ (Donate)

slipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to behold


I have PHP on my server. I found a script I can use and it will send mail... but no subject or message. And it sends from my server and not a email I specify. Maybe there is something missing

<html>
<head><title>PHP Mail Sender</title></head>
<body>
<?php

/* All form fields are automatically passed to the PHP script through the array $HTTP_POST_VARS. */
$name = $HTTTP_POST_VARS ['name'];
$email = $HTTP_POST_VARS['email'];
$comment = $HTTP_POST_VARS['comment'];


/* PHP form validation: the script checks that the Email field contains a valid email address and the Subject field isn't empty. preg_match performs a regular expression match. It's a very powerful PHP function to validate form fields and other strings - see PHP manual for details. */
if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) {
echo "<h4>Invalid email address</h4>";
echo "<a href='javascript:history.back(1);'>Back</a>";
} elseif ($subject == "") {
echo "<h4>No subject</h4>";
echo "<a href='javascript:history.back(1);'>Back</a>";
}

/* Sends the mail and outputs the "Thank you" string if the mail is successfully sent, or the error string otherwise. */
elseif (mail($email,$subject,$message)) {
echo "<h4>Thank you for sending email</h4>";
} else {
echo "<h4>Can't send email to $email</h4>";
}
?>
</body>
</html>
slipondajimmy is offline  
Old 12-30-2006, 07:49 PM   #6 (permalink)
NamePros Regular
 
Join Date: Feb 2006
Posts: 588
1,620.95 NP$ (Donate)

jerometan is a name known to alljerometan is a name known to alljerometan is a name known to alljerometan is a name known to alljerometan is a name known to alljerometan is a name known to all


This setting in phpini needs to be changed - sendmail_from
Changing it changes what address appears in the from address.

You need to have a form in order to send mail.
If you don't want to, edit :

$name = $HTTTP_POST_VARS ['name'];
$email = $HTTP_POST_VARS['email'];
$comment = $HTTP_POST_VARS['comment'];

to

$subject = " - Subject - ";
$email = " - To Email - ";
$message = " - To Message - ";

Edit the content inside.
jerometan is offline  
Old 12-30-2006, 08:32 PM   #7 (permalink)
Senior Member
 
Join Date: Nov 2003
Location: Florida
Posts: 2,010
117.50 NP$ (Donate)

slipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to behold


I think I have been working on this to much tonight . I need to give it a rest and try again tommorow.

I just need this http://www.kitcar.ws/test.html (just a test) To function.

Like I said I can get it to send, but with no message and with a server email.

So if anyone can help it would be great
slipondajimmy is offline  
Old 12-30-2006, 10:01 PM   #8 (permalink)
NamePros Regular
 
Join Date: Feb 2006
Posts: 588
1,620.95 NP$ (Donate)

jerometan is a name known to alljerometan is a name known to alljerometan is a name known to alljerometan is a name known to alljerometan is a name known to alljerometan is a name known to all


Sorry, missing out on the form posted.

Heres a fix :

Code:
<form name="form1" method="post" action="">
<table width="450" border="0">
<tr>
<td width="73">Name</td>
<td width="367"><label>
<input name="name" type="text" id="name">
</label></td>
</tr>
<tr>
<td>Email</td>
<td><label>
<input name="email" type="text" id="email">
</label></td>
</tr>
<tr>
<td>Subject</td>
<td><label>
<input name="subject" type="text" id="subject">
</label></td>
</tr>
<tr>
<td>Message</td>
<td><label>
<textarea name="message" id="message"></textarea>
</label></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><label>
<input name="Submit" type="submit" class="button" value="Send">
<input name="Submit2" type="reset" class="button" value="Clear">
</label></td>
</tr>
</table>
</form>
For the PHP Code :

Code:
/* All form fields are automatically passed to the PHP script through the array $HTTP_POST_VARS. */
$name = $HTTP_POST_VARS ['name'];
$email = $HTTP_POST_VARS['email'];
$message = $HTTP_POST_VARS['message'];
$subject = $HTTP_POST_VARS['subject'];


/* PHP form validation: the script checks that the Email field contains a valid email address and the Subject field isn't empty. preg_match performs a regular expression match. It's a very powerful PHP function to validate form fields and other strings - see PHP manual for details. */
if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) {
echo "<h4>Invalid email address</h4>";
echo "<a href='javascript:history.back(1);'>Back</a>";
} elseif ($subject == "") {
echo "<h4>No subject</h4>";
echo "<a href='javascript:history.back(1);'>Back</a>";
}

/* Sends the mail and outputs the "Thank you" string if the mail is successfully sent, or the error string otherwise. */
elseif (mail($email,$subject,$message)) {
echo "<h4>Thank you for sending email</h4>";
} else {
echo "<h4>Can't send email to $email</h4>";
}
?>
</body>
</html>
jerometan is offline  
Old 12-31-2006, 08:03 AM   #9 (permalink)
Senior Member
 
Join Date: Nov 2003
Location: Florida
Posts: 2,010
117.50 NP$ (Donate)

slipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to behold


Now im getting this

Method Not Allowed
The requested method POST is not allowed for the URL XXX/XXX.
slipondajimmy is offline  
Old 12-31-2006, 08:50 AM   #10 (permalink)
Domains my Dominion
 
sdsinc's Avatar
 
Join Date: Aug 2005
Location: Web 1.0
Posts: 6,285
1,095.94 NP$ (Donate)

sdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond reputesdsinc has a reputation beyond repute

Third World Education Find Marrow Donors! Find Marrow Donors! Find Marrow Donors! Find Marrow Donors! Animal Rescue Animal Cruelty AIDS/HIV Animal Rescue Wildlife Breast Cancer
Quote:
Originally Posted by slipondajimmy
Now im getting this

Method Not Allowed
The requested method POST is not allowed for the URL XXX/XXX.
Maybe you should rename the ext from .html to .php

Also, if you are using third-party code make sure you understand the risk of E-mail injection:
http://www.securephpwiki.com/index.php/Email_Injection
__________________
Buy now - MassDeveloper.com $500
sdsinc is online now  
Old 12-31-2006, 08:56 AM   #11 (permalink)
Stud Sausage
 
Join Date: Dec 2006
Location: England
Posts: 1,546
34.41 NP$ (Donate)

Matthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud of

Adoption Breast Cancer Breast Cancer Cancer Survivorship
jerometan, HTTP_POST_VARS? That was depreciated for $_POST autoglobal in php 4.1.

Also as has been said, that code is open to header injections.
Matthew. is offline  
Old 12-31-2006, 09:11 AM   #12 (permalink)
Senior Member
 
Join Date: Nov 2003
Location: Florida
Posts: 2,010
117.50 NP$ (Donate)

slipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to behold


Thanks for everyones help. So does anyone have any idea of a simple script I can use. IM putting a site together as a favor to someone and dont really want to spend any money on it.

This should have been simple and done by now..hhaha
slipondajimmy is offline  
Old 12-31-2006, 09:44 AM   #13 (permalink)
Stud Sausage
 
Join Date: Dec 2006
Location: England
Posts: 1,546
34.41 NP$ (Donate)

Matthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud of

Adoption Breast Cancer Breast Cancer Cancer Survivorship
This is my adapted version slipondajimmy, use it if you wish.

PHP Code:
<?php
define
('_sendto', 'youraddress@email.com');

if(
$_SERVER['REQUEST_METHOD'] == 'POST' )
{
    foreach(
$_POST as $key => $value)
    {
        
$_POST[$key] = addslashes(stripslashes($value));
    }
    
    
    if( !
strlen($_POST['e_name']) > 0 )
    {
         
$error[] = 'No name given';
    }
    
    if( !
strlen($_POST['e_from']) > 0 )
    {
         
$error[] = 'You did not supply your email';
    }
    else
    {

        if (!
preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $_POST['e_from']))
        {
             
$error[] = 'The email given was invalid!';
        }
    }
    
    if( !
strlen($_POST['e_message']) > 0 )
    {
         
$error[] = 'The message was left blank';
    }
    
    if(
count( $error ) > 0 )
    {
         foreach(
$error as $value)
         {
              echo
$value . '<br />';
         }
    }
    else
    {
         
$pattern = "/(content-type|bcc:|cc:)/i";
        
        if (
preg_match($pattern, $_POST['e_name']) || preg_match($pattern, $_POST['e_from']) || preg_match($pattern, $_POST['e_message']))
        {
             die(
'No injections please');
        }
        else
        {
        
              if(
mail(_sendto, 'Message from contact form', $_POST['e_message'], "From: <{$_POST['e_from']}> {$_POST['e_from']}\r\n
                                                                                  Reply-To: {$_POST['e_from']}"
))
              {
                   echo
'The message was sent!';
              }
              else
              {
                   
trigger_error('The email could not be sent!', E_USER_WARNING);
              }
         }
    }
}
else
{
    
?>
    <form action="?" method="post">
    Name:     <input type="text" name="e_name" value="" /><br />
    Email:     <input type="text" name="e_from" value="" /><br />
    Message:<textarea name="e_message"></textarea>
            <input type="submit" name="submit" value="Send" />
    </form>
    
    <?php
}
?>
Untested, should work.

Last edited by Matthew.; 01-01-2007 at 06:31 AM.
Matthew. is offline  
Old 12-31-2006, 10:28 AM   #14 (permalink)
Senior Member
 
Join Date: Nov 2003
Location: Florida
Posts: 2,010
117.50 NP$ (Donate)

slipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to behold


thanks a bunch. Im still getting this though. I must be missing something

Method Not Allowed
The requested method POST is not allowed for the URL
slipondajimmy is offline  
Old 12-31-2006, 11:10 AM   #15 (permalink)
Stud Sausage
 
Join Date: Dec 2006
Location: England
Posts: 1,546
34.41 NP$ (Donate)

Matthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud of

Adoption Breast Cancer Breast Cancer Cancer Survivorship
I have only ever known that message to appear as sdsinc said when your exstension is .html or .htm

Unless you have created a handler so php will parse in html files (not advised) your file extension must be .php
Matthew. is offline  
Old 12-31-2006, 11:52 AM   #16 (permalink)
NamePros Regular
 
Join Date: Feb 2006
Posts: 588
1,620.95 NP$ (Donate)

jerometan is a name known to alljerometan is a name known to alljerometan is a name known to alljerometan is a name known to alljerometan is a name known to alljerometan is a name known to all


Quote:
Originally Posted by Matthew.
jerometan, HTTP_POST_VARS? That was depreciated for $_POST autoglobal in php 4.1.

Also as has been said, that code is open to header injections.
I know the code is not secure, and HTTP_POST_VARS shouldnt be used.

However, he asked for his contact form to be fixed with functionality.

So I didn't make much changes to the script (how do i know what PHP version he has).

Rename the file (the one Matthew provided) to *.php.
jerometan is offline  
Old 01-01-2007, 10:08 AM   #17 (permalink)
Senior Member
 
Join Date: Nov 2003
Location: Florida
Posts: 2,010
117.50 NP$ (Donate)

slipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to beholdslipondajimmy is a splendid one to behold


Thanks everyone. Its working fine now
slipondajimmy is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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 On
Pingbacks are On
Refbacks are On


Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 04:53 AM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85