Welcome to Tech Support Forum home to more then 136,000 problems solved. Issues have included: Spyware, Malware, Virus Issues, Windows, Microsoft, Linux, Networking, Security, Hardware, and Gaming Getting your problem solved is as easy as:
1. Registering for a free account
2. Asking your question
3. Receiving an answer

Registered members:
* Get free support
* Communicate privately with other members (PM).
* Removal of this message
* See fewer ads.
* And much more..

 



Want to know how to post a question? click here Having problems with spyware and pop-ups? First Steps
Go Back   Tech Support Forum > Design Forum > Web Design & Programming
User Name
Password
Site Map Register Donate Rules Blogs Mark Forums Read


Web Design & Programming Discussion of web design, and server-side & client-side scripting

Reply
 
LinkBack Thread Tools
Old 09-08-2007, 12:11 PM   #1 (permalink)
Registered User
 
Join Date: Sep 2007
Location: United Kingdom
Posts: 75
OS: XP Media Center


Webforms help

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:

Quote:
From: phpFormGenerator@ns.3k11.com
Sent: Wed 05/09/2007
To: xxxx@xxxx.com
Name: Test
Valid Email Address: test@test.com
Enquiry: Hi,&nbsp;<br />&nbsp;<br />Do you know something news about Unlock Code??&nbsp;<br /> &nbsp;<br />I want to buy an UNLOCK CODE for my NOKIA N80-1 lock by 3 UK&nbsp;<br />My IMEI is: 35836100856xxxx.&nbsp;<br />&nbsp;<br />Thanks
The fields I have in my form are:

Quote:
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 phpFormGenerator@nks.... 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.
ralen is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Important Information
Join the #1 Tech Support Forum Today - It's Totally Free!

TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free.

Join TechSupportforum.com Today - Click Here

Old 09-09-2007, 12:34 AM   #2 (permalink)
Design Team Member
 
Redcore's Avatar
 
Join Date: Aug 2007
Location: Jamestown, CA
Posts: 717
OS: Linux Mint 7

My System

Re: Webforms help

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 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 09-09-2007, 02:14 AM   #3 (permalink)
Design Team Member
 
Redcore's Avatar
 
Join Date: Aug 2007
Location: Jamestown, CA
Posts: 717
OS: Linux Mint 7

My System

Re: Webforms help

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
PHP Code:
<?
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"/^(([^<>()[\]\\\\.,;:\s@\"]  +(\.[^<>()[\]\\\\.,;:\s@\"]  +)*)|(\"([^\"\\\\\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$currentHost25 ) ) {
            
$msgs[] = 'Created socket ('.$connection.') to '.$currentHost;
            if( 
preg_match"/^2\d\d/"$cn fgets$connection1024 ) ) ) {
                
$msgs[] = $currentHost.' sent SMTP connection header - no futher MX servers will be checked: '.$cn;
                while( 
preg_match"/^2\d\d-/"$cn ) ) { $cn fgets$connection1024 );
                    
$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$connection1024 ) ) ) {
                    
$msgs[] = $currentHost.' sent HELO response: '.$hl;
                    
fputs$connection"MAIL FROM: <$email>\r\n" );
                    if( 
$success preg_match"/^2\d\d/"$from fgets$connection1024 ) ) ) {
                        
$msgs[] = $currentHost.' sent MAIL FROM response: '.$from;
                        
fputs$connection"RCPT TO: <$email>\r\n" );
                        if( 
$success preg_match"/^2\d\d/"$to fgets$connection1024 ) ) ) {
                            
$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$connection1024 ); 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
HTML Code:
<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 Code:
<?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("youremail@yoursite.com"$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*

Last edited by carsey; 09-10-2007 at 02:31 PM. Reason: User request
Redcore is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 09-09-2007, 07:06 PM   #4 (permalink)
Registered User
 
Join Date: Sep 2007
Location: United Kingdom
Posts: 75
OS: XP Media Center


Re: Webforms help

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

Two questions though;
  1. Will this redirect the customer to a "thank you" page after they submit the form? If not, how do I set this up?
  1. 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 :)

Last edited by ralen; 09-09-2007 at 07:07 PM.
ralen is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 09-10-2007, 02:14 PM   #5 (permalink)
Design Team Member
 
Redcore's Avatar
 
Join Date: Aug 2007
Location: Jamestown, CA
Posts: 717
OS: Linux Mint 7

My System

Re: Webforms help

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

sendmail.php (version 2)
PHP Code:
<?php
// THESE ARE THE VARIABLES THAT YOU NEED TO EDIT!

$sendto "ENTER-YOUR-EMAIL-HERE" // for example: username@usershost.com
$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.
Redcore is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 09-10-2007, 06:06 PM   #6 (permalink)
Registered User
 
Join Date: Sep 2007
Location: United Kingdom
Posts: 75
OS: XP Media Center


Re: Webforms help

Quote:
Originally Posted by Redcore View Post
How about I just reformat sendmail.php to make it easier for you to edit...

sendmail.php (version 2)
PHP Code:
<?php
// THESE ARE THE VARIABLES THAT YOU NEED TO EDIT!

$sendto "ENTER-YOUR-EMAIL-HERE" // for example: username@usershost.com
$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.
lol, sorry. I did say im not very wise with php

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 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 09-10-2007, 06:23 PM   #7 (permalink)
Registered User
 
Join Date: Sep 2007
Location: United Kingdom
Posts: 75
OS: XP Media Center


Re: Webforms help

OK; So I couldnt wait lol.

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

Quote:
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:

