Post error value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Redapple
    New Member
    • Mar 2007
    • 5

    Post error value

    Hello everybody

    I have a script that looks like this:

    [PHP]
    <?php

    if (isset($_POST['name'])) {
    echo "$_POST[name]";
    }
    else
    {
    echo "Here the form with the insert name and submit";
    }

    ?>
    [/PHP]

    Now if a user press submit the form goes to if (isset($_POST['name'])) {

    But there is nothing filled in, Can i stop that there is nothing filled in and that a user needs to put something in the field?

    Thanks in advance.
  • vssp
    Contributor
    • Jul 2006
    • 268

    #2
    Sorry I am not clear . Are you enter any values in html form ?
    if you submit blank value ,its goes to isset($_POST) value ?

    Comment

    • code green
      Recognized Expert Top Contributor
      • Mar 2007
      • 1726

      #3
      If the form has submitted correctly then 'name' will always be set. You need to use
      Code:
       if (!empty($_POST['name']))
      and have the script recall the form again if 'name' is empty with
      Code:
      include 'Your Form'
      or
      Code:
      header(Location:'url address')

      Comment

      • Motoma
        Recognized Expert Specialist
        • Jan 2007
        • 3236

        #4
        Try print_r($_POST) ; to see what you are actually getting from the form.

        Comment

        • Redapple
          New Member
          • Mar 2007
          • 5

          #5
          Yes vssp, The html value goes to the if($_post. How can i solve that?

          Comment

          • code green
            Recognized Expert Top Contributor
            • Mar 2007
            • 1726

            #6
            Yes vssp, The html value goes to the if($_post
            No! it obviously doesn't.. Look at Motoma's post

            Comment

            Working...