Web Hosting Talk







View Full Version : help with php mail


sir_han
02-25-2005, 04:19 PM
i have a php script that is used as a contact form and sends me an email when someone hit submit:

here is the code:

<?php

/************************************************************************/
/* PHP ContactMe v1.0 */
/* =========================== */
/* */
/* Written by Steve Dawson - http://www.stevedawson.com */
/* Freelance Web Developer - PHP, Perl and Javascript programming */
/* */
/* This program is free software. You can redistribute it and/or modify */
/************************************************************************/
##
## -- --------- START OF CONFIG SECTION --------- ##
## STEP ONE: Change the info below to your details

$SendToEmail = "myemail@domain.com"; ## Your Email Address
$YourWebsiteURL = "http://www.mysite.com"; ## Your Website URL
$YourName = "sir_han"; ## Your Name or Company Name
$yoursubject = "my subject"; ## The Email Subject Line
$ThankyouURL = "http://www.mysites.com/thank_you_url.html"; ## Send them here after they have filled in the form

## STEP TWO: Change details below for the email footer of the confirmation email.
$EmailFooter = "
";
## ---------- END OF CONFIG SECTION ------------- ##

## If they call this page direct from the browser, send them away because they havent filled in the form!
if(!isset($email)) {
header("location: $YourWebsiteURL"); ## Redirect them to your websites front page
exit();
}

## Send the Email to you ....
$yoursubject = "$yoursubject";
$emailtext = "
-----------------------------------------------------------------------------
".$yoursubject."
-----------------------------------------------------------------------------

Name: ".$name."
Email: ".$email."
Message: ".$message."
";
$yoursubject = stripslashes($yoursubject);
$emailtext = stripslashes($emailtext);
@mail("$SendToEmail", $yoursubject, $emailtext, "From: $email"); ## Email Sent

## Now lets send a thankyou email to the sender
$emailsubject = "Re: ".$yoursubject."";
$autoemail = "
-----------------------------------------------------------------------------
Re: ".$yoursubject."
-----------------------------------------------------------------------------

Thank you ".$name." for the message sent at mysite.com.
The details you entered are:

Name: ".$name."
Email: ".$email."
Message: ".$message."

".$EmailFooter."
";
$yoursubject = stripslashes($yoursubject);
$autoemail = stripslashes($autoemail);
@mail($email, $emailsubject, $autoemail, "From: $SendToEmail");

header("Location: $ThankyouURL"); ## Don't change this, change the $ThankyouURL at the top!
exit;
?>


my question is, this script worked perfectly on my Redhat 7.3 server, but it's not working on my Rehat 9 server. Is there a PHP compilation I am missing that needs to make this work...like a mail compilation, etc.?

mattwade
02-25-2005, 04:51 PM
It's hard to say without telling us what it is or what it is not doing. But, a quick guess would be that your Redhat 9 server has register_globals turned off in the php.ini file. That script won't work right with register_globals off.

To make it work properly with register_globals off, change:

