Wrox Programmer Forums
|
BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5
This is the forum to discuss the Wrox book Beginning PHP4 by Wankyu Choi, Allan Kent, Chris Lea, Ganesh Prasad, Chris Ullman; ISBN: 9780764543647
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 18th, 2003, 01:14 AM
Authorized User
 
Join Date: Oct 2003
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to phpsharma Send a message via Yahoo to phpsharma
Default How can we submit a form without a submit butto

with out using submit <input type="submit">
how to in php?

www.sharma.5u.com

God Knows better than US
__________________
God Knows better than US
 
Old October 18th, 2003, 01:36 AM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

phpsharma,
If you don't want to use a submit button then you would use javascript or an alternate syntax for the input button. PHP wouldn't have anything to do with that side of it.

<input type='submit' value='Click Here' name='var' />
<input type='image' src='images/submit.jpg' value='Submit' alt='Submit' name='var' />

What you will get, because it's an image,

var.x = (x coordinates where user clicked)
var.y = (y coordinates where user clicked)

I did some testing on this and I can't seem to retrieve the values in PHP.

I used the following:

if (isset($_POST["var.x"])) echo $_POST["var.x"];
if (isset($_POST["var.y"])) echo $_POST["var.y"];

or even with the $_GET method if the form is set to submit via get, the query string shows up but I am not able to get the values to output from a script.

if (isset($_GET["var.x"])) echo $_GET["var.x"];
if (isset($_GET["var.y"])) echo $_GET["var.y"];

However despite this I was able to access other data set from other input elements. I'll have to do some researching on this to see how you access the data passed by the button itself.

??

If you don't want to use an image but want to use some other method, like fire form submission when a user selects something from a drop down list you would do that with JavaScript and would be a question better suited for that forum.

: )
Rich


:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::
 
Old October 18th, 2003, 01:44 AM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Ok problem solved,

In PHP if you use an image input type... like so...
<input type='image' src='images/submit.jpg' value='Submit' alt='Submit' name='var' />

And submitted via the post method..
The coordinates are accessible as follows:

if (isset($_POST["var_x"])) echo $_POST["var_x"];
if (isset($_POST["var_y"])) echo $_POST["var_y"];

Where the 'var' part of the indice is the name of the field, the underscore replaces the dot and 'x', 'y' are the coordinates.

So var.x becomes var_x in PHP.

: )
Rich

:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::
 
Old October 18th, 2003, 08:29 AM
Authorized User
 
Join Date: Oct 2003
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to phpsharma Send a message via Yahoo to phpsharma
Default

thank you quesadilla5


God Knows better than US
 
Old October 20th, 2003, 08:50 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The javascript required to submit a form is simple:

formname.submit();

where formname is the value of the name attribute of your form tag.

Play with this toy script to get the idea.

<form name="myform" method="get" action="<?php echo $_SERVER['PHP_SELF'];?>">
  <input type="text" name="username" />
</form>

<a href="javascript:myform.submit();">Submit this form!</a>

<pre>
<?php
if (isset($_GET)) print_r($_GET);
?>
</pre>


Take care,

Nik
http://www.bigaction.org/





Similar Threads
Thread Thread Starter Forum Replies Last Post
Form submit into Excel raversunite Infopath 0 August 1st, 2007 05:43 AM
How to submit the different data on single submit pushpa Classic ASP Databases 1 January 24th, 2007 07:10 PM
One form.. two submit buttons ashraf_gawdat HTML Code Clinic 1 July 28th, 2006 06:56 PM
Form Submit Nitin_sharma Javascript 1 December 2nd, 2004 08:51 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.