[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Call php inside same page

Posted on 2009-02-16
4
Medium Priority
?
1,122 Views
Last Modified: 2012-05-06
When  a user clicks on  a <a></a> link, I want to call some PHP code.  The best way I know now to do that is create another php page and run the code that way.  Is there a way to run the script inside the page so that I do not have to create another php file?  Having a bunch of files can cause clutter and all and I hate that haha.

Thanks guys.
0
Comment
Question by:tuckeroil
  • 2
  • 2
4 Comments
 
LVL 28

Accepted Solution

by:
gamebits earned 1600 total points
ID: 23652709
You can, your link will have to point to the same page where thay are and you append a variable to the link, on the page you check if the variable has been set or net.

<a href="mydomain.com/index.php?m=55">Go to m55</a>

<?php
if(isset($_REQUEST['m'])){
                                         show the m5
                                        }else{
                                                   show the link
                                                 }
0
 

Author Comment

by:tuckeroil
ID: 23653225
Thanks that worked for what I was doing, but I have a follow up question.

What if you want to submit information from a form, such as a file or a text field, how would you accomplish using the same php file?  Use the $_POST variable?

Thanks  
0
 
LVL 28

Assisted Solution

by:gamebits
gamebits earned 1600 total points
ID: 23653332
That's why I used $_REQUEST it will work with both a link or a form's post

link -> $_GET
form -> $_POST or $_GET depending of the method used in the form tag

$_REQUEST work with both $_GET or $_POST
0
 

Author Closing Comment

by:tuckeroil
ID: 31547453
Thanks for the help
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month19 days, 14 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question