How Can I 'run' a php file without showing it?

This is a discussion on How Can I 'run' a php file without showing it? within the alt.comp.lang.php forums, part of the PHP Programming Forums category; I have the folllowing problem: In a html page I show several 'buttons'. This buttons have a onclick="Agregar([...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-27-2005
Ing. David Méndez
 
Posts: n/a
Default How Can I 'run' a php file without showing it?

I have the folllowing problem:

In a html page I show several 'buttons'. This buttons have a
onclick="Agregar([a number])". The 'Agregar(number)' function calls a php
file. This php file UPDATES a row in a MYSQL database using the number. Up
to here is OK.

I don't want to show the: "?m=number" (in the URL, when I call the pHP file)

or best... That the PHP files runs transparentely.
or at least with a POST method to send the parameters (number)

The code I have is somethig like:

<script language="JavaScript">
<!--
function Agregar(matnum) {
window.location.href="member.php?m=" + matnum;
}
// -->
</script>

....

<input type="button" value="agregar" onclick="Agregar(2011310)"
class=button>
<input type="button" value="agregar" onclick="Agregar(2011410)"
class=button>
<input type="button" value="agregar" onclick="Agregar(2012010)"
class=button>
<input type="button" value="agregar" onclick="Agregar(2012110)"
class=button>
<input type="button" value="agregar" onclick="Agregar(2015510)"
class=button>
<input type="button" value="agregar" onclick="Agregar(2015530)"
class=button>
<input type="button" value="agregar" onclick="Agregar(2015610)"
class=button>


Thank you.

David.


Reply With Quote
  #2 (permalink)  
Old 05-27-2005
Janwillem Borleffs
 
Posts: n/a
Default Re: How Can I 'run' a php file without showing it?

Ing. David Méndez wrote:
> I have the folllowing problem:
>
> In a html page I show several 'buttons'. This buttons have a
> onclick="Agregar([a number])". The 'Agregar(number)' function calls a
> php file. This php file UPDATES a row in a MYSQL database using the
> number. Up to here is OK.
>
> I don't want to show the: "?m=number" (in the URL, when I call the
> pHP file)
>
> or best... That the PHP files runs transparentely.
> or at least with a POST method to send the parameters (number)
>


Use an iframe to call the PHP file, which can reload the parent page with
javascript when finished. Note that for this to work, both files should run
on the same domain.


JW



Reply With Quote
  #3 (permalink)  
Old 05-27-2005
Randy Webb
 
Posts: n/a
Default Re: How Can I 'run' a php file without showing it?

Ing. David Méndez wrote:

> I have the folllowing problem:
>
> In a html page I show several 'buttons'. This buttons have a
> onclick="Agregar([a number])". The 'Agregar(number)' function calls a php
> file. This php file UPDATES a row in a MYSQL database using the number. Up
> to here is OK.
>
> I don't want to show the: "?m=number" (in the URL, when I call the pHP file)
>
> or best... That the PHP files runs transparentely.
> or at least with a POST method to send the parameters (number)
>
> The code I have is somethig like:
>
> <script language="JavaScript">
> <!--
> function Agregar(matnum) {
> window.location.href="member.php?m=" + matnum;


document.images['someImage'].src="phpFile.php?m=" + matnum;

> }


<img name="someImage" src="phpFile.php" width="1" height="1">

Then, the URL is never seen (to most anyway).

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Reply With Quote
  #4 (permalink)  
Old 05-28-2005
Kimmo Laine
 
Posts: n/a
Default Re: How Can I 'run' a php file without showing it?

"Ing. David Méndez" <davigre@hotmail.com> kirjoitti
viestissä:4297262b_2@x-privat.org...
>I have the folllowing problem:
>
> In a html page I show several 'buttons'. This buttons have a
> onclick="Agregar([a number])". The 'Agregar(number)' function calls a php
> file. This php file UPDATES a row in a MYSQL database using the number. Up
> to here is OK.
>
> I don't want to show the: "?m=number" (in the URL, when I call the pHP
> file)
>
> or best... That the PHP files runs transparentely.
> or at least with a POST method to send the parameters (number)
>
> The code I have is somethig like:
>
> <script language="JavaScript">
> <!--
> function Agregar(matnum) {
> window.location.href="member.php?m=" + matnum;
> }
> // -->
> </script>
>
> ...
>
> <input type="button" value="agregar" onclick="Agregar(2011310)"
> class=button>
> <input type="button" value="agregar" onclick="Agregar(2011410)"
> class=button>
> <input type="button" value="agregar" onclick="Agregar(2012010)"
> class=button>
> <input type="button" value="agregar" onclick="Agregar(2012110)"
> class=button>
> <input type="button" value="agregar" onclick="Agregar(2015510)"
> class=button>
> <input type="button" value="agregar" onclick="Agregar(2015530)"
> class=button>
> <input type="button" value="agregar" onclick="Agregar(2015610)"
> class=button>
>
>


Why don't you just submit using POST method?

<form action='member.php'>
<input type="submit" value="agregar" name="Agregar[2015530]" class=button>
<input type="submit" value="agregar" name="Agregar[2015610]" class=button>
</form>

In the form handler member.php you just get the clicked button

$m = current(keys($_REQUEST['Agregar']));

// Result: $m contains either 2015530 or 2015610 depending on which button
was clicked.
// Now just add those n+1 buttons you had there....

If you were wondering: in a form that has multiple submit buttons, only the
one that is clicked is submitted, so it's a good way to do this. So in this
case, nothing but the button that was clicked is sent. And in the form
handler we just recieve the array index of it.
--
"I am pro death penalty. That way people learn
their lesson for the next time." -- Britney Spears

eternal.erectionN0@5P4Mgmail.com


Reply With Quote
  #5 (permalink)  
Old 05-29-2005
David Méndez
 
Posts: n/a
Default Re: How Can I 'run' a php file without showing it?

Thank You all !!

I think Kimmo Laine solution is what I was expecting, a POST method
Solution.

bye.
David.

"Ing. David Méndez" <davigre@hotmail.com> wrote in message
news:4297262b_2@x-privat.org...
> I have the folllowing problem:
>
> In a html page I show several 'buttons'. This buttons have a
> onclick="Agregar([a number])". The 'Agregar(number)' function calls a php
> file. This php file UPDATES a row in a MYSQL database using the number. Up
> to here is OK.
>
> I don't want to show the: "?m=number" (in the URL, when I call the pHP

file)
>
> or best... That the PHP files runs transparentely.
> or at least with a POST method to send the parameters (number)
>
> The code I have is somethig like:
>
> <script language="JavaScript">
> <!--
> function Agregar(matnum) {
> window.location.href="member.php?m=" + matnum;
> }
> // -->
> </script>
>
> ...
>
> <input type="button" value="agregar" onclick="Agregar(2011310)"
> class=button>
> <input type="button" value="agregar" onclick="Agregar(2011410)"
> class=button>
> <input type="button" value="agregar" onclick="Agregar(2012010)"
> class=button>
> <input type="button" value="agregar" onclick="Agregar(2012110)"
> class=button>
> <input type="button" value="agregar" onclick="Agregar(2015510)"
> class=button>
> <input type="button" value="agregar" onclick="Agregar(2015530)"
> class=button>
> <input type="button" value="agregar" onclick="Agregar(2015610)"
> class=button>
>
>
> Thank you.
>
> David.
>
>



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:37 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0