logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Coding & Scripting Corner View previous topic :: View next topic
Reply to topic   Topic: Calling php scripts from html form ?
Author
asinsh



Joined: 10 Dec 2005
Posts: 24

PostPosted: Fri 16 Dec '05 0:35    Post subject: Reply with quote

I've now got steffen's latest win32 binary build installed and my phpbb forum is up and running perfectly. Thanks!

Only issue, which I'm sure is just a configuration one: I have a number of html forms in a folder on my server that call php scripts I've written for various things. They worked fine on apache 2.0.55.

Now that I've upgraded to apache 2.2.0, here's what happens:

the html files display fine when viewed in a browser through apache but but when I submit the forms and they take me to the php scipts, the php scripts no longer seem to actually run. Instead, they output php source code that looks something like this:

Code:
"Not Enrolled"' : ''; // if you include the for statement, that will temporarily add in concept that we will print out end of month for each month from 9/30/202 to 2/28/05 // for($single_date = '2002/10/01'; $single_date <= '2005/03/01'; $single_date = date("Y/m/d", strtotime($single_date . "+1 month"))) // { // now, get and dump the answer if asking for a single date if( $mode == 'single_date' ) { // begin by compiling the single date (and make sure it doesn't go beyond the last db date) $single_date = $single_date_year . '/' . $single_date_month . '/' . $single_date_day; $single_date = ( strtotime($single_date) <= strtotime($last_db_date) ) ? $single_date : $last_db_date; // now test who is there on a particular date... $sql = "SELECT firstname, lastname FROM bio WHERE ( ( arrived1 IS NOT NULL AND arrived1 <= '$single_date' AND (left1 > '$single_date' OR left1 IS NULL) ) OR ( arrived2 IS NOT NULL AND arrived2 <= '$single_date' AND (left2 > '$single_date' OR left2 IS NULL) ) ) $sql_exclude ORDER BY lastname"; $result = mysql_query($sql); if(!$result) { echo "Failed to obtain db information"; } if (mysql_error()) { echo "Error Report: ".mysql_error()."

"; } $headcount = mysql_num_rows($result); echo '

I know I've got apache set up correctly to run php scripts generally since my phpbb board works fine...any idea what setting I need to tweak to get these other scripts working again?
Back to top
Steffen
Moderator


Joined: 15 Oct 2005
Posts: 3092
Location: Hilversum, NL, EU

PostPosted: Fri 16 Dec '05 0:42    Post subject: Reply with quote

Hard to say what is the issue. I do not know how you call php in the .html files.

You say:
I submit the forms and they take me to the php scripts.

What do you mean by "submit the forms" and "take me to the php scripts" ?


Steffen

ps.
I hope you do not mind that I made a seperate topic of your issue.
Back to top
asinsh



Joined: 10 Dec 2005
Posts: 24

PostPosted: Fri 16 Dec '05 1:00    Post subject: Reply with quote

THanks for responding (and so quickly!). I have pasted a sample of one of the problem html forms below. As you can see, the first line of the code tells the html to redirect to headcount.php when the user clicks to submit the form. It should redirect and execute the script called headcount.php (and it did that perfectly in apache 2.0.55), but instead it displays the source code of headcount.php in the browser. Anyway, here's the html form:

Code:

<form action="headcount.php" method="post">
<table>
<tr><td colspan="2" width="700" align="center"><b>Headcount Data</b><br />Fill out and click 'Submit' and we'll give you headcount data from info in the school's database through March 1, 2005<br /><br /><br /></td></tr>
<tr>
   <td width="300" valign="top"><input class="post" type="radio" name="mode" value="single_date" checked="checked" />&nbsp; &nbsp;single date headcount<br /></td>
   <td width="400" valign="top">Date for single date headcount:<br /></td>
