473,396 Members | 1,767 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,396 software developers and data experts.

Submit won't pass parameters

HH
I'm learning to design web applications with php, mysql, and apache
from a book. I copied a sample application called guestbook 2000 that
came with the CD in the book to my htdocs folder, but couldn't get the
sign guestbook page (sign.php) to work. This page first checks the
value of the $submit variable. If it is not "Sign", the page displays
a blank form for the guest to sign. If it is "Sign", the page process
the form information and sends it to a database. Everytime I click the
submit button, the blank form reloads itself. Through testing, I found
out that the $submit variable was never set to "Sign" when I clicked
the button. I use IE on Windows 2000 server. Anyone who has any idea
how to fix this problem? Thanks!
Jul 17 '05 #1
6 9620
hh*******@yahoo.com (HH) wrote in
news:3d**************************@posting.google.c om:
I'm learning to design web applications with php, mysql, and apache
from a book. I copied a sample application called guestbook 2000 that
came with the CD in the book to my htdocs folder, but couldn't get the
sign guestbook page (sign.php) to work. This page first checks the
value of the $submit variable. If it is not "Sign", the page displays
a blank form for the guest to sign. If it is "Sign", the page process
the form information and sends it to a database. Everytime I click the
submit button, the blank form reloads itself. Through testing, I found
out that the $submit variable was never set to "Sign" when I clicked
the button. I use IE on Windows 2000 server. Anyone who has any idea
how to fix this problem? Thanks!


quickie since its so late and my eyes are losing focus, I assume you are
using POST to retrive the value. when you click the submit button, which
form object contains 'sign' as the value? otherwise, its hard to tell the
problem without seeing any code.
Jul 17 '05 #2
HH wrote:
I'm learning to design web applications with php, mysql, and apache
from a book. I copied a sample application called guestbook 2000 that
came with the CD in the book to my htdocs folder, but couldn't get the
sign guestbook page (sign.php) to work. This page first checks the
value of the $submit variable. If it is not "Sign", the page displays
a blank form for the guest to sign. If it is "Sign", the page process
the form information and sends it to a database. Everytime I click the
submit button, the blank form reloads itself. Through testing, I found
out that the $submit variable was never set to "Sign" when I clicked
the button. I use IE on Windows 2000 server. Anyone who has any idea
how to fix this problem? Thanks!


Probably because register_globals is set to off.

In that case you can either replace all the request variables with their
'superglobal' counterparts. (i.e. $_POST['submit'] instead of $submit),
or use import_request_variables("gp") in the beginning of the script.

About the superglobals:..
http://www.php.net/manual/en/languag...predefined.php

If it doesn't do the trick, them post the code.

/Bent
Jul 17 '05 #3
HH
Bent Stigsen <ng**@thevoid.dk> wrote in message news:<41***********************@dread15.news.tele. dk>...
HH wrote:
I'm learning to design web applications with php, mysql, and apache
from a book. I copied a sample application called guestbook 2000 that
came with the CD in the book to my htdocs folder, but couldn't get the
sign guestbook page (sign.php) to work. This page first checks the
value of the $submit variable. If it is not "Sign", the page displays
a blank form for the guest to sign. If it is "Sign", the page process
the form information and sends it to a database. Everytime I click the
submit button, the blank form reloads itself. Through testing, I found
out that the $submit variable was never set to "Sign" when I clicked
the button. I use IE on Windows 2000 server. Anyone who has any idea
how to fix this problem? Thanks!


Probably because register_globals is set to off.

In that case you can either replace all the request variables with their
'superglobal' counterparts. (i.e. $_POST['submit'] instead of $submit),
or use import_request_variables("gp") in the beginning of the script.

About the superglobals:..
http://www.php.net/manual/en/languag...predefined.php

If it doesn't do the trick, them post the code.

/Bent


Bent, thanks for the superglobal idea! The page sign.php finally
worked. But a new problem came

up with the view.php page. This page prints out 2 guestbook database
records at a time with

