Click here to Skip to main content
15,902,112 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello i want to make a small code . I started but i cant finish . I made a input in html and 1 button in html too .
I want to make php code if button clicked and input equals admin , echo "You Are Admin" for example how can i do this

What I have tried:

Try
<?php
if($_GET['button1']){tryy();}

function tryy()
{

if($text == "admin") {
echo "You Are Admin";
}
}


?>
Posted
Updated 25-Jun-18 15:10pm
v2

1 solution

Your question does not make any sense at all. Any way. Try this
# index.html
# taken from w3school.
<!DOCTYPE html>
<html>
<body>

<h2>HTML Forms</h2>

<form action="/action_page.php">
  First name:<br>
  <input type="text" name="firstname" value="Mickey">
  <br>
  Last name:<br>
  <input type="text" name="lastname" value="Mouse">
  <br><br>
  <input type="submit" value="Submit">
</form> 

<p>If you click the "Submit" button, the form-data will be sent to a page called "/action_page.php".</p>

</body>
</html>


# action_page.php
<?php
$msg="";
if (isset($_GET['submit'])==true) {
  $firstname=isset($_GET['firstname'])?$_GET['firstname']:"";
  $lastname=isset($_GET['lastname'])?$_GET['lastname']:"";
  $msg="firstname=".$firstname."&amp;lastname=".$lastname."&nbsp;";
} else {
  $msg="Invalid requeset";
}
?><!DOCTYPE html>
<html>
<head>
  <title>Forms action page</title>
</head>
<body>
  <h1>Submitted Form Data</h1>
  <h2>Your input was received as:</h2>
<div style="word-wrap:break-word"><?=$msg?>
</div>
</div>
</body>
</html>


How data submit works in php
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900