473,508 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing parameters from HTML to PHP

I'm posting on this again. Sorry I am so thick heading but I do not
understand why this failure.

I have put in some 'printf' statements for debugging and some comments.
And some questions.

From the menu.html page

<html>
<a href="guestbook.php?var1=list-PINSS.txt"><h3>Padre Island National
Sea Shore</h3></a><br>
<a href="guestbook.php?var1=list-LHL.txt"><h3>Light House
Lakes</h3></a><br>
<a href="guestbook.php?var1=list-7LD.txt"><h3>7 Lakes Damon</h3></a><br>
<a href="guestbook.php?var1=list-GR.txt"><h3>Guadalupe River</h3></a><br>
</html>

To the PHP file
<?php

include $_GET['var1']; //prints to screen the correct information
$file=$_GET['var1'];

printf("-----%s", $var1); // prints nothing.
printf("+++++%s", $file); // prints to the screen the correct information.

error_reporting(1);
$mode=$_GET['mode'];
if($mode!='view' && $mode!='sign') $mode=$_POST['mode'];
if($mode!='view' && $mode!='sign') $mode='sign';
$name=$_POST['name'];
$site=$_POST['site'];
$phone=$_POST['phone'];
$date=date('l, F dS, Y (g:i A T)');
$self=$_SERVER['PHP_SELF'];
printf(;// prints to the screen the correct information.
($handle=fopen($file,'a+') or die("Could not open file: $file"));// FAILS
....................
....................
?>

This is the way it appears on the screen....
Sunday, September 24th, 2006 (4:10 PM CDT) Dafydd Cealleigh
da***********@ireland.nat lets go fishing Sunday, September 24th, 2006
(4:30 PM CDT) Dave Kelly da***********@ireland.nat Sunday, September
24th, 2006 (4:53 PM CDT) Jim Kloss da***********@ireland.nat Sunday,
September 24th, 2006 (5:01 PM CDT) Wilson Harmon wi**@harmon.cum 936 894
1710 Sunday, September 24th, 2006 (5:11 PM CDT) Alfred E Newman
49****@vista.fiv 1234483298374

Notice: Undefined variable: var1 in
/var/www/vhosts/texasflyfishers.org/httpdocs/guestbook.php on line 22

-----+++++list-PINSS.txt_____list-PINSS.txt_____

Why does $file contain 'list-PINSS.txt' in printf ("_____%s_____",
$file) and 'var1' in ($handle=fopen($file,'a+')?
Sep 26 '06 #1
1 6142
Dave Kelly wrote:
I'm posting on this again. Sorry I am so thick heading but I do not
understand why this failure.

I have put in some 'printf' statements for debugging and some comments.
And some questions.

From the menu.html page

<html>
<a href="guestbook.php?var1=list-PINSS.txt"><h3>Padre Island National
Sea Shore</h3></a><br>
<a href="guestbook.php?var1=list-LHL.txt"><h3>Light House
Lakes</h3></a><br>
<a href="guestbook.php?var1=list-7LD.txt"><h3>7 Lakes Damon</h3></a><br>
<a href="guestbook.php?var1=list-GR.txt"><h3>Guadalupe River</h3></a><br>
</html>

To the PHP file
<?php

include $_GET['var1']; //prints to screen the correct information
What are you printing? Does the included file do it?
$file=$_GET['var1'];

printf("-----%s", $var1); // prints nothing.
That's because $var1 isn't defined. Perhaps you're using an old text or
code that ran with register_globals enabled. That's a security hole,
and the default now is to have it turned off (as it should be).

Use

printf("-----%s", $_GET['var1']);

instead, as you had it in the include statement.
Or,

$var1 = $_GET['var1'];

and your current printf will work.

printf("+++++%s", $file); // prints to the screen the correct information.

error_reporting(1);
$mode=$_GET['mode'];
if($mode!='view' && $mode!='sign') $mode=$_POST['mode'];
Which method is your form using - GET or POST? One or the other.
if($mode!='view' && $mode!='sign') $mode='sign';
$name=$_POST['name'];
$site=$_POST['site'];
$phone=$_POST['phone'];
$date=date('l, F dS, Y (g:i A T)');
$self=$_SERVER['PHP_SELF'];
printf(;// prints to the screen the correct information.
($handle=fopen($file,'a+') or die("Could not open file: $file"));// FAILS
...................
...................
?>

This is the way it appears on the screen....
Sunday, September 24th, 2006 (4:10 PM CDT) Dafydd Cealleigh
da***********@ireland.nat lets go fishing Sunday, September 24th, 2006
(4:30 PM CDT) Dave Kelly da***********@ireland.nat Sunday, September
24th, 2006 (4:53 PM CDT) Jim Kloss da***********@ireland.nat Sunday,
September 24th, 2006 (5:01 PM CDT) Wilson Harmon wi**@harmon.cum 936 894
1710 Sunday, September 24th, 2006 (5:11 PM CDT) Alfred E Newman
49****@vista.fiv 1234483298374

Notice: Undefined variable: var1 in
/var/www/vhosts/texasflyfishers.org/httpdocs/guestbook.php on line 22

-----+++++list-PINSS.txt_____list-PINSS.txt_____

Why does $file contain 'list-PINSS.txt' in printf ("_____%s_____",
$file) and 'var1' in ($handle=fopen($file,'a+')?
It doesn't. That's an error message due to the uninitialized variable.

Looks like your logic is just a little messed up here.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 26 '06 #2

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

Similar topics

7
49556
by: Pavils Jurjans | last post by:
Hallo, I have been programming for restricted environments where Internet Explorer is a standard, so I haven't stumbled upon this problem until now, when I need to write a DOM-compatible code. ...
26
45471
by: Dave Hammond | last post by:
In document "A.html" I have defined a function and within the document body have included an IFRAME element who's source is document "B.html". In document "B.html" I am trying to call the function...
7
2828
by: Harolds | last post by:
The code below worked in VS 2003 & dotnet framework 1.1 but now in VS 2005 the pmID is evaluated to "" instead of what the value is set to: .... xmlItems.Document = pmXML // Add the pmID...
2
4571
by: Gordon Hudson | last post by:
Hello Here is what I am trying to do: Make a hyperlink on a data entry form with its URL built from the values for fields in that entry on the database. So, I would go to record 65785 click...
3
10813
by: Joe Bloggs | last post by:
Does anyone know if its possible to pass parameters or the values of Request.QueryString from a web page to a custom control class? I'm using a C# Web Application. For Example I have Web Page1...
13
2749
by: Maxim | last post by:
Hi! A have a string variable (which is a reference type). Now I define my Method like that: void MakeFullName(string sNamePrivate) { sNamePrivate+="Gates" }
0
2235
by: Neelima Godugu | last post by:
Hi All, I have developed a windows forms user control, which I am going to host in Internet Explorer.. I am familiar with the security settings requirement inorder to do the above. I have...
3
2670
by: Marc Castrechini | last post by:
First off this is a great reference for passing data between the Data Access and Business Layers:...
12
6872
by: Dennis D. | last post by:
Hello: I want a function to return three variables to the calling procedure: Private Function CalcTimes(ByVal iAddDays as Integer, ByVal iAddHours as Integer, ByVal iAddMins as Integer) As...
4
4149
by: moondaddy | last post by:
I have a htm page where I need to pass some data to an aspx page as a means of sending data to the database. I don't need to see the aspx page so I was going to put it in a hidden iframe. This...
0
7227
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7331
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,...
1
7054
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...
0
7501
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...
0
5633
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,...
0
4713
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3204
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...
0
3188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
768
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.