HI i am beginner in PHP and really need some help

<title>My Variables HTML Form</title> 
<h4>My HTML Form</h4> 
function display()
	echo "you called display function";

function profile()
	echo "you called Profile function";

<form action="<?= $php_SELF ?>" method="POST">

        <input type="button" name="action" value="submitted" onClick="<? display() ?>" />
    <input type="button" name="submit" value="submit me!" onClick="<? profile() ?>" />



it could not work at all. what i want is to call the function according to what i have clicked.
how to solve my problem?


10 Years
Discussion Span
Last Post by johny_d


You have to check which button is closed :

      if(isset($_POST['action'])) { display(); }

      if (isset($_POST['submit'])) { profile(); }


- Mitko Kostov


MitkOK is right with his code; but you have bigger problems before that:
- first of all, don't mix javascript function calls with php defined functions; get rid of those onClick="<? ....; those are javascript functions calls, but the functions you defined are php
- second: avoid using short open php tags (<?); use instead the long ones (<?php) that work on every server configuration;
Your code might work just fine without any correction (just with MitkOK addon code), but if you try to learn something here, than you should take the above into account.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.