Any ideas where I've gone wrong?
ralen is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 09-10-2007, 06:36 PM   #8 (permalink)
Design Team Member
 
Redcore's Avatar
 
Join Date: Aug 2007
Location: Jamestown, CA
Posts: 717
OS: Linux Mint 7

My System

Re: Webforms help

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

PHP Code:
<?php
// THESE ARE THE VARIABLES THAT YOU NEED TO EDIT!

$sendto "ENTER-YOUR-EMAIL-HERE"// for example: username@usershost.com
$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 ;)
Redcore is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 09-10-2007, 07:12 PM   #9 (permalink)
Registered User
 
Join Date: Sep 2007
Location: United Kingdom
Posts: 75
OS: XP Media Center


Re: Webforms help

Quote:
Originally Posted by Redcore View Post
You didn't do anything wrong - I forgot to end the top variables.

PHP Code:
<?php
// THESE ARE THE VARIABLES THAT YOU NEED TO EDIT!

$sendto "ENTER-YOUR-EMAIL-HERE"// for example: username@usershost.com
$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 ;)
Im getting another error now. You can still check it again using the links I gave you before.

Heres whats on the line 35:

Quote:
header("Location: $gotopage");
ralen is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 09-10-2007, 07:47 PM   #10 (permalink)
Registered User
 
Join Date: Sep 2007
Location: United Kingdom
Posts: 75
OS: XP Media Center


Re: Webforms help

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.
ralen is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 09-10-2007, 07:55 PM   #11 (permalink)
Design Team Member
 
Redcore's Avatar
 
Join Date: Aug 2007
Location: Jamestown, CA
Posts: 717
OS: Linux Mint 7

My System

Re: Webforms help

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:
HTML 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=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:

PHP Code:
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 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 09-10-2007, 07:58 PM   #12 (permalink)
Design Team Member
 
Redcore's Avatar
 
Join Date: Aug 2007
Location: Jamestown, CA
Posts: 717
OS: Linux Mint 7

My System

Re: Webforms help

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.
Redcore is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 09-10-2007, 08:04 PM   #13 (permalink)
Registered User
 
Join Date: Sep 2007
Location: United Kingdom
Posts: 75
OS: XP Media Center


Re: Webforms help

Let me get this right. Is this all that should be in the sendmail.php document:
PHP Code:
<body><?php
// THESE ARE THE VARIABLES THAT YOU NEED TO EDIT!

$sendto "enquiry@3g-codes.co.uk"// for example: username@usershost.com
$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:
PHP 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=iso-8859-1" />
<title>Untitled Document</title>
</head>

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

$sendto "enquiry@3g-codes.co.uk"// for example: username@usershost.com
$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>

?
ralen is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 09-10-2007, 08:12 PM   #14 (permalink)
Registered User
 
Join Date: Sep 2007
Location: United Kingdom
Posts: 75
OS: XP Media Center


Re: Webforms help

Quote:
Originally Posted by Redcore View Post

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

PHP Code:
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.
I tried removing that, but never solved the problem im afraid.

Quote:
Originally Posted by Redcore View Post
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

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.
ralen is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 09-11-2007, 01:29 AM   #15 (permalink)
Design Team Member
 
Redcore's Avatar
 
Join Date: Aug 2007
Location: Jamestown, CA
Posts: 717
OS: Linux Mint 7

My System

Re: Webforms help

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.

Quote:
Originally Posted by ralen
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! :P)

PHP Code:
<?php
// THESE ARE THE VARIABLES THAT YOU NEED TO EDIT!

$sendto "ENTER-YOUR-EMAIL-HERE"// for example: username@usershost.com
$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! :P

Last edited by Redcore; 09-11-2007 at 01:31 AM. Reason: woops...I keep including my darn email...
Redcore is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 09-11-2007, 08:09 AM   #16 (permalink)
Registered User
 
Join Date: Sep 2007
Location: United Kingdom
Posts: 75
OS: XP Media Center


Re: Webforms help

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

Quote:
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.
ralen is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 09-11-2007, 01:43 PM   #17 (permalink)
Design Team Member
 
Redcore's Avatar
 
Join Date: Aug 2007
Location: Jamestown, CA
Posts: 717
OS: Linux Mint 7

My System

Re: Webforms help

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.
Redcore is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 09-11-2007, 06:12 PM   #18 (permalink)
Registered User
 
Join Date: Sep 2007
Location: United Kingdom
Posts: 75
OS: XP Media Center


Re: Webforms help

Quote:
Originally Posted by Redcore View Post
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:

Quote:
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?

Last edited by ralen; 09-11-2007 at 06:17 PM.
ralen is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 09-11-2007, 08:21 PM   #19 (permalink)
Design Team Member
 
Redcore's Avatar
 
Join Date: Aug 2007
Location: Jamestown, CA
Posts: 717
OS: Linux Mint 7

My System

Re: Webforms help

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.
Redcore is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 09-11-2007, 08:33 PM   #20 (permalink)
Registered User
 
Join Date: Sep 2007
Location: United Kingdom
Posts: 75
OS: XP Media Center


Re: Webforms help

Quote:
Originally Posted by Redcore View Post
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:

sendmail.php.zip

function_checkEmail.php.zip

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

Last edited by ralen; 09-11-2007 at 08:42 PM. Reason: spelling error
ralen is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
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 Off
Refbacks are Off




All times are GMT -7. The time now is 08:56 PM.



Copyright 2001 - 2009, Tech Support Forum
Home Tips Plus | Outdoor Basecamp | Automotive Support Forum

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85