This is a discussion on Contact Form within the Coding Help forums, part of the Webmaster Help category; Hey all. Im sure most of ye will be able to answer this in yer sleep so here goes, How ...
| |||||||
| Register | Forum Rules | FAQ | Donate | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hey all. Im sure most of ye will be able to answer this in yer sleep so here goes, How do i go about getting information filled out on a contact form sent to my email address ? I had a look at formmail but i drew a blank... Here is the code for the form that im using ; PHP Code:
__________________ E30owners.com | ModifiedCars.ie | VW auctions | BMW cars and parts for sale | Flickr IT | |
| |||||
| can you run php code or asp code on your website hosting account?
__________________ :. Web Design & Development Web Design Ireland :. Search Engines Optimization Search Engines Optimization :. Directory Submission Directory Submission :. News & Press Release Ireland GiveItSocks.com :. Used Cars Ireland, Car Parts & Car Audio Cars For Sale, Car Parts & Accessories :. I Have 2 Find It Directory SEF Directory |
| |||||
| Code: <?php
if( isset($_POST['user']) && isset($_POST['emailaddress']) )
{
$to = "youremail@yourdomain.com";
$comments = (( isset($_POST['comments']) )?($_POST['comments']):(false));
if( $comments!=False )
{
$subject = 'Query about: ' . substr($comments,0,10).'...';
$name = (( isset($_POST['user']) )?($_POST['user']):('N/A'));
$phone = (( isset($_POST['phone']) )?($_POST['phone']):('N/A'));
$email = (( isset($_POST['emailaddress']) )?($_POST['emailaddress']):('N/A'));
$message =
'Name : '.$name."\n"
.'Phone : '.$phone."\n"
.'Email Address : '.$email."\n"."\n"
.'Query : '.$comments."\n"."\n"
.'From IP: '.(( isset($_SERVER['IP_ADDR']) )?($_SERVER['IP_ADDR']):('N/A'));
$mail_result = @ mail( $to, $subject, $message );
echo $message;
if( $mail_result )
{
echo 'Thank you for your query.';
}
else{ echo 'Unfortunately your query could not be received at this time, please try again later.'; }
}
else{ echo 'Sorry, you must enter a query.'; }
}
else
{
?>
<form id="myform" class="cssform" action="" method="post">
<p>
<label for="user">Name:</label>
<input type="text" id="user" name="user" value="" />
</p>
<p>
<label for="phone">Phone:</label>
<input type="text" id="phone" name="phone" value="" />
</p>
<p>
<label for="emailaddress">Email Address:</label>
<input type="text" id="emailaddress" name="emailaddress" value="" />
</p>
<p>
<label for="comments">Query:</label>
<textarea id="comments" name="comments" rows="5" cols="25"></textarea>
</p>
<div style="margin-left: 150px;">
<input type="submit" value="Submit" />
<input type="reset" value="Reset" />
</div>
</form>
<?php
}
?>
And an example of the email your will receive: Code: Name : John Doe Phone : 484839 Email Address : johndoe@gmail.com Query : I want to know. From IP: 221.243.24.13 |
| |||||
| dorran just gave you an example |
| |||||
| first off - you need to use "name" as well as "id" in your inputs. secondly - here's a drop-in replacement for formmail written in PHP: http://verens.com/files/formmail.tbz2 - you write your form as if you were going to send it to /cgi-bin/formmail.cgi, but instead, change the form "action" to point to the formmail.php in the archive. It also insists on a captcha, meaning that spambots won't use your mailer as a relay (sorry David - yours is wide open). |
| |||||
| Kae What kind of captcha does your version use? Is it GD based or text? Michele
__________________ Hosting & Domains|Plesk Vps Hosting|Geek / Cool Stuff|Films.ie|Cool Sites|Monetisation Tips|Movie Chat Energise your forum! Click here for info |
| |||||
| the example code uses GD (the captcha generator was not written by me). It might be interesting to make it more robust, though (I was only giving it as an example of a slightly more complete mailer) - you have something in mind? |
| |||||
| The problem with image based captcha is that you are basically waving two fingers at anyone who is visually impaired, so a text based challenge is a saner option IMHO
__________________ Hosting & Domains|Plesk Vps Hosting|Geek / Cool Stuff|Films.ie|Cool Sites|Monetisation Tips|Movie Chat Energise your forum! Click here for info |
| Tags |
| contact, form |
| Thread Tools | |
| Display Modes | |
|
|
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Web Development Quote | ButtermilkJack | Marketplace Requests | 5 | 24-01-2007 11:04 AM |
| Submit Email Form | Gavin | Coding Help | 12 | 20-12-2006 10:57 AM |
| ||||||||
| | ![]() | |||||||