Page 1 of 1

Is this script compatible with 4.3.4?? Help!

Posted: Thu Feb 12, 2004 3:54 pm
by tr_man
Hello yall,

This probably a stupid question, but I have a script that I running for about four month that from a guestbook that I made in flash. Then my server upgraded there PHP to 4.3.4 :( So now it is given me an error. I have it runnin on another server here:http://www.langers.com/GUESTBOOK/guestbook.html

And this where the one with the error is:http://www.socadia.com/guestbook1.swf


Here is the script:

Code: Select all

<?php
<?

if (!isset($name) || !isset($email) || !isset($message) || empty($name) || empty($email) || empty($message)) {
print "&result=Fail";
print "&errorMsg=" . urlencode("Input required for all fields.");
exit;
}

$email = strtolower($email);

addentry($name, $email, $website, $message);

function addentry($name, $email, $website, $message) {

$posted = strftime("%c %h %p");

$message = stripslashes($message);

$filename = "entry.txt";
$fp = fopen( $filename,"r"); 
$OldData = fread($fp, 80000);
$OldData = preg_replace("/^&result=okay&entries=/", "", $OldData);
fclose($fp); 

$Input = "<font color="#FFFFFF">Name:</font> $name\n<font color="#FFFFFF">Email:</font><font color="#FF0000"><A href="mailto:$email"> $email</A></font><br>\n<font color="#FFFFFF">Website:</font><font color="#FF0000"><A href="http://$website"target="_blank"> $website</A></font><br>\n<font color="#FFFFFF">Posted:</font> $posted\n<font color="#FFFFFF">Message:</font> $message\n\n";

$New = "&result=okay&entries=$Input$OldData";
	
$fp = fopen( $filename,"w"); 
fwrite($fp, $New);
fclose($fp); 

// Send admin an email when new entry occurs
mailAdmin($name, $email, $website, $message);
}

function mailAdmin($name, $email, $website, $message) {
	$mailTo = "info@socadia.com";
	$mailFrom = "From: <info@socadia.com>";
	$mailSubject = "New Guestbook Entry";
	$mailBody = "A visitor to your site has left the following information in your guestbook:\n
	Name: $name
	Email: $email
	Website: $website
	The visitor commented:
	------------------------------
	$message 
	------------------------------
	You can view the message at:
	http://www.yoursite.com";
	mail($mailTo, $mailSubject, $mailBody, $mailFrom);
	mail($email, "SOCADIA MUSIC", "Thank you for your guestbook message", "From: SOCADIA MUSIC");
}

print "&result=okay";
exit;

?>
?>
:wink:

Posted: Thu Feb 12, 2004 4:01 pm
by ol4pr0
And the error = ?

Dont feel like trying out the whole submit form...

Posted: Thu Feb 12, 2004 4:17 pm
by tr_man
well this is error that is coming up in the right text box saying:

print "&errorMsg=" . urlencode("Input required for all fields.");

That is what is coming up. Do you know if it is compatible with 4.3.4?

Did you try both url's there is nothin different, just the design.

Posted: Thu Feb 12, 2004 4:25 pm
by markl999
PHP >= 4.2.0 has register_globals turned Off by default, and this script needs then On ... are they On?
If not either turn them On or even better start using $_POST['name'] where you would use $name

See http://php.net/variables.predefined more info

Posted: Thu Feb 12, 2004 4:35 pm
by tr_man
Thanks Mark1999,

Man I a dumass when it come to PHP. So everywhere that I have $name, change it $_POST['name']

Posted: Thu Feb 12, 2004 5:25 pm
by tr_man
Mark1999,

You are the man. Turned register_globals on and works like a champ.

Posted: Thu Feb 12, 2004 7:28 pm
by McGruff
Better to adjust your script not register globals settings.

But if you must have register globals on, are you testing with error reporting set to E_ALL? If not, register globals on can be a big security risk.

E_ALL will show any undefined vars & indexes (provided you aren't logging errors). Anyone can insert any value they like to these with reg globs on.