eXceem

Go Back   eXceem > Off Topic > Technical Help

Claim your amazing £1,000 slots booster bonus now!


PHP help

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 ...

Reply
 
Thread Tools
Old 04-03-10, 11:12 PM   #1
iPod 60gb
 
eonbar's Avatar
 
Join Date: Nov 2007
Location: Reading
Posts: 1,701
eonbar is just really niceeonbar is just really nice

PHP help


Please may i have some help

okay, i have googled and i have exceem searched and i can't get my contact form working i'm looking at this post here when i tried the same thing in MAY 2008!!!!

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>
which i've put as html into my page and it looks good. The php is this, and this is where i think i maybe going wrong... I have this saved as contact.php and its in the same folder as my ENTIRE site ... do i need to put it in the SPECIFIC folder .... eg for http://www.iMoose.co.uk/TEST.html does it need to go in the TEST_files which holds the CSS and images etc ???

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>
or is there something else wrong
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 whyyyy?

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>
THANK YOOOOOOOU =rep obviously / thanks / virtual hug

Last edited by eonbar; 04-03-10 at 11:16 PM..
 
Reply With Quote
Old 04-03-10, 11:37 PM   #2
Mini Mac
 
wolf's Avatar
 
Join Date: Jun 2006
Location: Cardiff
Posts: 3,041
wolf is just really nicewolf is just really nice
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
__________________
A note on my profile page:
Spoiler
 
Reply With Quote
Old 05-03-10, 11:00 AM   #3
iBook
 
messyhead's Avatar
 
Join Date: Oct 2007
Location: Glasgow
Posts: 2,266
messyhead is a glorious beacon of lightmessyhead is a glorious beacon of lightmessyhead is a glorious beacon of light
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
 
Reply With Quote
Old 05-03-10, 11:11 AM   #4
iBook
 
messyhead's Avatar
 
Join Date: Oct 2007
Location: Glasgow
Posts: 2,266
messyhead is a glorious beacon of lightmessyhead is a glorious beacon of lightmessyhead is a glorious beacon of light
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..
 
Reply With Quote
Old 05-03-10, 11:16 AM   #5
iPod 60gb
 
eonbar's Avatar
 
Join Date: Nov 2007
Location: Reading
Posts: 1,701
eonbar is just really niceeonbar is just really nice
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 ta tho
 
Reply With Quote
Old 05-03-10, 11:24 AM   #6
iBook
 
messyhead's Avatar
 
Join Date: Oct 2007
Location: Glasgow
Posts: 2,266
messyhead is a glorious beacon of lightmessyhead is a glorious beacon of lightmessyhead is a glorious beacon of light
Quote:
Originally Posted by eonbar View Post
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 ta tho
No probs. In the form action you just specify the 'processor' file and put in the location. If you had the form in domain.com/test and the processor was in domain.com/, then the location in the action tag would be action="../processor.php". If it's all in the same folder, then you don't need ../ in front of it. The ../ tells it to look in the root directory.

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
 
Reply With Quote
Reply

Thread Tools

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 Off
Pingbacks are On
Refbacks are Off





All times are GMT. The time now is 12:53 PM.
All trademarks and copyrights held by respective owners. Forum posts are owned by the poster.

Powered by vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
SEO by vBSEO
no new posts