Nir.L
Nir.L

Reputation: 97

html form with Php code not executing

I'm new to PHP. I have this html file with php in it:

<!DOCTYPE html>
<head>
     <meta charset="UTF-8">
    <title>Php torturail 1</title>
</head>
<body>
<p>php ahead:</p>

<?php
if (isset($_POST['submit'])){
    printf('User Name: %s', $_POST['name']);
        }
?>

<form method="post" action="">
    <p>name:</p>
    <input type="text" name="name">
    <p>pass:</p>
    <input type="password" name="pwd">
    <p>massage:</p>
    <textarea name="area"></textarea>
    <p>accept:</p>
    <input type="checkbox" name="chb" value="on">
    <p>lucky number:</p>
    <input type="radio" name="group1" value="option1">1
    <input type="radio" name="group1" value="option2">2
    <p>button:</p>
    <input type="submit" name="submit" value="submit">
</form>

</body>
</html>

When I open it on on a browser and click submit, the form's fileds are empty again but nothing is printed.

What is the problem?

Thank you.

Upvotes: 1

Views: 46

Answers (1)

user4486345
user4486345

Reputation:

2 things: 1-you must save your file as .php file. 2-fill action in your form tag

<form method="post" action="where.php">

Upvotes: 1

Related Questions