473,666 Members | 2,678 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>Li ght 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>Gua dalupe 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***********@i reland.nat lets go fishing Sunday, September 24th, 2006
(4:30 PM CDT) Dave Kelly da***********@i reland.nat Sunday, September
24th, 2006 (4:53 PM CDT) Jim Kloss da***********@i reland.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.fi v 1234483298374

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

-----+++++list-PINSS.txt_____l ist-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 6156
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>Li ght 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>Gua dalupe 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_global s 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***********@i reland.nat lets go fishing Sunday, September 24th, 2006
(4:30 PM CDT) Dave Kelly da***********@i reland.nat Sunday, September
24th, 2006 (4:53 PM CDT) Jim Kloss da***********@i reland.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.fi v 1234483298374

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

-----+++++list-PINSS.txt_____l ist-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*******@attgl obal.net
=============== ===
Sep 26 '06 #2

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

Similar topics

7
49570
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. The question is about best practices for passing parameters to an event function. I have, say, the following HTML:
26
45498
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 defined in "A.html", but every attempt results in an "is not a function" error. I have tried to invoke the function using parent.document.funcname(), top.document.funcname(), and various other identifying methods, but all result in the above...
7
2852
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 parameter to the XSLT stylesheet XsltArgumentList xsltArgList = new XsltArgumentList(); xsltArgList.AddParam("pmID", "", pmID); xmlItems.TransformArgumentList = xsltArgList;
2
4584
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 on the link and it would open a web page. The URL contained in the hyperlink would pass the name and address field
3
10831
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 which has to parameters passed to it from another Web page Parameter # 1 dbid and Parameter # 2 reportid. I know that I can access the values of the parameters from the code behind .aspx.cs using Request.QueryString so
13
2786
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
2243
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 successfully gotten it working. The only problem I have is with passing parameters to the Windows Forms User control from IE I am using the Object tag to instantiate the IE object I am using param tags inside object tag to pass paramaters but the...
3
2680
by: Marc Castrechini | last post by:
First off this is a great reference for passing data between the Data Access and Business Layers: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnanchor/html/Anch_EntDevAppArchPatPrac.asp I use my own classes in the Business layer. I want to keep the Data Access layer from requiring these classes so I tried passing a Datarow between the layers and it seems to work good for me. Constructing the datarow in the Class...
12
6892
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 Array Variable values are calculated in the function. Calling procedure receives the values preferably into variables of the same
4
4156
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 works real good. Since I don't need the aspx page to do any postback, is there a way to pass a parameter to it with out it finishing the round trip back to the htm page? Thanks. -- moondaddy@newsgroup.nospam
0
8438
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8779
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
8549
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
7376
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...
0
5660
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4186
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
4356
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2004
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1761
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.