Go Back   Computer Forums > General Computing > Hardware
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 02-23-2007, 02:30 PM   #1
Solid State Member
 
Join Date: Feb 2007
Posts: 11
Default Need a contact form

Hello,

I need a contact form on my website, that will send to my email address what the visitor enter in the form fields. The problem is that I can't run any php scripts.. is there a way to use some html form?
__________________

_babuciu_ is offline   Reply With Quote
Old 02-23-2007, 02:48 PM   #2
In Runtime
 
Daeva's Avatar
 
Join Date: Dec 2005
Posts: 407
Send a message via AIM to Daeva Send a message via MSN to Daeva Send a message via Yahoo to Daeva
Default Re: Need a contact form

In order to process a form like that, you need some kind of server-side scripting. Html won't do it, btw, you should probably have posted this in the web programming section. Can you use cgi, coldfusion, or asp? Don't know if you can use javascript or not... Let me check on that.
__________________

__________________
**Official Self-proclaimed glorified excessive (insert additional adjectives here) post editor/modifier.
Edit = Best feature ever
http://www.twitter.com/xDaevax
Daeva is offline   Reply With Quote
Old 02-23-2007, 03:33 PM   #3
In Runtime
 
Daeva's Avatar
 
Join Date: Dec 2005
Posts: 407
Send a message via AIM to Daeva Send a message via MSN to Daeva Send a message via Yahoo to Daeva
Default Re: Need a contact form

<head>
<script type="text/javascript">
function emailMe() {
var mySubject = new String(document.form1.elements[0].value + "");
var myEmail = new String(document.form1.elements[1].value + "");
var messageText = new String(document.form1.elements[2].value + "");
window.location ="mailto:" + myEmail + "&subject=" + mySubject +"&body=" + messageText;
}
</script>
</head>
<body>
<form name="form1" id="form1" method="post" action="">
Subject: <input type="text" name="mySubject" id="mySubject" /><br />
Email: <input type="text" name="email" id="email" /><br />
Message:<br />
<input type="textarea" name="message" id="message" style="height: 100px; width: 150px;" /><br />
<INPUT TYPE="button" VALUE="Contact Us" onClick="emailMe();" />
</form>
</body>
Thats the closest you'll get (as far as I know) without any server side code. I wrote that, so you don't have to give credit, just hope it helps.

Also, this does not work on firefox. It throws an exception that I have no idea how to correct. So, stick with I.E.
__________________
**Official Self-proclaimed glorified excessive (insert additional adjectives here) post editor/modifier.
Edit = Best feature ever
http://www.twitter.com/xDaevax
Daeva is offline   Reply With Quote
Old 02-23-2007, 04:20 PM   #4
In Runtime
 
jamieoliver22's Avatar
 
Join Date: Apr 2004
Posts: 245
Default Re: Need a contact form

A code that only works on IE is a bad code

You can set up a basic one by using HTML and PHP.

Add a PHP page with this code:
Code:
<form action="contact2.php" method="post">
Name:<input type="text" name="name" class="text" size="41"/><br />
Email:<input type="text" name="email" id="email" class="text" size="41"/><br />
Subject:<input type="text" name="subject" class="text" size="41"/><br />
Message:<textarea name="message" class="text" cols="38" rows="10"></textarea><br />
<input type="hidden" name="ip" value="<?php echo ($_SERVER['REMOTE_ADDR']); ?>"/>
<input type="submit" name="send" value="Send" class="button"/>
<input type="reset" name="clear" value="Clear" class="button"/>
</form>
Then make a new page called contact2.php and add this code:

PHP Code:
<?php

$name 
htmlentities($_POST['name']);
$email htmlentities($_POST['email']);
$subject htmlentities($_POST['subject']);
$message htmlentities($_POST['message']);
$ip htmlentities($_POST['ip']);

    
$mailto "email@domain.com";
    
$mailsubj "$subject\n";
    
$headers "From: $email\r\n" "IP: $ip\r\n";
    
$mailbody $message;
    
mail($mailto$mailsubj$mailbody$headers);
    echo 
'<div>Your message has been sent</div>';
?>
This script is for demo purposes though, edit them as you see fit. Also, it is wise to add extra coding on contact2.php to stop people from sending blank messages.

EDIT: For the script to work correctly, you need to have the mail(); command enabled on the webserver. Some hosts enable a safe mode which blocks it so you may need to ask them about it. There are ways around it however.

Jamie.
__________________
Desktop: AMD Athlon XP 2000+ - 1.6ghz | MSI KT4-Ultra Motherboard |ATI Radeon Powercolor x850 XT 256mb DDR3 | 400gb HDD space |1gb PC2700 DDR SDRAM.
---
Laptop: AMD Sempron 3200+ - 1.6ghz | ATI Radeon Xpress 1100 - 128mb | 100gb PATA HDD | 1gb DDR2 RAM.
jamieoliver22 is offline   Reply With Quote
Old 02-23-2007, 04:25 PM   #5
In Runtime
 
Daeva's Avatar
 
Join Date: Dec 2005
Posts: 407
Send a message via AIM to Daeva Send a message via MSN to Daeva Send a message via Yahoo to Daeva
Default Re: Need a contact form

Quote:
Originally Posted by _babuciu_
Hello,
The problem is that I can't run any php scripts..
I agree though, scripts that only work on ie aren't good.
__________________
**Official Self-proclaimed glorified excessive (insert additional adjectives here) post editor/modifier.
Edit = Best feature ever
http://www.twitter.com/xDaevax
Daeva is offline   Reply With Quote
Old 02-23-2007, 04:38 PM   #6
Solid State Member
 
Join Date: Feb 2007
Posts: 12
Default Re: Need a contact form

wow how do you learn to write code like that, and where do you input that code ?

*bewildered*
pacman is offline   Reply With Quote
Old 02-23-2007, 04:38 PM   #7
In Runtime
 
jamieoliver22's Avatar
 
Join Date: Apr 2004
Posts: 245
Default Re: Need a contact form

Oh, didn't notice the bit about PHP. My bad

But move to a host that supports PHP, you will need it for many scripts. A host that doesn't offer PHP and a database sucks to be honest
__________________

__________________
Desktop: AMD Athlon XP 2000+ - 1.6ghz | MSI KT4-Ultra Motherboard |ATI Radeon Powercolor x850 XT 256mb DDR3 | 400gb HDD space |1gb PC2700 DDR SDRAM.
---
Laptop: AMD Sempron 3200+ - 1.6ghz | ATI Radeon Xpress 1100 - 128mb | 100gb PATA HDD | 1gb DDR2 RAM.
jamieoliver22 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off



All times are GMT -5. The time now is 09:46 AM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0