Click to See Complete Forum and Search --> : Variable Problems


jazper
06-07-2005, 04:41 AM
Hi.. I have a problem with variables ($name for example). I have these php files (forms) working on other server: http://www.airsept.com/robert2/index.php?loadmod=contact
It is working fine... but when I tried uploading it on the other server(Interland), it worked fine but it doesn't read the variables..
http://216.247.181.157/feedback.php

Do u guys have any idea about this problem? Thanks!

Sheldon
06-07-2005, 04:48 AM
hi, i checked out your page but after filling in every form i still got this reply

You didn't answer who you are
You didn't enter your name
You didn't enter your email
You didn't include a message
You didn't enter how you found AirSept


Please post your feedback1.php code on here?



Thanks Sheldon

jazper
06-07-2005, 04:55 AM
Here is the code of feedback1.php

<?
if (empty($R1)) $error .= "You didn't answer who you are<br>";
if (empty($name)) $error .= "You didn't enter your name<br>";
if (empty($email)) $error .= "You didn't enter your email<br>";
if (empty($text)) $error .= "You didn't include a message<br>";
if (empty($text5)) $error .= "You didn't enter how you found AirSept<br>";
$str = $text; $text_len = strlen($str);
if($text_len > 800) { $error .= "Sorry, you have used more than permitted 800 characters in

your message. Total was $text_len - please shorten your message.<br>"; }

if($email) {
if(isset($_POST['email']))
{
// $email = $email;
// check to make sure email has been filled out with valid address

if (preg_match('/^[-!#$%&\'*+\\.\/0-9=?A-Z^_`{|}~]+@([-0-9A-Z]+\.)+([0-9A-Z]){2,4}$/i',

trim($email))) {
//do nothing the syntax looks good
}
else {$error .= "Your email address has a spelling error<BR>";
}//set error code

// check for valid domain name
$ok = TRUE;
$ok = eregi( "^[_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3}$", $email,
$check);
$ok = getmxrr(substr(strstr($check[0], '@'), 1), $dummy);
if($ok === false)
{
$host = substr($email, strpos($email, '@') + 1);
if(gethostbyname($host) != $host)
{
$ok = true;
}
if ($ok != true) {$error .= "That email address does not seem to be valid - please check<br>";

}
// end of check
}
}} // end of email check


if($error) {

include("feedback.php");

}
else {

include("feedbacksent.php");

}

jazper
06-07-2005, 05:26 AM
I tried uploading a simple script with a variable on it and it still doesn't show up.. I don't know what seems to be the problem with Interland server.

NogDog
06-07-2005, 07:03 AM
First guess is that the server where it works has "register global variables" turned on while the other does not. That's why it's alwyas best to refer to post and get data variables as $_POST['name'] or $_GET['name'] instead of $name, so that you don't have to worry about whether register globals is on. For example, I suspect the first line should be:

if (empty($_POST['R1'])) $error .= "You didn't answer who you are<br>";
# likewise for subsequent lines...

chrys
06-07-2005, 03:59 PM
Just throw in extract($_POST); before all of your code.

jazper
06-07-2005, 10:11 PM
Thanks. It's working now. I changed all my variables with POST function. It seems that the server has the global variable set to off.