</tr>
<tr>
   <td></td>
   <td><select name="single_date_month" size="1" />
      <option value="01" />January</option><option value="02" />February</option><option value="03" />March</option><option value="04" />April</option><option value="05" />May</option>
      <option value="06" />June</option><option value="07" />July</option><option value="08" />August</option><option value="09" />September</option><option value="10" />October</option><option value="11" />November</option><option value="12" />December</option></select>

      <select name="single_date_day" size="1" />
      <option value="01" />1</option><option value="02" />2</option><option value="03" />3</option><option value="04" />4</option><option value="5" />5</option>
      <option value="06" />6</option><option value="07" />7</option><option value="08" />8</option><option value="09" />9</option><option value="10" />10</option>
      <option value="11" />11</option><option value="12" />12</option><option value="13" />13</option><option value="14" />14</option><option value="15" />15</option>
      <option value="16" />16</option><option value="17" />17</option><option value="18" />18</option><option value="19" />19</option><option value="20" />20</option>
      <option value="21" />21</option><option value="22" />22</option><option value="23" />23</option><option value="24" />24</option><option value="25" />25</option>
      <option value="26" />26</option><option value="27" />27</option><option value="28" />28</option><option value="29" />29</option><option value="30" />30</option><option value="31" />31</option>
      </select>

      <select name="single_date_year" size="1" />
      <option value="1984" />1984</option><option value="1985" />1985</option><option value="1986" />1986</option><option value="1987" />1987</option><option value="1988" />1988</option>
      <option value="1989" />1989</option><option value="1990" />1990</option><option value="1991" />1991</option><option value="1992" />1992</option><option value="1993" />1993</option>
      <option value="1994" />1994</option><option value="1995" />1995</option><option value="1996" />1996</option><option value="1997" />1997</option><option value="1998" />1998</option>
      <option value="1999" />1999</option><option value="2000" />2000</option><option value="2001" />2001</option><option value="2002" />2002</option><option value="2003" />2003</option>
      <option value="2004" selected="selected" />2004</option><option value="2005" />2005</option>
      </select>
   </td>
</tr>

<tr><td>&nbsp;<br /></td></tr>

<tr>
   <td width="300" valign="top"><input class="post" type="radio" name="mode" value="multiple_year" />&nbsp; &nbsp;multiple year headcount<br /></td>
   <td width="400" valign="top">Years to include in headcount:</td>
</tr>
<tr>
   <td></td>
   <td>First year to include: &nbsp; &nbsp; <select name="multiple_year_start" size="1" />
      <option value="1984" />1984</option><option value="1985" />1985</option><option value="1986" />1986</option><option value="1987" />1987</option><option value="1988" />1988</option>
      <option value="1989" />1989</option><option value="1990" />1990</option><option value="1991" />1991</option><option value="1992" />1992</option><option value="1993" />1993</option>
      <option value="1994" />1994</option><option value="1995" />1995</option><option value="1996" />1996</option><option value="1997" />1997</option><option value="1998" />1998</option>
      <option value="1999" />1999</option><option value="2000" selected="selected" />2000</option><option value="2001" />2001</option><option value="2002" />2002</option><option value="2003" />2003</option>
      <option value="2004" />2004</option>
      </select>
   </td>
</tr>
<tr>
   <td></td>
   <td>Last year to include: &nbsp; &nbsp; <select name="multiple_year_end" size="1" />
      <option value="1984" />1984</option><option value="1985" />1985</option><option value="1986" />1986</option><option value="1987" />1987</option><option value="1988" />1988</option>
      <option value="1989" />1989</option><option value="1990" />1990</option><option value="1991" />1991</option><option value="1992" />1992</option><option value="1993" />1993</option>
      <option value="1994" />1994</option><option value="1995" />1995</option><option value="1996" />1996</option><option value="1997" />1997</option><option value="1998" />1998</option>
      <option value="1999" />1999</option><option value="2000" />2000</option><option value="2001" />2001</option><option value="2002" />2002</option><option value="2003" />2003</option>
      <option value="2004" selected="selected" />2004</option>
      </select>
   </td>
</tr>

<tr><td>&nbsp;<br /></td></tr>

