Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a form, and I'm checking to see if it's submitting properly to post. This is my first foray into POST, so other than rudimentary research and tutorial stuff, I'm having a lot of problems. I wrote a simple script to see if my form is working properly at all. The HTML is clipped to only show you the form; I do have a validation and all that.

There is no naming conflict, whether in the filenames or those of the variables, so I assume it's a syntax error or just me being that guy with no knowledge of post whatsoever.

Here's the HTML:

<html>
 <body>
  <form name="Involved" method="post" action="postest.php" target="_blank">
   Name: <br><input type="text" name="name" title="Your full name" style="color:#000" placeholder="Enter full name"/>
   <br><br>
   Email: <br><input type="text" name="email" title="Your email address" style="color:#000" placeholder="Enter email address"/>
   <br><br>
   How you can help: <br><textarea cols="18" rows="3" name="help" title="Service you want to provide" style="color:#000" placeholder="Please let us know of any ways you may be of assistance"></textarea>
   <br><br>
   <input type="submit" value="Submit" id=submitbox"/>
  </form>
 </body>
<html>

Here's the post (named postest):

<?php
    $name   =   $_POSTEST['name'];
    $email  =   $_POSTEST['email'];
    $help   =   $_POSTEST['help'];

    echo {$name}, {$email}, {$help};
?>

This post was derived from this tutorial.

Also, I might as well ask: How would I go about submitting information to be (semi)permanently stored on a spreadsheet for my later perusal? However, this is a secondary question.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
146 views
Welcome To Ask or Share your Answers For Others

1 Answer

Part of your problem is that you are using a variable you're calling $_POSTEST when really what you want is the $_POST array. $_POST is a special reserved variable in PHP (and needs to be referenced using that exact syntax) which is:

An associative array of variables passed to the current script via the HTTP POST method.

Reference: PHP Manual - http://php.net/manual/en/reserved.variables.post.php

So whatever input names and values you're passing into the PHP script come in via HTTP POST, and they'll be located in the $_POST array.

So using your example, it would be:

<?php
    $name   =   $_POST['name'];
    $email  =   $_POST['email'];
    $help   =   $_POST['help'];

    echo {$name}, {$email}, {$help};
?>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...