navigation buttons at the bottom to move back and forth from page to
page. I was able to load the

first two records. Then when I press the Next Entries link at the
bottom, the same first two

records load again. Through debugging, I noticed that although the url
in the address window

showed:
http://localhost/questbook2k/view.php?offset=2
the actual value of the variable offset, which was passed through the
link, is still 0. And I'm

not sure how to use superglobals here.

Here are the codes for view.php. Here, nav() is a function defined in
header.php, and the function's codes are listed below.

<?php
include "header.php";

$page_title = "View My Guest Book!!";
include "start_page.php";
?>

<table border=0>

<?php
if (empty($offset)) { $offset = 0; }

$preserve = "";

// select_entries() (declared in header.php) should return a mysql
// result set identifier

$result = select_entries($offset);
while ($row = mysql_fetch_array($result))
{
print_entry($row,$preserve,"name","location","emai l","URL","entry
date","comments");
print "<tr><td colspan=2>$nbsp;</td></tr>\n";
}

mysql_free_result($result);
?>

</table>

<?php nav($offset);

include "end_page.php";
?>

Here are the codes for function nav(). Variable $limit is set to 2 (2
records per page):

function nav($offset=0, $this_script="")
{
global $limit;
global $PHP_SELF;

if (empty($this_script)) {$this_script = $PHP_SELF;}
if (empty($offset)) { $offset = 0; }

// get the total number of entries in the guest book -
//we need this to know if we can go forward from where we are
$result = safe_query("select count(*) from guestbook");
list($total_rows) = mysql_fetch_array($result);

if ($offset > 0)
{
// if we're not on the first record, we can always go backwards
print "<a href=\"$this_script?offset=".($offset-$limit)."\">Previous

Entires</a>";
}
if ($offset+$limit < $total_rows)
{
// offset + limit gives us the maximum record number
// that we could have displayed on this page. If it's
// less than the total number of entries, that means
// there are more entries to see, and we can go forward
print "<a href=\"$this_script?offset=".($offset+$limit)."\"> Next
Entries</a>";
}
}
?>

I'm not sure how to use superglobals here. I tried to use
$_GET('offset') at a few places, but I kept getting error messages
when I display the page. Could you help? Thanks again!
HH
Jul 17 '05 #4
HH wrote:
[snip]
I'm not sure how to use superglobals here. I tried to use
$_GET('offset') at a few places, but I kept getting error messages
when I display the page. Could you help? Thanks again!


I assume you did use $_GET['offset'] and not $_GET('offset')

You can either use the "import_request_variables" function if you not
sure what other parameters might exist or use
$offset = $_GET['offset']; in the beginning the the scripts.

/Bent
Jul 17 '05 #5
HH
Bent Stigsen <ng**@thevoid.dk> wrote in message news:<41***********************@dread15.news.tele. dk>...
HH wrote:
[snip]
I'm not sure how to use superglobals here. I tried to use
$_GET('offset') at a few places, but I kept getting error messages
when I display the page. Could you help? Thanks again!


I assume you did use $_GET['offset'] and not $_GET('offset')

You can either use the "import_request_variables" function if you not
sure what other parameters might exist or use
$offset = $_GET['offset']; in the beginning the the scripts.

/Bent


It worked after I changed $_GET('offset') to $_GET['offset']. I'm
still new to php. Won't make that mistake again. Now I have trouble
with edit.php page, which when first clicked, it asks for a username
and password, and if validation is successful, I'll arrive at a page
that allows me to delete unwanted entries in the database. I'm pretty
sure I used the correct username and password. But it just won't let
me pass through. Below is authenticate.php, which is included at the
beginning of edit.php and responsible for the authentication part. I
even used globals here, but it gives me three times to try, and ends
with the display of $errmsg. Any ideas? Thanks so much for the help!
HH

<?php
/*
Application: Guestbook2K
Name: authenticate.php
Purpose: Validate user name and password against the database,
using HTTP authentication.

This code uses the authenticate() function, declared in
/book/functions/basic.php.

*/
// realm is the label that will appear in the pop-up window that
// asks for name and password.
// errmsg is the text that will be displayed if the user hits the
'Cancel'
// button in the pop-up
$realm = "Guest Book Administration";
$errmsg = "You must enter a valid name & password to access this
function";

// PHP_AUTH_USER and PHP_AUTH_PW are global variables supplied by
// PHP, corresponding to the user name & password the user has entered
// in the pop-up window created by an HTTP authentication header. If
no
// authentication header has ever been sent, these variables will be
empty.

$PHP_AUTH_USER = $GLOBALS['PHP_AUTH_USER'];
$PHP_AUTH_PW = $GLOBALS['PHP_AUTH_PW'];
if (empty($PHP_AUTH_USER))
{
// first time through - use authenticate() to request a
// user name & password
authenticate($realm,$errmsg,"header");
}
else
{
$query = "select username from guestbook_admin
where password = password(lower('$PHP_AUTH_PW'))
and username = lower('$PHP_AUTH_USER')
";
$result = safe_query($query);
if ($result) { list($valid_user) = mysql_fetch_row($result); }

// if the query didn't work at all (which shouldn't happen), or ran
but
// didn't find a match for the user name & password, $valid_user will
// not be set to anything. if this is so, have the user try again.
if (!$result || empty($valid_user))
{
authenticate($realm,$errmsg,"query");
}
}
print "<p><b>Editing as $PHP_AUTH_USER</b></p>\n";
?>
Jul 17 '05 #6
HH wrote:
[snip]
$PHP_AUTH_USER = $GLOBALS['PHP_AUTH_USER'];
$PHP_AUTH_PW = $GLOBALS['PHP_AUTH_PW'];


PHP_AUTH_USER and PHP_AUTH_PW would be defined in the $_SERVER variable,
so to access it through $GLOBALS you would have to write:
$GLOBALS['_SERVER']['PHP_AUTH_USER']

But it would be easier to write:

$PHP_AUTH_USER = $_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW = $_SERVER['PHP_AUTH_PW'];

/Bent
Jul 17 '05 #7

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

Similar topics

2
by: Jack | last post by:
Hi, I have a form with input fields and a submit button as following :(don't focus on mistypings if any) <FORM action=page.asp method=post> <Input id=text1 name=text1> <Input id=submit1...
3
by: Matt | last post by:
I want to understand the difference between submit button and regular button: <input type="submit"> and <input type="button">. My understanding is that submit button will send the entire HTML form...
7
by: Matt | last post by:
In ASP, when we pass data between pages, we usually pass by query string. If we pass data by query string, that means we need to use submit button, not by regular button, and the form will pass to...
1
by: Orest Kinasevych | last post by:
Okay, I made sense of the earlier suggestions and realized I was on the right track -- I appreciate the feedback which got me to this point. The suggestions posted here indeed worked and...
10
by: Gregory A Greenman | last post by:
I'm trying to write a program in vb.net to automate filling out a series of forms on a website. There are three forms I need to fill out in sequence. The first one is urlencoded. My program is...
8
by: Prometheus Research | last post by:
http://newyork.craigslist.org/eng/34043771.html We need a JavaScript component which will auto-submit a form after a set period has elapsed. The component must display a counter that dynamically...
3
by: M | last post by:
i am using submit buttons to send the user to different parts of a wizard. i am using if (if attribute.step1 exists) statements to send them to the appropriate section based on which submit button...
11
by: charlie_M | last post by:
I have a number of applications where I want to have many onclick='submit()' attached to different 'elements' on a single form ..... which sends the form to a CGI "script" which does all the...
1
by: eldokp | last post by:
hi, In my javaScript function iam using document.ReportListForm.submit(); for form submision My ReportListForm contains <form name="RoleListForm" method="Post"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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
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
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
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
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,...

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.