Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    May 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Submitting php forms without reloading the page

    Hi everyone , i have an html with several forms and a php where i compare the the submited for and perform file execution. What i need is that i want my forms work without refreshing the page. I read that there should be used AJAX but i really don't know it and need your help.

    this is my test.html
    Code:
    <html>
    <body>
    <form action="phpform.php" method="post" target="_self">  
      <input name="submit" type="submit" value="W" />
    </form>
    <form action="phpform.php" method="post" target="_self">
      <input type="submit" name="submit2" value="U" />
    </form>
    <form action="phpform.php" method="post" target="_self">
      <input type="submit" name="submit3" value="Q" onmouseover/>
    </form>
    <form action="phpform.php" method="post" target="_self">
      <input type="submit" name="submit4" value="S" />
    </form>
    <form action="phpform.php" method="post" target="_self">
      <input type="submit" name="submit5" value="B" />  
    </form>
    </body>
    </html>
    and this is my phpform.php
    PHP Code:
    <?php
      
    if(isset($_POST['submit']))
      {
      echo 
    exec('test.bat');
      echo 
    "<meta http-equiv=refresh content=\"0; URL=form.html\">";
      }
      elseif(isset(
    $_POST['submit2']))
      {
      echo 
    exec('test2.bat');
      echo 
    "<meta http-equiv=refresh content=\"0; URL=form.html\">";
      }
      elseif(isset(
    $_POST['submit3']))
      {
      echo 
    exec('test3.bat');
      echo 
    "<meta http-equiv=refresh content=\"0; URL=form.html\">";
      }
      elseif(isset(
    $_POST['submit4']))
      {
      echo 
    exec('test4.bat');
      echo 
    "<meta http-equiv=refresh content=\"0; URL=form.html\">";
      }
      elseif(isset(
    $_POST['submit5']))
     {
      echo 
    exec('test5.bat');
      echo 
    "<meta http-equiv=refresh content=\"0; URL=form.html\">";
      }
      else{
       echo 
    "end";
           }
    ?>
    Any help would be appreciated , thanks

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    Have you gone through any tutorial on Ajax?

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,189
    Thanks
    10
    Thanked 569 Times in 550 Posts
    why so many forms? you only need one per url.

    also, you don't need ajax for your task. just set the target of the form to the name of a hidden iframe.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/1/19) IE7:0.2, IE8:6.7, IE11:7.4, IE9:3.8, IE10:4.4, FF:18.3, CH:43.6, SF:7.8, MOBILE:27.5


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •