Jump to content

Problem with PHP script


SeanH228

Recommended Posts

Hello everyone,

I having problems with a script executing properly on my IIS 6 Webserver. PHP is installed manually as recommended from [a href=\"http://www.php.net\" target=\"_blank\"]http://www.php.net[/a] and I have followed the directions on moving the PHP files to the correct directories and adding the Web Server extensions. The problem is this. Our Webmaster createda form using dreamweaver and is trying to use this PHP script to execute the options set forth in the script. Here is the script in question

<?php
//--------------------------Set these paramaters--------------------------

// Subject of email sent to you.
$subject = 'Residential Repair Request';

// Your email address. This is where the form information will be sent.
$emailadd = 'oceans@aimtree.org';

// Where to redirect after form is processed.
$url = 'http://www.aimtree.org/pwthankyou.htm';

// Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
$req = '0';

// --------------------------Do not edit below this line--------------------------
$text = "Results from form:\n\n";
$space = ' ';
$line = '
';
foreach ($_POST as $key => $value)
{
if ($req == '1')
{
if ($value == '')
{echo "$key is empty";die;}
}
$j = strlen($key);
if ($j >= 20)
{echo "Name of form element $key cannot be longer than 20 characters";die;}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ' ';}
$value = str_replace('\n', "$line", $value);
$conc = "{$key}:$space{$value}$line";
$text .= $conc;
$space = ' ';
}
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>

Evertime we go to use the Submit function of this form it produces this same code in the browser. This tells me the script is not executing but I don't know why. The phpinfo() files executes correctly on the server and I can see all the configuration settings as it says I should. Don't know if everything is correct in the php.ini file though. I am gasping for help here as I need to get these forms working by a deadline. Any help in this matter is greatly appreciated. Thanking you in advance.
Link to comment
Share on other sites

[!--quoteo(post=374703:date=May 17 2006, 12:13 PM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ May 17 2006, 12:13 PM) [snapback]374703[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Make sure you are saving your files with a [b].php[/b] extension and not anyother extension! Such as .html
[/quote]
The file is saved as a .php file I just don't know why it won't execute
Link to comment
Share on other sites

[!--quoteo(post=374711:date=May 17 2006, 12:24 PM:name=SeanH228)--][div class=\'quotetop\']QUOTE(SeanH228 @ May 17 2006, 12:24 PM) [snapback]374711[/snapback][/div][div class=\'quotemain\'][!--quotec--]
The file is saved as a .php file I just don't know why it won't execute
[/quote]
OK I have rechecked the syntax in the script and I found that I was missing a space after the php tag . I noticed this because as I combed through each line I noticed that there was a space afer each line of code. Now the script seems to run but I am getting this when I click on the Submit button of my form

"Name of form element location_description cannot be longer than 20 characters"

Any help please advise
Link to comment
Share on other sites

[!--quoteo(post=374758:date=May 17 2006, 03:06 PM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ May 17 2006, 03:06 PM) [snapback]374758[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I suspect you need to compare the length of [b]$value[/b] rather than $key.
[/quote]
changed the $j variable to equal 50 instead of 20 seemed to work I also changed all related variables with the =20 entry to 50 and the script now at least appears to work. My thank you page for submitting the form displays in my browser the only thing that doesn't work now is the email. Do you ave any idea how to set this up? Is this a setting in PHP or on my webserver somewhere? My webserver resides in our DMZ and the email server is on the inside LAN. Thanks Andy for opening my eye to the $value variable.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.