# Webforms help



## ralen (Sep 8, 2007)

Hi.

I have php GormGenerator installed on on of my websites. I installed it via my CpanelX control panel. The thing is, when I get an email from someone using the form on my site- it comes in like this:



> From: [email protected]
> Sent: Wed 05/09/2007
> To: [email protected]
> Name: Test
> ...


The fields I have in my form are:



> Name:
> Valid email address:
> Enquiry:


Is there any way to make it view properly in Outlook 2007? (Without all these <br> tags etc.

Also I want the "From" field to display the senders email address, not [email protected] as it's making my work harder since I need to manually input the clients email address into the "to" field when replying.

Go easy with me please; I know VERY little about php and only the basics really of HTML.

Thanks for any help given.


----------



## Redcore (Aug 14, 2007)

Well ... I wouldn't use a generator. I'll give you a simple email script here in a little bit - at this second I'm building a super complex one for my own site.


----------



## Redcore (Aug 14, 2007)

ALRIGHT - ready to help.

Email can be as simple or as complex as you want, really. For instance, my web site's contact form checks EVERY field and makes sure they're not blank, processes the fields through a cuss filter and replaces those words with asterisks (takes the wind out of the sails of some idiot wanting to send a bunch of profanity for their own chuckles), makes sure each field entry is up to a certain amount of characters (I typically want at least 10 characters for a message - I don't count spaces or astericks), and I have a script that verifies that the email exists (although obviously you can't check if they're giving you their REAL email). If they don't meet the requirements I've set, I have the script send back to the review page and it asks them to fill it in. Until they do, it'll keep sending back. It also logs every IP and I will be writing a additional script process that logs the IP after every sent email - and make it so they can't send another email for another 15 minutes or so.


So you get my point: it can get really complicated depending on how far you want to take it. I'm going to do a fairly simple one for you that is not nearly as advanced...but it'll still check if the email exists and strip HTML code (a must have for ANY posted variables).

Take note of the bolded file name above the code - you need to copy the code into notepad or whatever editor you like and save it as that filename.
---------------------
*function_checkEmail.php*

```
<?
function checkEmail( $email, $chFail = false ) {
	$msgs = Array(); $msgs[] = 'Received email address: '.$email;
	//check for email pattern (adapted and improved from http://karmak.org/archive/2003/02/validemail.html)
	//incorrectly allows IP addresses with block numbers > 256, but those will fail to create sockets anyway
	//unicode norwegian chars cannot be used: C caron, D stroke, ENG, N acute, S caron, T stroke, Z caron (PHP unicode limitation)
	if( !preg_match( "/^(([^<>()[\]\\\\.,;:\[email protected]\"]+(\.[^<>()[\]\\\\.,;:\[email protected]\"]+)*)|(\"([^\"\\\\\r]|(\\\\[\w\W]))*\"))@((\[([0-9]{1,3}\.){3}[0-9]{1,3}\])|(([a-z\-0-9áàäçéèêñóòôöüæøå]+\.)+[a-z]{2,}))$/i", $email ) ) {
		$msgs[] = 'Email address was not recognised as a valid email pattern';
		return $chFail ? Array( false, $msgs ) : false; }
	$msgs[] = 'Email address was recognised as a valid email pattern';
	//get the mx host name
	if( preg_match( "/@\[[\d.]*\]$/", $email ) ) {
		$mxHost[0] = preg_replace( "/[\w\W]*@\[([\d.]+)\]$/", "$1", $email );
		$msgs[] = 'Email address contained IP address '.$mxHost[0].' - no need for MX lookup';
	} else {
		//get all mx servers - if no MX records, assume domain is MX (SMTP RFC)
		$domain = preg_replace( "/^[\w\W]*@([^@]*)$/i", "$1", $email );
		if( !getmxrr( $domain, $mxHost, $weightings ) ) { $mxHost[0] = $domain;
			$msgs[] = 'Failed to obtain MX records, defaulting to '.$domain.' as specified by SMTP protocol';
		} else { array_multisort( $weightings, $mxHost );
			$cnt = ''; $co = 0; foreach( $mxHost as $ch ) { $cnt .= ( $cnt ? ', ' : '' ) . $ch . ' (' . $weightings[$co] . ')'; $co++; }
			$msgs[] = 'Obtained the following MX records for '.$domain.': '.$cnt; }
	}
	//check each server until you are given permission to connect, then check only that one server
	foreach( $mxHost as $currentHost ) {
		$msgs[] = 'Checking MX server: '.$currentHost;
		if( $connection = fsockopen( $currentHost, 25 ) ) {
			$msgs[] = 'Created socket ('.$connection.') to '.$currentHost;
			if( preg_match( "/^2\d\d/", $cn = fgets( $connection, 1024 ) ) ) {
				$msgs[] = $currentHost.' sent SMTP connection header - no futher MX servers will be checked: '.$cn;
				while( preg_match( "/^2\d\d-/", $cn ) ) { $cn = fgets( $connection, 1024 );
					$msgs[] = $currentHost.' sent extra connection header: '.$cn; } //throw away any extra rubbish
				if( !$_SERVER ) { global $HTTP_SERVER_VARS; $_SERVER = $HTTP_SERVER_VARS; }
				//attempt to send an email from the user to themselves (not <> as some misconfigured servers reject it)
				$localHostIP = gethostbyname(preg_replace("/^.*@|:.*$/",'',$_SERVER['HTTP_HOST']));
				$localHostName = gethostbyaddr($localHostIP);
				fputs( $connection, 'HELO '.($localHostName?$localHostName:('['.$localHostIP.']'))."\r\n" );
				if( $success = preg_match( "/^2\d\d/", $hl = fgets( $connection, 1024 ) ) ) {
					$msgs[] = $currentHost.' sent HELO response: '.$hl;
					fputs( $connection, "MAIL FROM: <$email>\r\n" );
					if( $success = preg_match( "/^2\d\d/", $from = fgets( $connection, 1024 ) ) ) {
						$msgs[] = $currentHost.' sent MAIL FROM response: '.$from;
						fputs( $connection, "RCPT TO: <$email>\r\n" );
						if( $success = preg_match( "/^2\d\d/", $to = fgets( $connection, 1024 ) ) ) {
							$msgs[] = $currentHost.' sent RCPT TO response: '.$to;
						} else { $msgs[] = $currentHost.' rejected recipient: '.$to; }
					} else { $msgs[] = $currentHost.' rejected MAIL FROM: '.$from; }
				} else { $msgs[] = $currentHost.' rejected HELO: '.$hl; }
				fputs( $connection, "QUIT\r\n");
				fgets( $connection, 1024 ); fclose( $connection );
				//see if the transaction was permitted (i.e. does that email address exist)
				$msgs[] = $success ? ('Email address was accepted by '.$currentHost) : ('Email address was rejected by '.$currentHost);
				return $chFail ? Array( $success, $msgs ) : $success;
			} elseif( preg_match( "/^550/", $cn ) ) {
				$msgs[] = 'Mail domain denies connections from this host - no futher MX servers will be checked: '.$cn;
				return $chFail ? Array( false, $msgs ) : false;
			} else { $msgs[] = $currentHost.' did not send SMTP connection header: '.$cn; }
		} else { $msgs[] = 'Failed to create socket to '.$currentHost; }
	} $msgs[] = 'Could not establish SMTP session with any MX servers';
	return $chFail ? Array( false, $msgs ) : false;
}


/****************************************************************
                Email address validation script
  v2.1.1 Written by Mark 'Tarquin' Wilton-Jones - 26-28/01/2004
 Updated 12/02/2004 to allow all valid email address formats and
 improve RFC compliance, and use MX record weightings
 Updated 09/05/2004 to allow Norwegian characters
******************************************************************

Please see http://www.howtocreate.co.uk/jslibs/termsOfUse.html for terms and
conditions of use.

Requires PHP 4.0 (min) with support for Perl compatible regular expression functions.
Windows (NT/2000/XP) installations will need to provide the getmxrr function - see:
http://uk.php.net/manual/en/function.getmxrr.php

This is superior to regular pattern matching email address validators, because it
actually attempts to contact the relevant mail exchange servers to prove that the
email address actually exists. Note that some mail exchangers will accept all
usernames, even if the username does not exist as a valid email user.

This script accepts all valid email address formats, including:
"any @ characters\\\" < that> you !%$& want"@mailDomain.com

It will check each available server until one permits a connection. It then attempts
to initialise an email to the specified email address.

If the server accepts the email, it is cancelled, and the email address is assumed
to be valid. If the server rejects the email, the email address is assumed to be
invalid.

WARNING: the check will show the email address as invalid if all available MX servers
are offline or are busy, even though the email address may be valid.

I plan to add functionality to show temporary failures like these in version 3
(I have not yet planned when to write or release version 3).

This library provides one function:

	mixed checkEmail( string email_address[, optional boolean debug] )

The function can operate in two modes;
	1) email validating:
		boolean valid_email = checkEmail( $email_address );
	2) email validation debugging:
		Array( boolean valid_email, Array debugging_messages ) = checkEmail( $email_address, true );

A typical use of the validating mode is to use:

	if( checkEmail( $email_address ) ) {
		// use mail() to send the email
		...
	} else {
		print 'Your email address is not valid';
	}

A typical use of the debugging mode is to use:

	$return_msgs = checkEmail( $email_address, true );
	foreach( $return_msgs[1] as $debug_msg ) { print htmlspecialchars( $debug_msg ).'<br />'; }
	print $return_msgs[0] ? 'Email address seems to be valid' : 'Email address does not seem to be valid';
____________________________________________________________________________________________________________*/
?>
```
_NOTE: I did not write this particular code...and thus I kept the info for it but just moved it to the bottom (personal preference)_

*contact.html*

```
<Form method="post" action="sendmail.php">
  <p>Name:<br />
    <input name="name" type="text" id="name" size="20" maxlength="50" />
</p>
  <p>Email:<br /> 
    <input name="email" type="text" size="20" maxlength="50" /> 
    <br />
    <br />
Message:<br />
<textarea name="message" rows="5" cols="40">
</textarea> 
<br />
<input name="Submit" type="submit" value="Submit">
<label>
<input type="reset" name="Submit2" value="Reset" />
</label>
<br />
    </p>
</form>
```

*sendmail.php*

```
<?php
include "function_checkEmail.php";

  $_POST = array_map('strip_tags', $_POST);
  $name = $_POST['name'];
  $email = $_POST['email'];
  $message = $_POST['message'];
  
// let's format them
  $message = "Inquiry:" . "\n\n" . $message;
  $subject = "Email From Website - " . $name;

// this will show you who it's from AND will blind carbon-copy the message to them
  $headers .= 'From: ' . $name . '<' . $email . '>' . "\r\n";
  $headers .= 'Bcc: ' . $name . '<' . $email . '>' . "\r\n";

// let's check if that email is valid or not!
// if it's valid - send the email
	if( checkEmail( $email ) ) {
		mail("[email protected]", $subject, $message, $headers);
		echo "Thank you for your inquiry. I will be in contact with you soon!";
	} else {
		die("Email provided is not valid.");
	}	
?>
```
This should work out for you. I tested it - and it works.

*Please use the updated code below*


----------



## ralen (Sep 8, 2007)

Cheers for that. I will try it and post my experiences with it.

Two questions though; 


Will this redirect the customer to a "thank you" page after they submit the form? If not, how do I set this up?

Where do I input MY email address in this coding so that the mail is delivered to the email address I need it to?

I have a thank you page working on the site just now


----------



## Redcore (Aug 14, 2007)

How about I just reformat sendmail.php to make it easier for you to edit...

*sendmail.php* (version 2)

```
<?php
// THESE ARE THE VARIABLES THAT YOU NEED TO EDIT!

$sendto = "ENTER-YOUR-EMAIL-HERE" // for example: [email protected]
$gotopage = "ENTER-YOUR-PAGE-HERE" // for example: http://www.yoursite.com/thankyou.html

// end editable variables

include "function_checkEmail.php";

  $_POST = array_map('strip_tags', $_POST);
  $name = $_POST['name'];
  $email = $_POST['email'];
  $message = $_POST['message'];
  
// let's format them
  $message = "Inquiry:" . "\n\n" . $message;
  $subject = "Email From Website - " . $name;

// this will show you who it's from AND will blind carbon-copy the message to them
  $headers .= 'From: ' . $name . '<' . $email . '>' . "\r\n";
  $headers .= 'Bcc: ' . $name . '<' . $email . '>' . "\r\n";

// let's check if that email is valid or not!
// if it's valid - send the email
    if( checkEmail( $email ) ) {
        mail($sendto, $subject, $message, $headers);
        header("Location: $gotopage");
    } else {
        die("Email provided is not valid.");
    }
?>
```
All you need to do is edit the variables at the top of the page with your information.


----------



## ralen (Sep 8, 2007)

Redcore said:


> How about I just reformat sendmail.php to make it easier for you to edit...
> 
> *sendmail.php* (version 2)
> 
> ...


lol, sorry. I did say im not very wise with php :grin:

Its 1am here now, but tomorrow morning Im going to try this out and see how I get on with it.

I will keep you informed of my progress.

Thanks very much.


----------



## ralen (Sep 8, 2007)

OK; So I couldnt wait lol.

Ive just tried it out, but Im getting this error after clicking the submit button:



> Parse error: syntax error, unexpected T_VARIABLE in /home/puezq/public_html/3g-codes/sendmail.php on line 12


Any ideas?

If you click here you can see the temp upload I've done to test it out.

It should redirect to here after the form is submitted. I have added into line 12 the following:



> http://www.3g-codes.co.uk/thanks.htm


Any ideas where I've gone wrong?


----------



## Redcore (Aug 14, 2007)

You didn't do anything wrong - I forgot to end the top variables.


```
<?php
// THESE ARE THE VARIABLES THAT YOU NEED TO EDIT!

$sendto = "ENTER-YOUR-EMAIL-HERE"; // for example: [email protected]
$gotopage = "ENTER-YOUR-PAGE-HERE"; // for example: http://www.yoursite.com/thankyou.html

// end editable variables

include "function_checkEmail.php";

  $_POST = array_map('strip_tags', $_POST);
  $name = $_POST['name'];
  $email = $_POST['email'];
  $message = $_POST['message'];
  
// let's format them
  $message = "Inquiry:" . "\n\n" . $message;
  $subject = "Email From Website - " . $name;

// this will show you who it's from AND will blind carbon-copy the message to them
  $headers .= 'From: ' . $name . '<' . $email . '>' . "\r\n";
  $headers .= 'Bcc: ' . $name . '<' . $email . '>' . "\r\n";

// let's check if that email is valid or not!
// if it's valid - send the email
    if( checkEmail( $email ) ) {
        mail($sendto, $subject, $message, $headers);
        header("Location: $gotopage");
    } else {
        die("Email provided is not valid.");
    }
?>
```
Give that one a shot


----------



## ralen (Sep 8, 2007)

Redcore said:


> You didn't do anything wrong - I forgot to end the top variables.
> 
> 
> ```
> ...


Im getting another error now. You can still check it again using the links I gave you before.

Heres whats on the line 35:



> header("Location: $gotopage");


----------



## ralen (Sep 8, 2007)

I've just realised; the script is actually working as I've received the mails, including yours. It's just the error with the redirect after the form has been submitted.


----------



## Redcore (Aug 14, 2007)

It works on my server.

The error recieved on your page is when something is already posted to the page before the header (header = redirect). The trouble is, there's nothing in the code I gave you that puts anything on the page.

Here's what I'm seeing when I copied the source code on your sendmail.php:

```
<!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=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body><!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=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body> 

</body>
</html>
<br />
<b>Warning</b>:  Cannot modify header information - headers already sent by (output started at /home/puezq/public_html/3g-codes/sendmail.php:8) in <b>/home/puezq/public_html/3g-codes/sendmail.php</b> on line <b>35</b><br />
 
</body>
</html>
```
None of that should be there - I'm not really sure why it's showing up. I don't know why it adds TWO headings on top of that...

The good thing is that it does send the email when the address is valid...but try taking out this:


```
include "function_checkEmail.php";
```
If that comes up with the same result, add it back (it means that it's not this causing the problem).

Beyond that, I'm going to have to research this...it's a new one for me.


----------



## Redcore (Aug 14, 2007)

You know - if you don't mind, you could always just display "thanks for the email, we'll get back to you. click here to go back to the main site" and provide a link until this can be figured out.


----------



## ralen (Sep 8, 2007)

Let me get this right. Is this all that should be in the sendmail.php document:

```
<body><?php
// THESE ARE THE VARIABLES THAT YOU NEED TO EDIT!

$sendto = "[email protected]"; // for example: [email protected]
$gotopage = "http://www.3g-codes.co.uk/thanks.htm"; // for example: http://www.yoursite.com/thankyou.html

// end editable variables

include "function_checkEmail.php";

  $_POST = array_map('strip_tags', $_POST);
  $name = $_POST['name'];
  $email = $_POST['email'];
  $message = $_POST['message'];
  
// let's format them
  $message = "Inquiry:" . "\n\n" . $message;
  $subject = "Email From Website - " . $name;

// this will show you who it's from AND will blind carbon-copy the message to them
  $headers .= 'From: ' . $name . '<' . $email . '>' . "\r\n";
  $headers .= 'Bcc: ' . $name . '<' . $email . '>' . "\r\n";

// let's check if that email is valid or not!
// if it's valid - send the email
    if( checkEmail( $email ) ) {
        mail($sendto, $subject, $message, $headers);
        header("Location: $gotopage");
    } else {
        die("Email provided is not valid.");
    }
?> 
</body>
```
Or should it be like this:

```
<!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=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body><?php
// THESE ARE THE VARIABLES THAT YOU NEED TO EDIT!

$sendto = "[email protected]"; // for example: [email protected]
$gotopage = "http://www.3g-codes.co.uk/thanks.html"; // for example: http://www.yoursite.com/thankyou.html

// end editable variables

include "function_checkEmail.php";

  $_POST = array_map('strip_tags', $_POST);
  $name = $_POST['name'];
  $email = $_POST['email'];
  $message = $_POST['message'];
  
// let's format them
  $message = "Inquiry:" . "\n\n" . $message;
  $subject = "Email From Website - " . $name;

// this will show you who it's from AND will blind carbon-copy the message to them
  $headers .= 'From: ' . $name . '<' . $email . '>' . "\r\n";
  $headers .= 'Bcc: ' . $name . '<' . $email . '>' . "\r\n";

// let's check if that email is valid or not!
// if it's valid - send the email
    if( checkEmail( $email ) ) {
        mail($sendto, $subject, $message, $headers);
        header("Location: $gotopage");
    } else {
        die("Email provided is not valid.");
    }
?> 
</body>
</html>
```

? :upset: :grin:


----------



## ralen (Sep 8, 2007)

Redcore said:


> The good thing is that it does send the email when the address is valid...but try taking out this:
> 
> 
> ```
> ...


I tried removing that, but never solved the problem im afraid.



Redcore said:


> You know - if you don't mind, you could always just display "thanks for the email, we'll get back to you. click here to go back to the main site" and provide a link until this can be figured out.


It's ok. My current script is, and has been working well for a long time now. Its just that yours will make my life a hell of a lot easier if we can get it working properly :grin:

Whilst im on the subject of this script; is there anyway I can obtain the persons IP address who is submitting the form? I would like it so that the senders IP address is included in the email I receive.


----------



## Redcore (Aug 14, 2007)

Ah, so that's it. What you have there at the top is the header information - that should not be there. This is just a straight PHP script.



ralen said:


> Whilst im on the subject of this script; is there anyway I can obtain the persons IP address who is submitting the form? I would like it so that the senders IP address is included in the email I receive.


Yes, and it's pretty easy. I added it to the script...I also added "stripslashes()" because I noticed that I was getting slashes in one of the email tests (due to a thing called Magic Quotes which is commonly set to "on" on most servers).

Here's the updated script (maybe now we'll get where we wanna go! )


```
<?php
// THESE ARE THE VARIABLES THAT YOU NEED TO EDIT!

$sendto = "ENTER-YOUR-EMAIL-HERE"; // for example: [email protected]
$gotopage = "ENTER-YOUR-NEXT-PAGE-HERE"; // for example: http://www.yoursite.com/thankyou.html

// end editable variables

include "function_checkEmail.php";

  $_POST = array_map('strip_tags', $_POST);
  $name = $_POST['name'];
  $email = $_POST['email'];
  $message = $_POST['message'];
  $ip = $_SERVER['REMOTE_ADDR'];
  
// let's format them
  $message = "Inquiry:" . "\n\n" . $message . "\n\n" . $ip;
  $message = stripslashes($message);
  $subject = "Email From Website - " . $name;
  $subject = stripslashes($subject);

// this will show you who it's from AND will blind carbon-copy the message to them
  $headers .= 'From: ' . $name . '<' . $email . '>' . "\r\n";
  $headers .= 'Bcc: ' . $name . '<' . $email . '>' . "\r\n";

// let's check if that email is valid or not!
// if it's valid - send the email
    if( checkEmail( $email ) ) {
        mail($sendto, $subject, $message, $headers);
        header("Location: $gotopage");
    } else {
        die("Email provided is not valid.");
    }
?>
```
*NOTE: this is the COMPLETE page - don't add anything else!*


----------



## ralen (Sep 8, 2007)

Well the IP address add-in works perfect. But I'm still getting this error:



> Warning: Cannot modify header information - headers already sent by (output started at /home/puezq/public_html/3g-codes/function_checkEmail.php:8) in /home/puezq/public_html/3g-codes/sendmail.php on line 31


I copied the php script you posted, then created a NEW .php page in dreamweaver. I clicked "code" tab, "select all", deleted everything that were there, then pasted the code you gave me. I saved, uploaded over ftp, and im getting that same error still. :4-dontkno


----------



## Redcore (Aug 14, 2007)

Does "function_checkEmail.php" have all that header junk at the top too? That's probably why I was seeing two headers in your page before. That should be a straight-PHP script too.


----------



## ralen (Sep 8, 2007)

Redcore said:


> Does "function_checkEmail.php" have all that header junk at the top too? That's probably why I was seeing two headers in your page before. That should be a straight-PHP script too.


Yes it was. Sorry, my mistake.

I've changed it now, but it's still not working. However I do notice this change in the error msg given now:



> Warning: Cannot modify header information - headers already sent by (output started at /home/puezq/public_html/3g-codes/function_checkEmail.php:*125*) in /home/puezq/public_html/3g-codes/sendmail.php on line 31


Instead of the previous number *8* being there, it's *125*

Don't know if that means anything to you? :4-dontkno


----------



## Redcore (Aug 14, 2007)

Are there any tags at the very bottom? such as </HTML> ect.

I'm totally serious when I say you have to copy what I gave you EXACTLY.


----------



## ralen (Sep 8, 2007)

Redcore said:


> Are there any tags at the very bottom? such as </HTML> ect.
> 
> I'm totally serious when I say you have to copy what I gave you EXACTLY.


No. It's exactly what you gave me in the .php files.

Here they are; see for yourself:

View attachment sendmail.php.zip


View attachment function_checkEmail.php.zip


(Because this forum doesnt allow uploading of .php files, I added a ".zip" extension on the end, just remove it).


----------



## Redcore (Aug 14, 2007)

They didn't work (damaged or corrupt)


----------



## ralen (Sep 8, 2007)

Redcore said:


> They didn't work (damaged or corrupt)


Redcore, when you download them, don't unRAR them, simply remove the .rar extension to convert them back to .php

Note the files I uploaded have this extension:

.php.rar

If you don't know how to do this:


> Open My Documents, Tools->Folder Options-> View-> Untick "Hide extensions for known file types"-> click ok


Now you can see the file extensions on files.


----------



## ralen (Sep 8, 2007)

Redcore; Test the form again, this time using your own email address in the contact form. :grin:

When you submit it, not only I get the email, but you will also. :4-dontkno

I only found out as I have an email from someone saying "Stop Spamming Me!" lol. I must have typed in a random email ID and it happened to actually be someones....OOoops!


----------



## Redcore (Aug 14, 2007)

HAHA, sorry - I was definitely in a hurry and didn't read all of your message as I should have.



ralen said:


> Redcore; Test the form again, this time using your own email address in the contact form.
> 
> When you submit it, not only I get the email, but you will also.
> 
> I only found out as I have an email from someone saying "Stop Spamming Me!" lol. I must have typed in a random email ID and it happened to actually be someones....OOoops!


LOL well that's the point of the "function_checkEmail.php" - it checks whether or not the email is valid. If you were to put in a random email that did not exist, it wouldn't allow the script to send. This will at least detour some random spam. It's not completely necessary, so if the following does not work, we'll just have you take it out.

The weirdest thing is - I tested your script (just changed out the email) and I got the same error - but when I test with my function_checkEmail.php it works. They APPEAR to be exactly alike. I'm guessing that one of the words in the script got messed up whilst one of us was copying/pasting.

Here's the working script...I've uploaded it and added .rar onto the end, just remove that as I did with yours:

http://www.techsupportforum.com/attachment.php?attachmentid=17306&stc=1&d=1189669517

If this doesn't work out for you I'll just take that out of the script and send you the new "sendmail.php"


----------



## ralen (Sep 8, 2007)

Redcore said:


> HAHA, sorry - I was definitely in a hurry and didn't read all of your message as I should have.
> 
> 
> LOL well that's the point of the "function_checkEmail.php" - it checks whether or not the email is valid. If you were to put in a random email that did not exist, it wouldn't allow the script to send. This will at least detour some random spam. It's not completely necessary, so if the following does not work, we'll just have you take it out.
> ...


Oh, I see :grin:

Anyway, I downloaded your .php file and uploaded. 

I really don't quite understand where we were going wrong, but it's working like a charm now.

Im just trying to modify it a little at the moment, then I will impliment it to my site, and post you a link so you can check it out.

Thanks very much for your help Redcore-I It's much appreciated. ray:


----------



## ralen (Sep 8, 2007)

Hmm. Seems adding extra fields to this form isnt possible. I mean, it still submits ok, but I only receive the txt in the "enquiry" box.


----------



## Redcore (Aug 14, 2007)

It's possible - you just have to add those new variables to sendmail.php and add it to send with the rest of the message.


----------



## ralen (Sep 8, 2007)

Redcore said:


> It's possible - you just have to add those new variables to sendmail.php and add it to send with the rest of the message.


Oh. I see. Bit over my head that lol.

I imagined things being a bit easier (as in I just add the HTML coding to the page and it would automatically send it with the rest of the mail) :grin:

BTW- I got your PM. Thanks a lot for that; I will look into this over the weekend.


----------

