I am confused about how to go to a specific url after I click a button,
I made button that goes to a page containing a form (php file) so it will go to form.php
www.domain.com/form.php
Because there are many types of forms I want to make it simple and populate the page with another file. I remember that I learned something like this so I can call one php file into another file.
www.domain.com/form.php?package=standard
Is there any link or tutorial that I can follow to help me do this?
Thanks
put your button design to an a tag like this:
Im a button
clicking the button will now redirect you to the link. if you want to redirect in a new tab
put target="_blank" on your a tag like this:
Im a button
but if you want to retain the button tag, call the link using javascript or jquery.
Related
How can I use php to echo a page instead of linking to existing html page with hyperlink?
One example would be
<html>
<body>
click on this link to go back
</body>
</html>
Now, I don't want this link above to be a link to html page but to echo a page with php code when user clicks on click on this link to go back(to generate a page). This way, nobody can access a page after they logout.
Can php do this?
If someone logged out of your website or application I assume you will have a check whether or not this person is allowed to view the content.
Your question itself is very unclear to me. But it sound a bit if you want to do client-side coding (don't follow a link when it's clicked) with PHP which is not possible since PHP is a server side language. You will need Javascript to change the behavior of a link (for example, make an AJAX request which returns the content of another page).
Create a function, what the function should do is it should get triggered on a button click event and the code inside the function must send an curl request to the url you want and get back the html from it and echo it on your page
For answering the second part of your question!. you want no one to access the data without logging in so maintain $_SERVER['']; and sessions for users and validate if the user is inside a genuine session then show him content else no
I have a base php file that displays items in a database on an html table. Each row has a remove button. When pressed, it will remove that one item from the database. At the end of the table, there is an add button that once it is pressed will take you to another php file with a form that you can fill out with information to add to the database. I am having two problems. The first is that I am not sure how to determine what remove button is pushed. My second question is how do I move to a different page for the other php file once the add button is clicked? I am not supposed to use AJAX for this. And though I tried using include and isset, I couldn't get them to work properly. Any help, conceptual or code examples would be greatly appreciated.
If you can go to other pages, simply create a form with a hidden input field holding the id of the row and have the remove button be a form submit button.
On the remove button being clicked it will go to the delete php file and redirect back to the table page.
As far as the adding button, instead of using a button just use a link to the add form.
If any of this doesn't work because of requirements you haven't mentioned let me know of any restrictions you have.
For your first problem, just make a form for each individual row of data. that way, you will be able to pass by post the relevant id you want to remove.
Another way would be to create a "button" (not a submit button) and have the relevant onClick="..." script - like redirect to "index?Action=Remove&Id=xxxx"
By making different form for each button, you add button will have its own "action" in the form and you'll be allright!
You either have to generate a new "form" (with proper html) if you need to pass data to your next page. If you only need to redirect depending on which button you press, you can have a onClick="..." event on your button. Make sure not to make a "submit" button :)
i want a php code for automatically clicking on a Specified text or link on a page.
thanks
You want to use JavaScript code.
Just insert a script tag just before the closing body tag on the web page. It should look something like this:
<script>
document.getElementById("#my-link").click();
</script>
That will click the link with the HTML ID "my-link".
Note that generally this is not a good idea to implement. If you need to forward the user to another page, you can do that without simulating a mouse click - in PHP you can use the code
header("Location: redirectToHere.php");
and that will redirect the user automatically. If you need to change things on the page, you can do that by directly setting their properties with JavaScript.
I have seen a few of these floating about however I want to use it different to the way they posted on here.
I have all my server validation (for register page) at the top of the page so the form submit looks like (im on index.php so it just does it's self):
However, the index.php page has a login button and a register button and the form pops up depending which you click.
However i need that div to act like a page, so you submit and it reloads the div as if it were a web page if that makes sense?
Thanks for reading :-)
I am using a PHP foreach loop to list a series of links on a HTML page, which are rendered using jquery mobile. When one of the links is chosen, I want to be able to use the link label in PHP code to query a database and generate the header and other data for the destination page.
The problem is detecting which link was chosen. It seems that an "onclick" event would be involved, but that might mean using Javascript. I've seen an example of placing PHP inside a HTML form, but that relies on using a submit button to create a $_POST input. In my case, the link would be the only button involved in the event,so creating a separate Submit button would not make sense.
You can add query parameters to the links. (e.g. ?id=foo) and then pick them up in PHP via $_GET['id'].