1 is myName() and second one is yourName()
Code: Select all
function myName()
{
echo "my name is this.";
}
function yourName()
{
echo "your name is that.";
}Please help me. Thanks
Moderator: General Moderators
Code: Select all
function myName()
{
echo "my name is this.";
}
function yourName()
{
echo "your name is that.";
}Code: Select all
fucntion myName($name) {
$name = $_POST['name'];
echo $name;
}Code: Select all
<form method="post">
<input type="submit" name="submit" value="my">
<input type="submit" name="submit" value="you">
</form>
<?php
if(isset($_POST['submit'])) {
switch($_POST['submit']) {
case 'my':
myName();
break;
case 'you':
yourName();
break;
}
}
function myName()
{
echo "my name is this.";
}
function yourName()
{
echo "your name is that.";
}Separate in your mind the concepts of a form and a function. They are two unrelated parts of PHP. All a function does is return a value to somewhere else in the same script that calls the function. A form is the "wrapper" for a bunch of data input elements and when its submit button is clicked, it sends data to another script (or itself, if you put the right logic into it), so that it can recover the form data from either the $_POST or $_GET global array, as specified in the form tag. Don't get forms confused with functions.alicefreak wrote:Hello guys, I'm new to PHP. Please help me. I have two functions in myFunctions.php
1 is myName() and second one is yourName()and I have two submit button. One is my and another is you. When user click on my button. then myName() function is called and when user click on you then yourName() function is called.Code: Select all
function myName() { echo "my name is this."; } function yourName() { echo "your name is that."; }
Please help me. Thanks