472,096 Members | 1,360 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,096 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 1681
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

303 posts views Thread by mike420 | last post: by
2 posts views Thread by pratchaya | last post: by
7 posts views Thread by Skc | last post: by
8 posts views Thread by Brian Basquille | last post: by
2 posts views Thread by venkatesh | last post: by

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.