Contact Form

If you have PHP on the server do something like the following for your contact form:

<form action="form.php" method="post">

Then create the form.php to process the post variables and email function

or seeing that your site is heavily dependant on java you might want to create a java vaildation and email processing function.
 
Code:
<form action="#" method="POST>
   <input type="text" name="field1">
   <button type="submit">Send</button>
</form>
 
If you have PHP on the server do something like the following for your contact form:

<form action="form.php" method="post">

Then create the form.php to process the post variables and email function

or seeing that your site is heavily dependant on java you might want to create a java vaildation and email processing function.

you mean javascript obviously. cant really send email with javascript.

and client vs server side validation isn't an OR decision, it's an AND
 
Yes I do mean javascript.

Also for sending email with javascript http://phpjs.org/functions/mail/

Google 'javascript sendmail' and there are many ways to do it.

OMG all that trouble for just a simple post method contact form :O

HTML and PHP works just fine with much less lines

I got a html5 template from the net and I need help to link up a contact form to it.

Please can someone assist please.

www.moveyourass.co.za/test


Nice template btw, mind sharing the source ? ?(where you got it, not it's actual source :/)
 
Last edited:
OMG all that trouble for just a simple post method contact form :O

HTML and PHP works just fine with much less lines

Agree with you, PHP is my choice, javascript just too much effort :)

Link was just to show one of the posters that it is possible
 
Last edited:
Yes I do mean javascript.

Also for sending email with javascript http://phpjs.org/functions/mail/

Google 'javascript sendmail' and there are many ways to do it.


you know that wont work in a browser right?

there are not many ways to do it...... you can do it in this awesome way though

Code:
var url = "mailto:[email protected]?Subject=my%20subject&Body=my%20body";
window.location = url;

doing it in nodejs, on the server side doesnt count....
 
Ok Ive done the following,

Code on site.

<form>
<form method="post" action="contactengine.php">
<input type="text" class="col-md-6 col-xs-12 name" name='name' placeholder='Name'/>
<input type="text" class="col-md-6 col-xs-12 Email" name='Email' placeholder='Email'/>
<input type="text" class="col-md-12 col-xs-12 Subject" name='Subject' placeholder='Subject'/>
<textarea type="text" class="col-md-12 col-xs-12 Message" name='Message' placeholder='Message'></textarea>
<div class="cBtn col-xs-12">
<ul>
<input type="submit" name="submit" value="Submit" class="submit-button" />

</ul>
</div>
</form>

And then Code in the contactengine.php file

<?php

$EmailFrom = "[email protected]";
$EmailTo = "[email protected]";
$Subject = "Move Your Ass Website";
$Name = Trim(stripslashes($_POST['Name']));
$Tel = Trim(stripslashes($_POST['Tel']));
$Email = Trim(stripslashes($_POST['Email']));
$Subject = Trim(stripslashes($_POST['Subject']));
$Message = Trim(stripslashes($_POST['Message']));

// validation
$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}

// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Tel: ";
$Body .= $Tel;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Subject: ";
$Body .= $Subject;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";

// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>



If done this and it isn't working.
Please help.
 
Top
Sign up to the MyBroadband newsletter
X