Reputation: 47
So I have been working on this project of a learning site.So there are teachers and students and different subjects. So I have separated the teacher and student registration page because they go in different tables in the database. I already have a landing page and when someone clicks to register as a teacher they will see a bunch of subjects that they can choose. So I need the code to call one of those buttons in the PHP code so I can redirect them on other pages.This is what the buttons look like:
<a href="technology_sign-up.php" class="tech-s-u" style="text-decoration:none; text-align: center; padding-left: 20px;">
<button style="cursor:pointer;border: none; background-color: dodgerblue; border-radius: 5px;"><h1 style="color: white; font-family: Patua One;">
Technology
</h1>
</button>
</a>
Basically i need to create a function and i need to call this button as a variable and then use it. If I should do it with AJAX please give more explanation because I don't understand AJAX that well. Excuse me for if my explain isn't completely understandable! I am new to PHP. Thank you!!
Upvotes: 0
Views: 109
Reputation: 1027
What is Ajax ?
Ajax is a way to make a request be a remote call or local file call. It happens asynchronously which means that the page does not refreshes while the data gets load.
For ex : Imagine a page in which there are 3 menu links home,aboutus,contact. Typically when you click on a link the page will refresh to load the content. By using AJAX you can load the content dynamically without reloading the page.
There are different ways to write ajax calls.
Ex :
function yourfunc() {
$.ajax ({
type:"post",
url: "yoururl",
data:data,
success:function(response) {
alert(response);
}
});
}
This is a jquery ajax example. You can check this link Ajax tutorial
HTML :
<button onclick="yourfunc()">Click</button>
Upvotes: 1