Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HOW TO run a PHP script by clicking on a link 1

Status
Not open for further replies.

svar

Programmer
Aug 12, 2001
349
GR
Ok, I posted this in the wrong way before.
The point is I'm new to PHP and was not able to
find this in the PHP documentation. So, I would appreciate
if one could give an example of code where basically
one clicks on a link and php does something
like send an email for instance, or just print 'hi'
. Alternatively, thee may be a faq(not at tek-tips from
what I see) or documentation on how to do this

A further question: I am doing some testing on examples
I am writing on my PC. I have PHP4.2 I think
-but no server(e.g. Apache), so it is normal that I do not see
the correct html code produced, right?

thanks, svar
 
Code:
<a href=[URL unfurl="true"]http://someplace.com/myscript.php?item=hello</a>[/URL]



an myscript.php contains
<?php
echo &quot;Item is $_GET[item]&quot;;
?>

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Thanks. Now if the myscript.php is at the server, thsi should read <a href=
or (localhost instead of 127.0.0.1 dependeing on what httpd.conf says, right?


To be more specific, consider the following:
<HTML>
<HEAD>
<TITLE>:: TEST ::</TITLE>
</HEAD>
<B>Some bullets</B>
<ul>
<li type=square><a href= action A<\a>
<li type=square><a href= action B<\a>
</BODY>
</HTML>

(This does not appear to work and I'm trying to figure out why)

Thanks, svar
 
is your server configured to parse PHP ? what happens if you give it a simple php info page?

phpinfo.php
<?
phpinfo();
?>

you should get a very nice page returned giving you lots of useful info...

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Thanks, but no. The situation is like this: I do not have
a web server working, but I do have php installed.
(php -v works).
The point is I want to write some php code that will be
run on a web server, but right now I do not have a web server to run. This is why I am asking all these questions,
basically I want to have the script close to ready by the time they can be deployed on the server, which should be very soon

So, coming back to the original question, am I doing something wrong or should
something like
<li type=square><a href= action A'<\a>
<li type=square><a href= action B'<\a>
work?

thanks, svar
 
A few things...

Without a http server, you cannot get past the in your URLs

You should also be aware of URL strings. Your example would not work because there are spaces in it.

If you are capable of installing PHP, you can just as easily install a web server on your development box. It does not even need to be connected to the internet: just use it for your own development.

Your HTML is also spotty. Where is the opening body tag?

- - picklefish - -
Why is everyone in this forum responding to me as picklefish?
 
it's perhaps also nice if you're link has a title

Code:
<a href=[URL unfurl="true"]http://127.0.01./myscript.php?item='Do[/URL] action A'>action a</a>
<a href=[URL unfurl="true"]http://127.0.01./myscript.php?item='Do[/URL] action b'>action b</a>
 
Thanks again guys, sure I'll install a web server then
a couple of things though:
1) first, 127.0.01. in my previous posts should have read
127.0.0.1
But with that change is this how one would implement
a clickable link to call php to actually do something?

2) second, jimoblak, what do you mean by spaces in the URL?
I guess I'm missing this cause I don't see them

thanks again, svar
 
I'm assuming that you are just using this as an example but even examples should be free of questionable stuff...

Code:
<a href=[URL unfurl="true"]http://127.0.0.1/myscript.php?item=[/URL][b]'Do action b'[/b]>

Should be...

Code:
<a href=&quot;[URL unfurl="true"]http://127.0.0.1/myscript.php?item=[/URL][b]Do_action_b[/b]&quot;>



- - picklefish - -
Why is everyone in this forum responding to me as picklefish?
 
Yes, you're right, thanks again. If it isn't too obvious,
I am new to PHP and in fact web stuff, so I need to
catch up fast, so let me play with this for a while.
Thanks again,
svar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top