473,785 Members | 2,480 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Form not working when called through Include

Hi:

I have my index.php page.

For the header, sidebar, and footer, those are separate php pages that I
call into the index.php page.

My sidebar.php page has a form in it, that works fine if I load the page by
itself. However when I try to use it in the index.php page being called by
an include, it doesn't work.

Is there a way to make it so it does work? I think there may be some way to
use $_GET to make this work, but I'm not quite sure how to implement it.

Thanks!

Here is my code just incase it's needed:

<?
$form_block = "
<TABLE border=1><TR><T D align=center>

<FORM METHOD=\"POST\" ACTION=\"$PHP_S ELF\">
<span class=\"textmes sage\">
<strong>Send To:</strong><br>
<SELECT NAME=\"name_sel ect\" class=\"textbox \">
<option value=\"1111111 111 at messaging.nexte l.com\">Greg </option>
<option value=\"1111111 111 at messaging.nexte l.com\">John</option>
<option value=\"1111111 111 at messaging.nexte l.com\">Fred</option>
</select>

<br>
<strong>Name: </strong><br>
<INPUT type=\"text\" class=\"textbox \" NAME=\"sender_n ame\" SIZE=18>
<br>
<strong>Message :</strong><br>

<TEXTAREA NAME=\"limitedt extarea\" class=\"textbox \" cols=15
onKeyDown=\"lim itText(this.for m.limitedtextar ea,this.form.co untdown,100);\"
onKeyUp=\"limit Text(this.form. limitedtextarea ,this.form.coun tdown,100);\"

</TEXTAREA>
<span class=\"smallfo nt\">(Max Characters: 100)<br>
You have <input class=\"textbox \" readonly type=\"text\"
name=\"countdow n\" size=1 value=\"100\">c haracters left.</span>

<INPUT type=\"hidden\" name=\"op\" value=\"ds\">
<INPUT TYPE=\"submit\" class=\"submit\ " NAME=\"submit\" VALUE=\"Send
This Form\">

</span>
</FORM>

</TD></TR>
</TABLE>
";
if ($_POST['op'] != "ds") {
echo "$form_bloc k";

} else if ($_POST['op'] == "ds") {
//check value of $_POST[sender_name]
if ($_POST['sender_name'] == "") {
$name_err = "<font color=red>Pleas e enter your
name!</font><br>";
$send = "no";
}
//check value of $_POST[limitedtextarea]
if ($_POST['limitedtextare a'] == "") {
$message_err = "<font color=red>Pleas e enter your
message!</font><br>";
$send = "no";
}
if ($send != "no") {
//it's okay to send, so build the mail

$msg = "Message: $_POST[limitedtextarea]\n\n";

$to = $_POST['name_select'];
$sender = $_POST['sender_name'];
$subject = "";
$mailheaders = "From: $sender
<text @ web.com>\n";
//send the mail
mail ($to, $subject, $msg, $mailheaders);
//display confirmation to user
echo "<p>Mail has been sent!</p>";
} else if ($send =="no") {
//print error messages
echo "$name_err" ;
echo "$message_e rr";
echo "$form_bloc k";
}
}

?>
Jul 17 '05 #1
8 6557
One quick glance of an experienced eye allowed to understand the blurred
and almost unreadable Greg A's handwriting:
Hi:

I have my index.php page.

For the header, sidebar, and footer, those are separate php pages that
I call into the index.php page.

My sidebar.php page has a form in it, that works fine if I load the
page by itself. However when I try to use it in the index.php page
being called by an include, it doesn't work.

Is there a way to make it so it does work? I think there may be some
way to use $_GET to make this work, but I'm not quite sure how to
implement it.

Thanks!

Here is my code just incase it's needed:

<?
$form_block = "
<TABLE border=1><TR><T D align=center>

<FORM METHOD=\"POST\" ACTION=\"$PHP_S ELF\">
Something's fishy about the above line... If you want the form to send
the values to the same file that's the form in, you should use
$_SERVER['PHP_SELF'], unless of course you have register_global s set to
on in php.ini - which is NOT a good idea.
However, IF you have register_global s on, it SHOULD work. Could you post
what exactly happens - what page get's loaded upon submiting the form,
or that no page is loaded, or watever else actually happens? That could
help to track down the problem.
<snip>


Cheers
Mike
Jul 17 '05 #2
*** Greg A wrote/escribió (Tue, 26 Apr 2005 20:32:23 -0700):
My sidebar.php page has a form in it, that works fine if I load the page by
itself. However when I try to use it in the index.php page being called by
an include, it doesn't work.


I cannot see any include in your sample code. However, if I'm to guess, I'd
say you aren't including the code itself but the result of executing it.
--
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
--
Jul 17 '05 #3

"Michal Wozniak" <mikiwoz_remove _this@yahoo_rem ove_this.co.uk> wrote in
message news:d4******** **@213-238-75-8.adsl.inetia.p l...
One quick glance of an experienced eye allowed to understand the blurred
and almost unreadable Greg A's handwriting:
Hi:

I have my index.php page.

For the header, sidebar, and footer, those are separate php pages that
I call into the index.php page.

My sidebar.php page has a form in it, that works fine if I load the
page by itself. However when I try to use it in the index.php page
being called by an include, it doesn't work.

Is there a way to make it so it does work? I think there may be some
way to use $_GET to make this work, but I'm not quite sure how to
implement it.

Thanks!

Here is my code just incase it's needed:

<?
$form_block = "
<TABLE border=1><TR><T D align=center>

<FORM METHOD=\"POST\" ACTION=\"$PHP_S ELF\">


Something's fishy about the above line... If you want the form to send
the values to the same file that's the form in, you should use
$_SERVER['PHP_SELF'], unless of course you have register_global s set to
on in php.ini - which is NOT a good idea.
However, IF you have register_global s on, it SHOULD work. Could you post
what exactly happens - what page get's loaded upon submiting the form,
or that no page is loaded, or watever else actually happens? That could
help to track down the problem.
<snip>


Cheers
Mike

Hi:

Let me start off with the problem I was running into (which I should have
mentioned previously).

Well the error I'm getting is:

Http 405 - Resource not allowed
Internet Information Services.

(I'd rather use Apache, but I don't have a choice)

I saw this page which explained stuff about the error:
http://www.somacon.com/blog/page26.php

However, my settings seem to be fine. And as I mentioned, the sidebar.php
page processes fine if I load it by itself rather than in an include.

If I make the action a separate PHP file, rather than php_self, it also
works fine. But I don't want an entire new page to load. I just wanted the
page to stay where it is.

I looked into what you said, and my register global is set to off.

I tried changing the line to: <FORM METHOD=\"POST\"
ACTION=$_SERVER['$PHP_SELF']>
However when I do that, I get this error:

Parse error: syntax error, unexpected T_ENCAPSED_AND_ WHITESPACE, expecting
T_STRING or T_VARIABLE or T_NUM_STRING in C:\Inetpub\wwwr oot\new\sidebar .php
on line 72

Still lost.....

I was also simply using <? include 'sidebar.php'; ?>, perhaps this needs to
be more elaborate?

Thanks!
Jul 17 '05 #4

"Alvaro G Vicario" <al************ ******@telecomp uteronline.com> wrote in
message news:3d******** *************** ******@40tude.n et...
*** Greg A wrote/escribió (Tue, 26 Apr 2005 20:32:23 -0700):
My sidebar.php page has a form in it, that works fine if I load the page
by
itself. However when I try to use it in the index.php page being called
by
an include, it doesn't work.


I cannot see any include in your sample code. However, if I'm to guess,
I'd
say you aren't including the code itself but the result of executing it.
--
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
--


Alvaro:

Hi, thanks for the response. I was using: <? include 'sidebar.php'; ?>

Should I be using this a little differently? I made another response up
above of the exact problem I am having. The form loads fine and looks good,
just the problem when I submit it.

Thanks!

-Greg

Jul 17 '05 #5
One quick glance of an experienced eye allowed to understand the blurred
and almost unreadable Greg A's handwriting:
Hi:

Let me start off with the problem I was running into (which I should
have mentioned previously).

Well the error I'm getting is:

Http 405 - Resource not allowed
Internet Information Services.

(I'd rather use Apache, but I don't have a choice)

I saw this page which explained stuff about the error:
http://www.somacon.com/blog/page26.php

However, my settings seem to be fine. And as I mentioned, the
sidebar.php page processes fine if I load it by itself rather than in
an include.

If I make the action a separate PHP file, rather than php_self, it also
works fine. But I don't want an entire new page to load. I just wanted
the page to stay where it is.

I looked into what you said, and my register global is set to off.
Well, here's your bug! :]
But...
I tried changing the line to: <FORM METHOD=\"POST\"
ACTION=$_SERVER['$PHP_SELF']>
However when I do that, I get this error:

Parse error: syntax error, unexpected T_ENCAPSED_AND_ WHITESPACE,
expecting T_STRING or T_VARIABLE or T_NUM_STRING in
C:\Inetpub\wwwr oot\new\sidebar .php on line 72
Yes, because you forgot about the \"'s :)
<FORM METHOD=\"POST\" > ACTION=\"{$_SER VER['$PHP_SELF']}\">
this should work - at least it won't give you the parse error.
And it should definetely solve your problem, as far as I can see.

If not, you could also check, what is actually being written as an action
- try putting an
echo "Action is: " . $_SERVER['$PHP_SELF'];
somewhere in sidebar.php and check whether it is what you expect it to
be.
I was also simply using <? include 'sidebar.php'; ?>, perhaps this
needs to be more elaborate?
No, that should be just fine.
Thanks!


Cheers
Mike

Jul 17 '05 #6
Stupid Question but if you change the form action to get does the page
load? I am having problems with a page that will not load if I use a
post action but will work with a get action.

Jul 17 '05 #7