<tr>
   <td width="300" valign="top"><input class="post" type="radio" name="mode" value="arbitrary_period" />&nbsp; &nbsp;arbitrary period headcount<br /></td>
   <td width="400" valign="top">Period to include in headcount:</td>
</tr>
<tr>
   <td></td>
   <td>First date to include: &nbsp; &nbsp; <select name="arbitrary period_start_month" size="1" />
      <option value="01" selected="selected" />January</option><option value="02" />February</option><option value="03" />March</option><option value="04" />April</option><option value="05" />May</option>
      <option value="06" />June</option><option value="07" />July</option><option value="08" />August</option><option value="09" />September</option><option value="10" />October</option><option value="11" />November</option><option value="12" />December</option></select>

      <select name="arbitrary period_start_day" size="1" />
      <option value="01" selected="selected" />1</option><option value="02" />2</option><option value="03" />3</option><option value="04" />4</option><option value="5" />5</option>
      <option value="06" />6</option><option value="07" />7</option><option value="08" />8</option><option value="09" />9</option><option value="10" />10</option>
      <option value="11" />11</option><option value="12" />12</option><option value="13" />13</option><option value="14" />14</option><option value="15" />15</option>
      <option value="16" />16</option><option value="17" />17</option><option value="18" />18</option><option value="19" />19</option><option value="20" />20</option>
      <option value="21" />21</option><option value="22" />22</option><option value="23" />23</option><option value="24" />24</option><option value="25" />25</option>
      <option value="26" />26</option><option value="27" />27</option><option value="28" />28</option><option value="29" />29</option><option value="30" />30</option><option value="31" />31</option>
      </select>

      <select name="arbitrary period_start_year" size="1" />
      <option value="1984" />1984</option><option value="1985" />1985</option><option value="1986" />1986</option><option value="1987" />1987</option><option value="1988" />1988</option>
      <option value="1989" />1989</option><option value="1990" />1990</option><option value="1991" />1991</option><option value="1992" />1992</option><option value="1993" />1993</option>
      <option value="1994" />1994</option><option value="1995" />1995</option><option value="1996" />1996</option><option value="1997" />1997</option><option value="1998" />1998</option>
      <option value="1999" />1999</option><option value="2000" selected="selected" />2000</option><option value="2001" />2001</option><option value="2002" />2002</option><option value="2003" />2003</option>
      <option value="2004" />2004</option><option value="2005" />2005</option>
      </select>
   </td>
</tr>
<tr>
   <td></td>
   <td>Last date to include: &nbsp; &nbsp; <select name="arbitrary period_end_month" size="1" />
      <option value="01" />January</option><option value="02" />February</option><option value="03" />March</option><option value="04" />April</option><option value="05" />May</option>
      <option value="06" />June</option><option value="07" />July</option><option value="08" />August</option><option value="09" />September</option><option value="10" />October</option><option value="11" />November</option><option value="12" selected="selected" />December</option></select>

      <select name="arbitrary period_end_day" size="1" />
      <option value="01" />1</option><option value="02" />2</option><option value="03" />3</option><option value="04" />4</option><option value="05" />5</option>
      <option value="06" />6</option><option value="07" />7</option><option value="08" />8</option><option value="09" />9</option><option value="10" />10</option>
      <option value="11" />11</option><option value="12" />12</option><option value="13" />13</option><option value="14" />14</option><option value="15" />15</option>
      <option value="16" />16</option><option value="17" />17</option><option value="18" />18</option><option value="19" />19</option><option value="20" />20</option>
      <option value="21" />21</option><option value="22" />22</option><option value="23" />23</option><option value="24" />24</option><option value="25" />25</option>
      <option value="26" />26</option><option value="27" />27</option><option value="28" />28</option><option value="29" />29</option><option value="30" />30</option><option value="31" selected="selected" />31</option>
      </select>

      <select name="arbitrary period_end_year" size="1" />
      <option value="1984" />1984</option><option value="1985" />1985</option><option value="1986" />1986</option><option value="1987" />1987</option><option value="1988" />1988</option>
      <option value="1989" />1989</option><option value="1990" />1990</option><option value="1991" />1991</option><option value="1992" />1992</option><option value="1993" />1993</option>
      <option value="1994" />1994</option><option value="1995" />1995</option><option value="1996" />1996</option><option value="1997" />1997</option><option value="1998" />1998</option>
      <option value="1999" />1999</option><option value="2000" />2000</option><option value="2001" />2001</option><option value="2002" />2002</option><option value="2003" />2003</option>
      <option value="2004" selected="selected" />2004</option><option value="2005" />2005</option>
      </select>
   </td>
