473,385 Members | 2,243 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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><TD align=center>

<FORM METHOD=\"POST\" ACTION=\"$PHP_SELF\">
<span class=\"textmessage\">
<strong>Send To:</strong><br>
<SELECT NAME=\"name_select\" class=\"textbox\">
<option value=\"1111111111 at messaging.nextel.com\">Greg </option>
<option value=\"1111111111 at messaging.nextel.com\">John</option>
<option value=\"1111111111 at messaging.nextel.com\">Fred</option>
</select>

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

<TEXTAREA NAME=\"limitedtextarea\" class=\"textbox\" cols=15
onKeyDown=\"limitText(this.form.limitedtextarea,th is.form.countdown,100);\"
onKeyUp=\"limitText(this.form.limitedtextarea,this .form.countdown,100);\"

</TEXTAREA>
<span class=\"smallfont\">(Max Characters: 100)<br>
You have <input class=\"textbox\" readonly type=\"text\"
name=\"countdown\" size=1 value=\"100\">characters 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_block";

} else if ($_POST['op'] == "ds") {
//check value of $_POST[sender_name]
if ($_POST['sender_name'] == "") {
$name_err = "<font color=red>Please enter your
name!</font><br>";
$send = "no";
}
//check value of $_POST[limitedtextarea]
if ($_POST['limitedtextarea'] == "") {
$message_err = "<font color=red>Please 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_err";
echo "$form_block";
}
}

?>
Jul 17 '05 #1
8 6544
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><TD align=center>

<FORM METHOD=\"POST\" ACTION=\"$PHP_SELF\">
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_globals set to
on in php.ini - which is NOT a good idea.
However, IF you have register_globals 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_remove_this.co.uk> wrote in
message news:d4**********@213-238-75-8.adsl.inetia.pl...
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><TD align=center>

<FORM METHOD=\"POST\" ACTION=\"$PHP_SELF\">


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_globals set to
on in php.ini - which is NOT a good idea.
However, IF you have register_globals 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\wwwroot\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******************@telecomputeronline.com> wrote in
message news:3d*****************************@40tude.net...
*** 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\wwwroot\new\sidebar.php on line 72
Yes, because you forgot about the \"'s :)
<FORM METHOD=\"POST\"> ACTION=\"{$_SERVER['$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_remove_this.co.uk> wrote in
message news:d4**********@213-238-75-8.adsl.inetia.pl...
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\wwwroot\new\sidebar.php on line 72


Yes, because you forgot about the \"'s :)
<FORM METHOD=\"POST\"> ACTION=\"{$_SERVER['$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
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...
4
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...
3
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...
25
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...
4
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. ...
3
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...
2
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
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...
2
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...

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.