This is a simplified version of what I really want, but it doesn't work either. I'm just trying a simple submit to self, but it never passes the 'if' test.

<?
if ($create_form) {

echo "thanks!, you submitted $num";

}
else {
?>
<form method="post" action="<? echo $_SERVER['PHP_SELF'] ?>">
<input type="HIDDEN" name="num" value="1">
<input type="Submit" name="create_form" value="Edit Story">
<?
}
?>

The "action="<? echo $_SERVER['PHP_SELF'] ?>" is because register globals is off, and this is the only way I can get it to work. Viewing the source, it seems to work just fine, as the HTML source is "action="/admin/test.php"" which is the correct page.

I've done searches but can't find what will help me.

    try this.

    if(isset($_GET['create_form'])){
    echo "thanks!, you submitted $num";
    }

    im presuming this is running on PHP 4.1.2 or Greater.

      hrm, still not working.

      and yes, this is 4.2.1

        <?
        $file=$SERVER['PHP_SELF'];
        if (isset($
        GET['create_form'])) {
        echo "thanks!, you submitted $num";
        }
        else {
        echo "
        <form method='post' action='$file'>
        <input type='HIDDEN' name='num' value='1'>
        <input type='Submit' name='create_form' value='Edit Story'>";
        }
        ?>

        try that

          ahhh
          this should work.

          <?
          $file=$SERVER['PHP_SELF'];
          if (isset($
          GET['create_form'])) {
          echo "thanks!, you submitted $num";
          }
          else {
          echo "
          <form method='GET' action='$file'>
          <input type='HIDDEN' name='num' value='1'>
          <input type='Submit' name='create_form' value='Edit Story'>";
          }
          ?>

          you had METHOD='post'
          didnt see it the first time round. 🙂

            Ahh, it was GET, not POST. I was sure it was supposed to have been POST, since I was POSTing to something. Guess I have some reading to do.

              Well, using GET works nicely here. However, as I just learned, using GET places all the variables in the URL. My real page is going to be posting news to the front page, which would be pretty large at times. Is there any way to make POST work when submitting to $PHP_SELF? I was hoping to leave all adding, editing and deleting to one page for neatness if at all possible.

                Write a Reply...