By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,269 Members | 1,561 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,269 IT Pros & Developers. It's quick & easy.

Can anyone tell me what wrong with this please!

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
what your html page passes as far as i can see the code is

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

Jul 17 '05 #3

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.