</tr>

<tr><td>&nbsp;<br /><br /><br /></td></tr>

<tr>
   <td></td>
   <td><input class="post" type="checkbox" name="exclude_unenrolled_kids" />&nbsp;&nbsp;Check here to <b><u>exclude</u></b> kids listed in database as "Not Enrolled"</td>
</tr>


<tr><td>&nbsp;<br /></td></tr>

<tr>
<td></td><td><input type="submit" name="submit" value="Submit" /></td>
</tr>
</table>
</form>
Back to top
Steffen
Moderator


Joined: 15 Oct 2005
Posts: 3092
Location: Hilversum, NL, EU

PostPosted: Fri 16 Dec '05 1:18    Post subject: Reply with quote

I tried above script and it redirects here.

Steffen
Back to top
asinsh



Joined: 10 Dec 2005
Posts: 24

PostPosted: Fri 16 Dec '05 1:25    Post subject: Reply with quote

Steffen wrote:
I tried above script and it redirects here.

Steffen

Right, the phpbb and webcalendar html forms redirect to php scripts that execute fine too. It's just that one set of html forms that redirects in a way where apache doesn't run the script but instead shows the source. That set is in a different subdirectory a few levels down underneath htdocs, but I don't see why that would make any difference.

Bottom line: I know there is nothing wrong with the html forms or the php scripts they redirect to (they work fine with my apache 2.0.55 setup). It's clearly something funny I've done with the conf files in apache 2.2 so that those forms in that directory redirect in a way so that apache doesn't know to execute the php script. Does that ring a bell at all?
Back to top
asinsh



Joined: 10 Dec 2005
Posts: 24

PostPosted: Fri 16 Dec '05 1:37    Post subject: Reply with quote

I have a partial answer. The php files in question started with <? rather than <?php

That used to work fine on my server but now I see I need to add 'php' after the <? at the top of each php file in my apache 2.2.0 setup.

I imagine I must have had some line in my apache 2.0.55 conf file that told it that anything that begins with <? is php and I guess I don't have that in my apache 2.2.0 conf file. Not a big deal.
Back to top
pnllan



Joined: 05 Dec 2005
Posts: 221

PostPosted: Fri 16 Dec '05 10:48    Post subject: Reply with quote

With regards to being able to use <? in PHP script or not, that is purely a PHP Configuration Issue...not Apache.

In PHP, it is referred to by most as Short Tags. Different people have different opinions on using short tags. It really doesn't hurt anything to use short tags, but there are purist out there who like adhering to current standards and would rather not use anything that is considered deprecated.

In the PHP.INI file, locate the directive short_open_tag. If it is set to OFF, then that is why <? was not working.

As far as 'pushing out' raw PHP, I have seen this before. I cannot remember exactly what is was, but it was definitely a PHP Configuration Issue (might have been a missing opening tag issue - which react similiarly to what you are experiencing). Comb through your PHP.INI, and compare it to the last working PHP.INI file. It sounds like you should try turning on short tags. I might be wrong, but I'll take it on the chin if I am.

Let us know how it turns out.
Back to top
asinsh



Joined: 10 Dec 2005
Posts: 24

PostPosted: Sat 17 Dec '05 3:48    Post subject: Reply with quote

pnllan wrote:
With regards to being able to use <? in PHP script or not, that is purely a PHP Configuration Issue...not Apache.

