| |||||||
This is a discussion on PHP help within the Technical Help forums, part of the Off Topic category; Please may i have some help okay, i have googled and i have exceem searched and i can't get my ...
![]() |
| | Thread Tools |
| | #1 |
| iPod 60gb Join Date: Nov 2007 Location: Reading
Posts: 1,701
![]() ![]() | PHP helpPlease may i have some help okay, i have googled and i have exceem searched and i can't get my contact form working http://www.exceem.co.uk/forums/techn...-php-help.html i understand everything a little better now and have done what xaviier said in post 3, but nothing I also tried a different free form thingy of which i have this. Code: <!-- Website Contact Form Generator --> <!-- http://www.tele-pro.co.uk/scripts/contact_form/ --> <!-- This script is free to use as long as you --> <!-- retain the credit link --> <form method="POST" action="contact.php"> Fields marked (*) are required <p>Email From:* <br> <input type="text" name="EmailFrom"> <p>Name:<br> <input type="text" name="Name"> <p>Email:<br> <input type="text" name="Email"> <p>Answer:<br> <input type="text" name="Answer"> <p>T&C:* <br> <input type="checkbox" name="T&C" value="Yes"> <p><input type="submit" name="submit" value="Submit"> </form> <p> <!-- Contact Form credit link --> Created by <a target="_blank" href="http://www.tele-pro.co.uk/scripts/contact_form/">Contact Form Generator</a> Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
// Website Contact Form Generator
// http://www.tele-pro.co.uk/scripts/contact_form/
// This script is free to use as long as you
// retain the credit link
// get posted data into local variables
$EmailFrom = Trim(stripslashes($_POST['EmailFrom']));
$EmailTo = "imoosecompetition@googlemail.com";
$Subject = "Competition";
$Name = Trim(stripslashes($_POST['Name']));
$Email = Trim(stripslashes($_POST['Email']));
$Answer = Trim(stripslashes($_POST['Answer']));
$T&C = Trim(stripslashes($_POST['T&C']));
// validation
$validationOK=true;
if (Trim($EmailFrom)=="") $validationOK=false;
if (Trim($T&C)=="") $validationOK=false;
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 .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Answer: ";
$Body .= $Answer;
$Body .= "\n";
$Body .= "T&C: ";
$Body .= $T&C;
$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=ok.htm\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>
</body>
</html>
this has taken me two years lol.... EDIT: also at the bottom you'll see www.iMoose.co.uk in a box thing. This is the code, but when you click it doesn't autoselect this is the code Code: <div align=center><input size= '40' type="text" readonly="readonly" onclick="SelectAll('txtLink');" value="http://www.iMoose.co.uk" id="txtLink" name="txtLink"></div>
__________________ Last edited by eonbar; 04-03-10 at 11:16 PM.. |
|
| | #2 |
| Mini Mac Join Date: Jun 2006 Location: Cardiff
Posts: 3,041
![]() ![]() | I believe dear Chiggles will be your best bet for help here. However as it is undoubtedly past his bed time you may have to wait till morning XD
__________________ |
|
| | #3 |
| iBook Join Date: Oct 2007 Location: Glasgow
Posts: 2,266
![]() ![]() ![]() | I'll have a look at this and get back to you. I've just finished building my own kick-ass PHP form processor, so should be able to get yours working. Back in 5...
__________________ Received about £1600 worth so far! Spoiler |
|
| | #4 |
| iBook Join Date: Oct 2007 Location: Glasgow
Posts: 2,266
![]() ![]() ![]() | Ok, give this a go... I removed one of the email fields. You had EmailFrom and Email but they both looked like they were doing the same thing? If you need both, you can just add it back in. I've also included a check for valid email addresses. If you want to add more validation, have a look at this tutorial as it's what I used for my form processor. PHP Mail Form: Secure and Protected » tutorialtastic.co.uk Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
// Website Contact Form Generator
// http://www.tele-pro.co.uk/scripts/contact_form/
// This script is free to use as long as you
// retain the credit link
// get posted data into local variables
$EmailFrom = trim($_POST['EmailFrom']);
$Name = trim($_POST['Name']);
$Answer = trim($_POST['Answer']);
$TC = $_POST['T&C'];
if (empty($EmailFrom)) {
exit("<p>Failed Message Here</p>");
}
if (empty($Name)) {
exit("<p>Failed Message Here</p>");
}
if (!ereg("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,6})$",strtolower($EmailFrom))) {
exit("<p>That e-mail address is not valid, please use another.</p>");
}
if (empty($Answer)) {
exit("<p>Failed Message Here</p>");
}
if ($TC !='Yes') {
exit("<p>Failed Message Here</p>");
}
$EmailFrom= stripslashes(strip_tags($EmailFrom));
$Name= stripslashes(strip_tags($Name));
$Answer= stripslashes(strip_tags($Answer));
$TC= stripslashes(strip_tags($TC));
$EmailTo = "imoosecompetition@googlemail.com";
$Subject = "Competition";
// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Answer: ";
$Body .= $Answer;
$Body .= "\n";
$Body .= "T&C: ";
$Body .= $T&C;
$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=ok.htm\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>
</body>
</html>
__________________ Received about £1600 worth so far! Spoiler Last edited by messyhead; 05-03-10 at 11:13 AM.. |
|
| | #5 |
| iPod 60gb Join Date: Nov 2007 Location: Reading
Posts: 1,701
![]() ![]() | ahhh thanks messyhead ... was a simple mistake. really dont know whats going on with all this php stuff. I thought i could just have the .php in the whole index type thingy, not in the actualy TEST_files (with the other css stuff) would rep, need to spread
__________________ |
|
| | #6 | |
| iBook Join Date: Oct 2007 Location: Glasgow
Posts: 2,266
![]() ![]() ![]() | Quote:
Have you used just PHP validation, or do you have any JS validation? On my forms, I use JS validation first, then if they've got JS disabled, the PHP is a back up. The PHP also validates for spambots and profanity. An example of a form I've just done is The ReSessions :: Enquiries It's not live so you can play about with it to see how it works. The JS validation catches most things, then if you pass all the JS with profanities in any filed, the PHP validation will give you a slap. If you disable JS, then the PHP validation kicks in.
__________________ Received about £1600 worth so far! Spoiler | |
|
![]() |
| Thread Tools | |
| |