473,624 Members | 2,290 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 9640
hh*******@yahoo .com (HH) wrote in
news:3d******** *************** ***@posting.goo gle.com:
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_global s 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.d k> 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_global s 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_arr ay($result))
{
print_entry($ro w,$preserve,"na me","location", "email","URL"," entry
date","comments ");
print "<tr><td colspan=2>$nbsp ;</td></tr>\n";
}

mysql_free_resu lt($result);
?>

</table>

<?php nav($offset);

include "end_page.p hp";
?>

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_sc ript)) {$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("sel ect count(*) from guestbook");
list($total_row s) = mysql_fetch_arr ay($result);

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

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_sc ript?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.d k> 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.ph p, 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.ph p
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_AUT H_USER))
{
// first time through - use authenticate() to request a
// user name & password
authenticate($r ealm,$errmsg,"h eader");
}
else
{
$query = "select username from guestbook_admin
where password = password(lower( '$PHP_AUTH_PW') )
and username = lower('$PHP_AUT H_USER')
";
$result = safe_query($que ry);
if ($result) { list($valid_use r) = 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_us er))
{
authenticate($r ealm,$errmsg,"q uery");
}
}
print "<p><b>Edit ing 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
7125
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 type=submit value=Submit name=submit1> </Form>
3
2902
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 to the web server, but regular button won't. I have a problem that needs to pass HTML elements data back and forth in several ASP pages. I am using regular button to do that. But what's the approaches?? Please advise. Thanks!
7
23648
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 the server since it's GET or POST request. But if just form-to-form communication, why we need to send the form to the server? Please help clarify. Thanks!! <form action="process.asp" method="get"> //form controls <input type="submit">
1
4303
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 eliminated the JavaScript errors I was seeing. The fact that the target URL didn't execute was because certain variables weren't being passed to it. What I need to do is to pass a conditional variable to the target URL, when the form is submitted,...
10
19341
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 able to fill that one out just fine. The second form is multipart/form-data. Unfortunately, I haven't been able to fill that out in a way that makes the server happy. I set up a copy of this form at my web site so that I could see exactly what a...
8
3015
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 shows the minutes and seconds remaining before submission. We have a fairly tight deadline (by 5PM EST, Friday, June 25); we are using a "bounty" in the hope of getting a few good responses in a hurry. BOUNTY: $200 for first place, plus a $50...
3
1916
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 they pressed. well i would like to change these submit buttons into text links instead. however they do not pass form parameters like the submit button. any simple ways to accomplish this? this is what i have so far:
11
10184
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 validation. The problem is.. how can I code the submit()s so the CGI's form collection knows which 'element' was clicked?? I am NOT permitted to use <input type=image...> or any "button" that browsers produce for forms.... the reasons are all client...
1
87440
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" action="RIRoleList.do?PageCount=<%= rptBean.getPageCount() %>">
0
8240
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
8625
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
8336
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
8482
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5565
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
4082
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
4177
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2610
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1487
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.