473,406 Members | 2,220 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,406 software developers and data experts.

Can anyone tell me what wrong with this please!

Hi,
I'm new to PHP. I followed an example on the book and wanted to pass a variable
from one html page to a php page, but it always tells me the passed variable is
undefined. I've checked the syntax over and over again, but I couldn't find the
problem. I also tried to change POST to SUBMIT and noticed the value of the
variable can be passed. Why can't the target php catch it??? The code is as
following, can any one please kindly help me out?
Very much appreciated!

----------------------HOME.htm----------------------------------------------------
<html >
<head>
<script language="JavaScript" type="text/javascript">
function book(show) {
if (!show.contains(event.toElement)) {
document.showList.where.value = show.name;
document.showList.submit();
}
}
</script>
</head>
<title>Home</title>
<body>
<form name="showList" method="POST" action="test.php">
<input type="hidden" name="where">
<input type="button" value="BOOK" name="LaBotieII" onClick="book(this)">
</body>
</html>
-------------------------------TEST.php----------------------------------------------
<html >
<head>
</head>
<title>TEST</title>
<body>
<?php
include("connection.php"); //connect to a database
connect();
echo($whichVenue); //error message "whichVenue is undefined"
$ven =whichVenue; //error message "whichVenue is undefined"
?>
</body></html>
Jul 17 '05 #1
4 1767
What's in your 'connection.php' file? Do you mind posting that without
the database information(i.e. username, password, etc.).

Ohdarn

Jul 17 '05 #2
what your html page passes as far as i can see the code is

$_POST['where'] = '' (empty)
$_POST['LaBotieII'] = 'BOOK'

Jul 17 '05 #3
I noticed that Message-ID: <d4***********@bunyip2.cc.uq.edu.au> from
Fang contained the following:
I'm new to PHP. I followed an example on the book

Please let us know which book is recommending solutions that rely on
Javascript to operate so that we can avoid it.

This may get you going:

----------------------HOME.htm----------------------------------------------------
<html >
<head>
<title>Home</title>
</head>

<body>
<form method="POST" action="test.php">
<select name='show'>
<option>Show 1</option>
<option>Show 2</option>
<option>Show 3</option>
<option>Show 4</option>
</select>
<input type="submit" value="submit" name="Book" >
</body>
</html>
-------------------------------TEST.php----------------------------------------------
<html >
<head>
<title>TEST</title>
</head>
<body>
<?php
if (isset($_POST['show'])){
echo "<p>You selected " .$_POST['show']."</p>";
}
?>
<a href="home.htm"> Book another?</a>
</body>
</html>

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #4
One quick glance of an experienced eye allowed to understand the blurred
and almost unreadable Fang's handwriting:
Hi,
I'm new to PHP. I followed an example on the book and wanted to pass a
variable from one html page to a php page, but it always tells me the
passed variable is undefined. I've checked the syntax over and over
again, but I couldn't find the problem. I also tried to change POST to
SUBMIT and noticed the value of the
variable can be passed. Why can't the target php catch it??? The code
is as following, can any one please kindly help me out?
Very much appreciated!

----------------------HOME.htm---------------------------------------------- <html >
<head>
<script language="JavaScript" type="text/javascript">
function book(show) {
if (!show.contains(event.toElement)) {
document.showList.where.value = show.name;
document.showList.submit();
}
}
</script>

</head>

<title>Home</title>
The <title></title> tag should be placed inside the <head></head>
section.
<body>
<form name="showList" method="POST" action="test.php">
<input type="hidden" name="where">
<input type="button" value="BOOK" name="LaBotieII"
onClick="book(this)">
Why don't you close the <form> tag?
</body>

</html>

-------------------------------TEST.php------------------------------------- <html >
<head>
</head>
<title>TEST</title>
<body>
<?php
include("connection.php"); //connect to a database
connect();
echo($whichVenue); //error message "whichVenue is undefined"
$ven=whichVenue; //error message "whichVenue is undefined"
You don't post any variable that is named whichVenue. You post a variable
named "where" (accessible through $_POST['where']) whith value
'LaBottieII" as far as I can see, and a variable named
'LaBottieII' ($_POST['LaBottieII']) whith value 'BOOK'. No more, no
less.
?>
</body></html>


Cheers
Mike
Jul 17 '05 #5

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

Similar topics

303
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b....
6
by: What-a-Tool | last post by:
I'm going out out of my mind trying to get this to work with no luck. The error message I get is at the bottom. Can someone please tell me what I'm doing wrong here. I've tried this a million...
2
by: pratchaya | last post by:
This is my sample error in my MySQL Log New value of fp=(nil) failed sanity check, terminating stack trace! Please read http://www.mysql.com/doc/en/Using_stack_trace.html and follow instructions...
7
by: Skc | last post by:
Hullo Just like to check whether anyone has tried RentACoder. I intend to farm out a small job that must use C#, WinForms, ADO.Net for around US$400, but don't know whether RentACoder is...
8
by: Brian Basquille | last post by:
Hello all, Bit of a change of pace now. As opposed to the typical questions regarding my Air Hockey game, am also working on a Photo Album which uses an Access Database to store information...
29
by: Roy Gourgi | last post by:
Hi, I am new to C#. I have the same time scheduling program written in C++ and it is 5 times faster than my version in C#. Why is it so slow as I thought that C# was only a little slower than...
2
by: venkatesh | last post by:
hai , i am using turboc++ compiler to run my c program. i written an program with structure sa foolws struct s { float x; }y; when i am accessing the variable x it shows the following error...
9
by: Coleen | last post by:
Hi All :-) I am desperately looking for some help/information on how to direct page flow. Forget what I have done - here's what I need to do: I have a large ASPX.Net - VB.Net web application...
1
by: maheshgupta0248 | last post by:
Hi everyone.. Im newbie in the driver development.. till now i have developed some drivers in Linux. Now I have to change to Windows.. can anyone tell me what are the real differences between driver...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
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
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...

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.