if(!isset($email)) {

to:

if(!isset($_REQUEST['email'])) {

mattwade
02-25-2005, 04:55 PM
sorry...you will have to change the other instances of $message, $email, and $name to $_REQUEST['message'], $_REQUEST['email'], and $_REQUEST['name']

sir_han
02-25-2005, 05:35 PM
hmmm i don't see "register_global" anywhere in my php.ini.

here's the file:

$
; Minimum client message severity to display.$
sybct.min_client_severity = 10$
$
[bcmath]$
; Number of decimal digits for all bcmath functions.$
bcmath.scale = 0$
$
[browscap]$
;browscap = extra/browscap.ini$
$
[Informix]$
; Default host for ifx_connect() (doesn't apply in safe mode).$
ifx.default_host =$
$
; Default user for ifx_connect() (doesn't apply in safe mode).$
ifx.default_user =$
$
; Default password for ifx_connect() (doesn't apply in safe mode).$
ifx.default_password =$
$
; Allow or prevent persistent links.$
ifx.allow_persistent = On$
$
; Maximum number of persistent links. -1 means no limit.$
ifx.max_persistent = -1$
$
; Maximum number of links (persistent + non-persistent). -1 means no limit.$
ifx.max_links = -1$
$
; If on, select statements return the contents of a text blob instead of its id.$
ifx.textasvarchar = 0$
$
; If on, select statements return the contents of a byte blob instead of its id.$
ifx.byteasvarchar = 0$
$
; Trailing blanks are stripped from fixed-length char columns. May help the$
; life of Informix SE users.$
ifx.charasvarchar = 0$
$
; If on, the contents of text and byte blobs are dumped to a file instead of$
; keeping them in memory.$
ifx.blobinfile = 0$
$
; NULL's are returned as empty strings, unless this is set to 1. In that case,$
; NULL's are returned as string 'NULL'.$
ifx.nullformat = 0$
$
[Session]$
; Handler used to store/retrieve data.$
session.save_handler = files$
$
; Argument passed to save_handler. In the case of files, this is the path$
; where data files are stored. Note: Windows users have to change this $
; variable in order to use PHP's session functions.$
session.save_path = /tmp$
$
; Whether to use cookies.$
session.use_cookies = 1$
$
$
; Name of the session (used as cookie name).$
session.name = PHPSESSID$
$
; Initialize session on request startup.$
session.auto_start = 0$
$
; Lifetime in seconds of cookie or, if 0, until browser is restarted.$
session.cookie_lifetime = 0$
$
; The path for which the cookie is valid.$
session.cookie_path = /$
$
; The domain for which the cookie is valid.$
session.cookie_domain =$
$
; Handler used to serialize data. php is the standard serializer of PHP.$
session.serialize_handler = php$
$
; Percentual probability that the 'garbage collection' process is started$
; on every session initialization.$
session.gc_probability = 1$
$
; After this number of seconds, stored data will be seen as 'garbage' and$
; cleaned up by the garbage collection process.$
session.gc_maxlifetime = 1440$
$
; Check HTTP Referer to invalidate externally stored URLs containing ids.$
; HTTP_REFERER has to contain this substring for the session to be$
; considered as valid.$
session.referer_check =$
$
; How many bytes to read from the file.$
session.entropy_length = 0$
$
; Specified here to create the session id.$
session.entropy_file =$
$
;session.entropy_length = 16$
$
;session.entropy_file = /dev/urandom$
$
; Set to {nocache,private,public} to determine HTTP caching aspects.$
session.cache_limiter = nocache$
$
; Document expires after n minutes.$
session.cache_expire = 180$
$
; use transient sid support if enabled by compiling with --enable-trans-sid.$
session.use_trans_sid = 1$
$
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"$
$
[MSSQL]$
; Allow or prevent persistent links.$
mssql.allow_persistent = On$
$
; Maximum number of persistent links. -1 means no limit.$
mssql.max_persistent = -1$
$
; Maximum number of links (persistent+non persistent). -1 means no limit.$
mssql.max_links = -1$
$
; Minimum error severity to display.$
mssql.min_error_severity = 10$
$
; Minimum message severity to display.$
mssql.min_message_severity = 10$
$
; Compatability mode with old versions of PHP 3.0.$
mssql.compatability_mode = Off$
$
; Valid range 0 - 2147483647. Default = 4096.$
;mssql.textlimit = 4096$
$
; Valid range 0 - 2147483647. Default = 4096.$
;mssql.textsize = 4096$
$
; Limits the number of records in each batch. 0 = all records in one batch.$
;mssql.batchsize = 0$
$
[Assertion]$
; Assert(expr); active by default.$
;assert.active = On$
$
; Issue a PHP warning for each failed assertion.$
;assert.warning = On$
$
; Don't bail out by default.$
;assert.bail = Off$
$
; User-function to be called if an assertion fails.$
;assert.callback = 0$
$
; Eval the expression with current error_reporting(). Set to true if you want$
; error_reporting(0) around the eval().$
;assert.quiet_eval = 0$
$
[Ingres II]$
; Allow or prevent persistent links.$
ingres.allow_persistent = On$
$
; Maximum number of persistent links. -1 means no limit.$
ingres.max_persistent = -1$
$
; Maximum number of links, including persistents. -1 means no limit.$
ingres.max_links = -1$
$
; Default database (format: [node_id::]dbname[/srv_class]).$
ingres.default_database =$
$
; Default user.$
ingres.default_user =$
$
; Default password.$
ingres.default_password =$
$
[Verisign Payflow Pro]$
; Default Payflow Pro server.$
pfpro.defaulthost = "test-payflow.verisign.com"$
$
; Default port to connect to.$
pfpro.defaultport = 443$
$
; Default timeout in seconds.$
pfpro.defaulttimeout = 30$
$
; Default proxy IP address (if required).$
;pfpro.proxyaddress =$
$
; Default proxy port.$
;pfpro.proxyport =$
$
; Default proxy logon.$
;pfpro.proxylogon =$
$
; Default proxy password.$
;pfpro.proxypassword =$
$
[Sockets]$
; Use the system read() function instead of the php_read() wrapper.$
sockets.use_system_read = On$
$
[com]$
; path to a file containing GUIDs, IIDs or filenames of files with TypeLibs$
;com.typelib_file = $
; allow Distributed-COM calls$
;com.allow_dcom = true$
; autoregister constants of a components typlib on com_load()$
;com.autoregister_typelib = true$
; register constants casesensitive$
;com.autoregister_casesensitive = false$
; show warnings on duplicate constat registrations$
;com.autoregister_verbose = true$
$
[Printer]$
;printer.default_printer = ""$
$
[mbstring]$
;mbstring.internal_encoding = EUC-JP$
;mbstring.http_input = auto$
;mbstring.http_output = SJIS$
;mbstring.detect_order = auto$
;mbstring.substitute_character = none;$
$
[FrontBase]$
;fbsql.allow_persistent = On$
;fbsql.autocommit = On$
;fbsql.default_database = $
;fbsql.default_database_password =$
;fbsql.default_host =$
;fbsql.default_password =$
;fbsql.default_user = "_SYSTEM"$
;fbsql.generate_warnings = Off$
;fbsql.max_connections = 128$
;fbsql.max_links = 128$
;fbsql.max_persistent = -1$
;fbsql.max_results = 128$
;fbsql.batchSize = 1000$
$
; Local Variables:$
; tab-width: 4$
; End:$

mattwade
02-25-2005, 10:03 PM
If it isn't specified, it defaults to off.

http://us3.php.net/manual/en/ini.core.php#ini.register-globals