Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP Script Help Needed

Status
Not open for further replies.

Ivan1

Programmer
Jun 18, 2001
113
0
0
US
Hello.
I'm dealing with a hosting company that has registered_globals turned off by default. My script runs fine on other servers. Please look at the script below. Any suggestions are much appreciated; my client is bugging me.

Here's what the hosting company said about this:

'The problem lies with the script. In
addition, for your form to work with mail correctly, your script must have a
way to indicate the path to sendmail, which is the $mailprog, which
eventually handles all mail that originates from the server. If you are not
doing any php coding that pertains to using global variables
(registered_globals turned off by default) then you will have some problems
because the registered_globals variable is turned off by default on this
plan.'

Ivan

<?
/* subject */
$subject = "QUOTE REQUEST";

/* additional header pieces for errors, From cc's, bcc's, etc */
$headers = "From: $fname $lname <$email>\n";
$headers .= "X-Sender: <$email>\n";
$headers .= "X-Mailer: PHP\n"; // mailer
$headers .= "X-Priority: 1\n"; // Urgent message!
$headers .= "Return-Path: $fname $lname <$email>\n"; // Return path for errors

/* recipients */
$recipient = "ivan@foundation-one.net";


/* and now mail it */
mail($recipient, $subject, "Hello,\nMy name is $fname $lname.\nMy phone number is $phone.\nMy e-mail is $email.\nMy comments: $comments.\nThis is how we heard about you: $question.", $headers);
echo "<META http-EQUIV=\"refresh\" CONTENT=\"0;URL=http://www.foundation-one.net/Bulldog\">";

// Replay
// ---------------------------

/* subject */
$subject = "Bulldog Movers Inc";

/* additional header pieces for errors, From cc's, bcc's, etc */
$headers = "From: Bulldog Movers Inc <ivan@foundation-one.net>\n";
$headers .= "X-Sender: <ivan@foundation-one.net>\n";
$headers .= "X-Mailer: PHP\n"; // mailer
$headers .= "X-Priority: 1\n"; // Urgent message!
$headers .= "Return-Path: Quote Request Reply <ivan@foundation-one.net>\n"; // Return path for errors

/* recipients */
$recipient = $email;

/* message */
$message = "Dear $fname $lname,

Thank you so much for contacting Bulldog Movers, Inc. regarding your relocation. Please rest assured that a Bulldog Movers representative will contact you immediately.

Sincerely,
Bulldog Movers, Inc.
5080 Highlands Parkway
Suite A1
Atlanta, GA 30082

info@bulldogmovers.net
(770) 333.8100";

mail($recipient, $subject, $message, $headers);
?>
 
I would not complain about a hosting company that has register_globals off. That's the right thing to do and I am sure that the vast majority of host to be taken seriously follow the recommendation from Zend to keep it that way.

If the vars are sent using POST use $_POST['varname'], for GET use $_GET['varname'] or have a look at the $_REQUEST[] superglobal array.

It is in your own interest to develop your PHP under the most restrictive circumstances - that's the only guarantee that it will run everywhere.
 
Quit trying to use bare variables, such as $email or $question. Use $_POST['email'] and $_POST['question'] or $_GET['email'] and $_GET['question'], depending on whether the data submitted to the script is coming from a POST-method or GET-method form, respectively.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
I do appreciate your feedback. However, that's the only way I know how to write code, so please, if you would like to be helpful let me know how I can alter the existing code to fit the needed parameters.

Ivan

 
The needed alterations were suggested in both posts above:
Variables that come from the form trough POST should be referred to as $_POST['varname']. For GET it's just $_GET['varname']

Identify the vars that are transfereed and just assign them in the top portion of your script - this is the quick fix.
Code:
<?php
$email = $_POST['email'];
$fname = $_POST['fname'];
$lname = $_POST['lanme'];
# etc.

If you are unsure which and how vars are being sent, inspect what the originating form has for method.

All local variables - which are not provided from the user - can be just plain vars, $whatever.
 
If you really want the register globals, just enable them on your script.

ini_set("register_globals","1");
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top