0

Hi friend.I m faraz here for the first time. I m new in PHP and doing some basics. I m writing small scripts. I have prolem with $_POST varivle. I wanna get name from the form and print it on the screen. But my script iz not working. Plz check it and help me that whats wrong with it. Thanx
Here is the form code:

<form action="action.php" method="POST">
  <table>
    <tr>
      <td>Name:</td>
      <td><input type="text" name="name" id="name"/></td>
    </tr>
   
    <tr>
      <td colspan="2" align="center">
        <input type="submit" name="Submitbtn" id="Submit_btn" value="Send">
      </td>
    </tr> 
  </table>
</form>

And here is the action script:

<?php echo $_POST['name']; ?>

.Thnax and waiting 4 ur help

5
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by Fbody
0

Friends I have checked again as you told me.But I m facing the same peoblem.
My code in all cases shows the same results. When I write something in the form and press submit or send. It shows my whole astion script on the screen. For example if I write this

<?php 
print_r($_POST);
?>

in the action.php file then this whole script appears on the screen.

0

$name=$_POST('name');
echo $name;

is the standard way, as you can get access to the $_POST array values and then process them eg trim leading/trailing spaces, addslashes, remove html, convert to a date, check for illegal characters, etc, etc from the variable you pass the value to. You shouldn't get into the habit of using $_POST values directly. It's dangerous.

PS name is a reserved word, so it is a bad idea to use it as a variable name - use something different eg fname for first name, theName for enire name or whatever you want. But not name="name".

Edited by drjohn: n/a

0

Since it's printing out your PHP scripts, rather than processing them, it sounds like the issue is with your installation of PHP itself. What are the exact filenames of your form and "action script"?

You may need to modify the configuration for your webserver so that it knows it needs to re-direct PHP files to the interpreter. Do you actually have PHP installed?

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.