Post method from PHP script

Discussion in 'PHP' started by ker, Apr 9, 2011.

  1. #1
    Hello!
    Is there any function for posting from PHP sctipt?
    Instead of
    <form name="input" method="post" action="login.php" >
    	<input type="text" name="user" />
    	<input type="password" name="pass" />
    	<input type="submit" value="Login" />
    </form>
    HTML:
    I want that PHP script does that automatic, something like
    <?php post("login.php", "?user=$username&pass=$password"); ?>
    PHP:
    Thanks
     
    ker, Apr 9, 2011 IP
  2. rainborick

    rainborick Well-Known Member

    Messages:
    424
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    120
    #2
    rainborick, Apr 9, 2011 IP
  3. michalka

    michalka Peon

    Messages:
    79
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Just create a php function post($page, $arg); and add the below code
    
    function post($post,$arg){
    echo "<form method='post' action='$page'>";
    for($i=0;$i<count($arg);$i++){
       echo "<input type='text' name='$arg[$i]' value=''>";
    }
      echo " </form>";
    }
    
    Code (markup):
    Note: $arg should be list of arguments in a array
     
    michalka, Apr 9, 2011 IP
  4. ker

    ker Peon

    Messages:
    97
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    0
    #4
    I couldn't find any helpful methods.
    ________________________________________________________________________________________
    No.
    ________________________________________________________________________________________
    This will only generate HTML code, that's not what I wanted.
    ________________________________________________________________________________________
    Thanks anyway...
     
    ker, Apr 10, 2011 IP