"Michal Wozniak" <mikiwoz_remove _this@yahoo_rem ove_this.co.uk> wrote in
message news:d4******** **@213-238-75-8.adsl.inetia.p l...
One quick glance of an experienced eye allowed to understand the blurred
and almost unreadable Greg A's handwriting:
Hi:

Let me start off with the problem I was running into (which I should
have mentioned previously).

Well the error I'm getting is:

Http 405 - Resource not allowed
Internet Information Services.

(I'd rather use Apache, but I don't have a choice)

I saw this page which explained stuff about the error:
http://www.somacon.com/blog/page26.php

However, my settings seem to be fine. And as I mentioned, the
sidebar.php page processes fine if I load it by itself rather than in
an include.

If I make the action a separate PHP file, rather than php_self, it also
works fine. But I don't want an entire new page to load. I just wanted
the page to stay where it is.

I looked into what you said, and my register global is set to off.


Well, here's your bug! :]
But...
I tried changing the line to: <FORM METHOD=\"POST\"
ACTION=$_SERVER['$PHP_SELF']>
However when I do that, I get this error:

Parse error: syntax error, unexpected T_ENCAPSED_AND_ WHITESPACE,
expecting T_STRING or T_VARIABLE or T_NUM_STRING in
C:\Inetpub\wwwr oot\new\sidebar .php on line 72


Yes, because you forgot about the \"'s :)
<FORM METHOD=\"POST\" > ACTION=\"{$_SER VER['$PHP_SELF']}\">
this should work - at least it won't give you the parse error.
And it should definetely solve your problem, as far as I can see.

If not, you could also check, what is actually being written as an action
- try putting an
echo "Action is: " . $_SERVER['$PHP_SELF'];
somewhere in sidebar.php and check whether it is what you expect it to
be.
I was also simply using <? include 'sidebar.php'; ?>, perhaps this
needs to be more elaborate?


No, that should be just fine.
Thanks!


Cheers
Mike


This worked great. Thanks for your help, I appreciate it! =)
Jul 17 '05 #8
One quick glance of an experienced eye allowed to understand the blurred
and almost unreadable Greg A's handwriting:
This worked great. Thanks for your help, I appreciate it! =)


No problem, my pleasure. :)

Cheers
Mike

Jul 17 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
6027
by: Randell D. | last post by:
HELP! I am determined to stick with this... I'm getting there... for those who haven't read my earlier posts, I'm createing what should be a simple function that I can call to check that required fields in a form have values. I'm writing the values to the client using document.write only so that I can confirm that the values are there to be played with - this is not the final result so please (unless it's leading to the script failure)...
4
9303
by: Stuart Perryman | last post by:
Hi, I have the following code which works just fine in IE6 but not in Firefox. It is an extract of several table rows each with an individual form. It is generated by php. <form action="MaintNotification.php?ReqID=5" method="post" name="frm5"> <tr align="left" bgcolor="#dddddd" class="text" onClick="submit()"
3
6615
by: Richard | last post by:
Hi, I have a form based on a table. When I filter the form I want to run a report based on the same table with the same filter as the form. No problem until I want to filter a combo box where the text value is on a different table. The me.filter is then a text instead of the id-number from the lookup table. This causes the report to prompt for the parameter. How do I get by this problem? Do I need to create a temporary table? I rather...
25
10266
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the data in each record, which includes the ID of the father and the mother (who also have records in the table). One record per form. I have a Tab Control in the form, and in one of the tabs I have a subform (sfmSiblings) in which I wish to list...
4
3175
by: Kathy | last post by:
What is the standard technique for handling the fields in the following scenario on a continuous form? Multiple Divisions. Each Division has multiple Buildings. Each Building has a Supervisor. Tables: (abbreviated) TblDivision DivisionID
3
8631
by: garyusenet | last post by:
Dear Professionals, I have recently been using the wonderful krypton toolkit and am trying to use them in my small hobby application. I include this bit of info as an aside really because i'm sure my question can be extrapolated to the more general case, so here goes! I have a box standard windows forms project. (File, New Project, Windows Application, OK)
2
2657
by: Ralph | last post by:
Hi I don't understand why it's not working: function schedule(imTop){ this.tdImagesTop = imTop; } schedule.prototype.selectEl = function() { alert(this.tdImagesTop);
12
3841
by: colt28 | last post by:
Ok so I found an ajax contact form script but i can't get the b****** to work. I made a bunch of alterations to it and it didn't work so i replaced everything with the original and it still didn't work...dunno why, but anyhow. The form appears after a delay on the page in a hidden DIV. The original form just had name, email and message, but i have to add a few questions to it so i did and i also added some code from another script i found to...
2
2327
by: adwest | last post by:
Forgive me if this is a foolish question. I "play" in Access and have only created a few rather simple relational databases. My knowledge and experience is limited. I have no formal training, just picked up a few books and have gone from there... I'm not sure how to relate my question using the accepted shorthand, so I'm afraid this will be a narrative description. I am using Access 2003. The database is for property management. I have...
0
10325
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10148
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10091
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8972
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.