Web Form + Submit button

Soldato
Joined
18 Oct 2002
Posts
4,023
Location
Wellington, NZ
Hi,

To make a web form work, after pressing the submit button what should I need to know to put in the code to make it work?

I have a form with all the required fields and i'm wanting the send button to send an email to my webhost email address without going through outlook.

Is this is as difficult thing to do? I've had a look in google but it's not too clear.
 
Thanks for the link :) Is there no way to do it internally through the browser and the webhost mail server though without going through Outlook?

thanks
 
I'll read into that, i'm sure we have php services.. I think the reason it's a bit tougher is because i'm trying implement this to a form created already:


<br style="line-height:9px">
<form action="" enctype="multipart/form-data" id="form">
<table cellspacing="0" cellpadding="0" class="form">
<tr>
<td style="width:198px; height:128px">
<table cellspacing="0" cellpadding="0">
<tr>
<td style="width:198px; height:27px"><input name="" type="text" value="your name:"></td>
</tr>
<tr>
<td style="width:198px; height:27px"><input name="" type="text" value="your company:"></td>
</tr>
<tr>
<td style="width:198px; height:27px"><input name="" type="text" value="telephone:"></td>
</tr>
<tr>
<td style="width:198px; height:27px"><input name="" type="text" value="e-mail"></td>
</tr>
</table>
</td>
<td style="width:202px; height:128px">
<table cellspacing="0" cellpadding="0">
<tr>
<td style="width:202px; height:109px"><textarea name="" cols="0" rows="0">message:</textarea></td>
</tr>
<tr>
<td style="width:202px; height:19px">
<br style="line-height:1px">
<img src="images/spacer.gif" alt="" width="116" height="1"><strong><a href="#" onClick="document.getElementById('form').reset()">reset</a></strong><img src="images/spacer.gif" alt="" width="15" height="1"><strong><a href="#" onClick="document.getElementById('form').submit()">send</a></strong> </td>
</tr>
</table>
</td>
</tr>
</table>

that is the code without CSS - 'document.getElementById' is this what I need to be looking at?

thanks
 
You're making life far more complicated than you need to :).

Look back at the first link I posted, you can simply submit the forum via <input type=submit>. If you specify the form to be sent to the PHP file you create, you can then use the PHP mail function to manipulate the form data how you wish, and send an email with your desired reply address/headers/target address from the server.

This may make things a bit clearer to you.

http://www.thesitewizard.com/archive/feedbackphp.shtml
 
the reason it's that hard is because I want to retain the styling. I've just tested and got that form working on the last link you posted but on my form the submit button is a link rather than a button - this seems to be the problem at the moment.

Cheers :)
 
I'm lost as to why you need your submit button as a Javascript action that executes the sending. If it's styling you're worried about, you can use CSS to tweak an <input type=submit> to however you want. Can't help but feel that I'm maybe missing something here with regards to what you're after,lol.
 
you're not i'm just not very good at explaining my requirements :D

I'm not sure why it's using a javascript action. How would I use the CSS to do that as i'm pretty sure that's the last piece of the jigsaw.
 
In your HTML form...

Code:
<input type="submit" class="submit" value="send" />

In your CSS...

Code:
.submit 
{
	border: 0;
	background-color: transparent;
	color: #0000ff;
	font-weight: bold;
	text-decoration: underline;
	cursor: hand;
}

That's about as close as I can make it. The styling you've got currently is just whatever the browser default styling is for a link. This can change from browser to browser and can also be overidden by users anyway, so best not to rely on everyone seeing exactly that style in the first place.

The first 2 styles above are they key bits to making the button look like text as they remove the border and the background. the others just make it look a bit like a link.

ps. use PHP and CSS always - Javascript is evil!
 
Last edited:
Cheers for the replies:

Managed to get the form to send but it's now blank apart from the email!!:o
___________________________________________________________________________________________________________
<form method="post" action="sendmail.php">

<table cellspacing="0" cellpadding="0" class="form">
<tr>
<td style="width:198px; height:128px">
<table cellspacing="0" cellpadding="0">
<tr>
<td style="width:198px; height:27px"><input name="name" type="text" value="your name:"></td>
</tr>
<tr>
<td style="width:198px; height:27px"><input name="company" type="text" value="your company:"></td>
</tr>
<tr>
<td style="width:198px; height:27px"><input name="telephone" type="text" value="telephone:"></td>
</tr>
<tr>
<td style="width:198px; height:27px"><input name="email" type="text" value="e-mail:"></td>
</tr>
</table> </td>
<td style="width:202px; height:128px">
<table cellspacing="0" cellpadding="0">
<tr>

<td style="width:202px; height:109px">message:<textarea name="textarea" cols="0" rows="0"></textarea></td>
</tr>
<tr>
<td style="width:202px; height:19px">
<br style="line-height:1px">
<img src="images/spacer.gif" alt="" width="116" height="1"><input type="submit" />
____________________________________________________________________________
That's the form element.
____________________________________________________________________________
This is the PHP element:
<?php
$name = $_REQUEST['name'] ;
$company = $_REQUEST['company'] ;
$telephone = $_REQUEST['telephone'] ;
$email = $_REQUEST['email'] ;
$textarea = $_REQUEST['textarea'] ;


mail( "****@hotmail.com", "Feedback",
$message, "From: $email" );
header( "Location: thankyou.html" );
?>

What's going wrong now?
 
Back
Top Bottom