Is this script compatible with 4.3.4?? Help!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tr_man
Forum Newbie
Posts: 4
Joined: Thu Feb 12, 2004 3:54 pm
Location: **WEST SIDE***

Is this script compatible with 4.3.4?? Help!

Post 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:
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

And the error = ?

Dont feel like trying out the whole submit form...
tr_man
Forum Newbie
Posts: 4
Joined: Thu Feb 12, 2004 3:54 pm
Location: **WEST SIDE***

Post 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.
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post 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
tr_man
Forum Newbie
Posts: 4
Joined: Thu Feb 12, 2004 3:54 pm
Location: **WEST SIDE***

Post by tr_man »

Thanks Mark1999,

Man I a dumass when it come to PHP. So everywhere that I have $name, change it $_POST['name']
tr_man
Forum Newbie
Posts: 4
Joined: Thu Feb 12, 2004 3:54 pm
Location: **WEST SIDE***

Post by tr_man »

Mark1999,

You are the man. Turned register_globals on and works like a champ.
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post 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.
Post Reply