View Full Version : Information form problem
DragginGlass
03-19-2008, 03:44 AM
alright everyone, Im no pro at this HTML stuff yet, I build simple sites but have a desire to do more. I have an idea that I need some help completing. Here is what I wanna do.
I have a button on one page of my site. When a guest clicks on that button it will take them to a whole new page that has a form on it that they will need to fill out. When they complete the form and hit submit at the bottom, the form and info they just filled out will be sent to me via email.
I do not know what or where to get a form that I can customize the required info feilds on and I don't know how to have the info put in the form emailed to me when the user hits submit.
Any and all help would be greatly appreicated. Thanks in advance,
You have to options, one you can use a different language such as PHP.
Or you can use the the 'mailto:email' thing with html.
With php you would do something like this:
<?php
mail('email','subject','content');
?>
The bright side of using this way is that it is very easy to understand and customize.
You can also use html with this by making a form and a post for the php.
Now if you decide to do it with HTML, you have a lot of downers on that.
You can't have it in the email, for example. All the info that they email will be attatched to a file for some reason
It will look like get data, so something like this: email=email&name=name&text=text, very hard to read.
Its not easy to customize at all, for example, if you type in a % it will turn out as a 37.
It will ask you A LOT of crap before you even get to submit the email like "This is trying to access your default mail thing. It will give away private info such as your name and email
So I suggest doing this with php:
<?php
mail('email',$_POST['sub'],$_POST['message']);
?>
<form action="" method="post">
<input type="text" name="sub" /><br />
<input type="text" name="message" />
<input type="submit" />
</form>
I agree with using php rather then HTML emailing. Once you get it set up, it's a lot easier for everyone. I personally hate those messages as well :p BUT, you have to keep in mind that your webhost needs to meet the requirements for emailing as well, and some don't. The webhost needs to:
Be PHP enabled
Have an SMTP server (which you have access to)
And the page will need a .php extension rather then .htm (in case you didn't know).
Also, a small correction in the PHP code-- I know it is just an example, but that code will send a blank email before the real email, which will get old really fast. (Or maybe it outputs a blank subject/message error?)
<?php
if(isset($_POST['submit'])){ // <-- Will not email unless form was submitted
mail('email',$_POST['sub'],$_POST['message']);
}
?>
<form action="" method="post">
<input type="text" name="sub" /><br />
<input type="text" name="message" />
<input type="submit" name="submit" />
</form>
The button to redirect uses can be done using PHP:
<?php
if(isset($_POST['submit'])){
header("Location: form.php");
}
?>
<form action="" method="post">
<input type="submit" name="submit" value="Send Email" />
</form>
Or javascript:
<script type="text/javascript">
function emailform(){
window.location = "./form.php";
}
</script>
<input type="button" value="Send Email" onclick="emailform()" />
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.