In PHP, it is referred to by most as Short Tags. Different people have different opinions on using short tags. It really doesn't hurt anything to use short tags, but there are purist out there who like adhering to current standards and would rather not use anything that is considered deprecated.

In the PHP.INI file, locate the directive short_open_tag. If it is set to OFF, then that is why <? was not working.

As far as 'pushing out' raw PHP, I have seen this before. I cannot remember exactly what is was, but it was definitely a PHP Configuration Issue (might have been a missing opening tag issue - which react similiarly to what you are experiencing). Comb through your PHP.INI, and compare it to the last working PHP.INI file. It sounds like you should try turning on short tags. I might be wrong, but I'll take it on the chin if I am.

Let us know how it turns out.

Yes, you are right that when I change that line in php.ini taht fixes the problem. But the strange things is that I am using the same php.ini file as Iused with apache 2.0.55 and in apache 2.0.55 I didn't need to turn short tags on in php.ini. It doesn't reallly matter, since now that steffen and you have suggested turning short tags on in php.ini I did that and everything works fine. But I am confused about why the old configuration without turning short tags on in php.ini stil seemed to work. I'm guessing there was some other apache conf line that would have done the same thing...
Back to top
pnllan



Joined: 05 Dec 2005
Posts: 221

PostPosted: Sat 17 Dec '05 9:40    Post subject: Reply with quote

Mr. Green Glad to here the problem is fixed.Very Happy

Confused It is rather curious that you were able to run instantiated PHP with short tags when short tags were not enabled.

Are you running PHP Apache module that Steffen offers in downloads? Wink

What version of PHP were you running with Apache 2.0.55? Embarassed You never said.

In the past, was your PHP running as a CGI binary?
Back to top
asinsh



Joined: 10 Dec 2005
Posts: 24

PostPosted: Sat 17 Dec '05 14:02    Post subject: Reply with quote

pnllan wrote:
...Are you running PHP Apache module that Steffen offers in downloads? Wink
What version of PHP were you running with Apache 2.0.55? Embarassed You never said....

Now that I am running apache 2.2, I am running the php apache module that steffen offers in downloads. But when I was running apache 2.0.55 I was running php 5.1.1 (and before that php 5.1.0 and before that successively earlier versions of php for the last two years....) with the regular php apache module that comes packaged with the regular php windows binary zip package.

pnllan wrote:
...In the past, was your PHP running as a CGI binary?
No. I've been using the regular windows binary zip package and not the cgi only version with an installer.
Back to top
pnllan



Joined: 05 Dec 2005
Posts: 221

PostPosted: Sat 17 Dec '05 18:54    Post subject: Reply with quote

I was just curious and seeking possbilities.

That is definitely unusual, but what counts is that you are up and running now.
Back to top
asinsh



Joined: 10 Dec 2005
Posts: 24

PostPosted: Sun 18 Dec '05 18:14    Post subject: Reply with quote

Well, I now know why I didn't need to turn on short tags in my php.ini file for my earlier setup with apache 2.0.55:

I have in my apache conf file the following line which should tell apache to execute php files rather than treating them as text files:
AddType application/x-httpd-php .php

That line worked fine for apache 2.0.55 but does not seem to do anything for apache 2.2. Maybe I need to tweak that line for apache 2.2? Or maybe there is some other change I made on my server when I upgraded to 2.2 that keeps that conf line from working right?
Back to top
VeronicaSpivy



Joined: 17 Aug 2006
Posts: 1
Location: Earth

PostPosted: Thu 17 Aug '06 5:29    Post subject: Reply with quote

Hi - I know this post was from awhile back, but I had the same problem as you did regarding the php loading as text and not executing as an executable php file. My problem was that I was testing from the file directly (i.e. C:\webs\test\orderform.html) instead of using localhost (http://localhost/orderform.html). Once I changed the url to use localhost then the php file executed fine. Possibly not your solution but maybe it was late at night while you were testing Wink
Back to top


Reply to topic   Topic: Calling php scripts from html form ? View previous topic :: View next topic
Post new topic   Forum Index -> Coding & Scripting Corner