tags:

views:

35

answers:

3

I've looked all over the net for probably a common and simple task and have found nothing but deadends. I'm trying to grab a response from my own html page that uses POST to submit data to a website so I can parse it and show/print the parsed text on the same html page. Here's what my html page looks like:

    <html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<form 
 method="post" 
 action="http://somesite.com" 
 enctype="multipart/form-data">
 <input type="hidden" name="function"  value="login">
 <input type="text"   name="username"  value="client">
 <input type="text"   name="password"  value="qwerty">
 <input type="file"   name="upload">
 <input type="text"   name="upload_to"   value="0">
 <input type="text"   name="upload_type" value="0">
 <input type="submit" value="Send">
</form>
</head><body></body></html>
A: 

Just do <?php echo $_POST['username']; ?>

Skilldrick
A: 

use the Predefined Variable $_POST

<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<form 
 method="post" 
 action="" 
 enctype="multipart/form-data">
 <input type="hidden" name="function"  value="login">
 <input type="text"   name="username"  value="client">
 <input type="text"   name="password"  value="qwerty">
 <input type="file"   name="upload">
 <input type="text"   name="upload_to"   value="0">
 <input type="text"   name="upload_type" value="0">
 <input type="submit" value="Send">
</form>
<?php if("Send" == $_POST['submit']){ var_dump($_POST); } ?>
</head><body></body></html>
Hannes
A: 

Would recommend that you read on http://www.php.net/form as it contains both examples and good comments. As your calling the fields username and password I guess you might also be looking at database connections, be very careful of SQL injections (http://php.net/manual/en/security.database.sql-injection.php).

Sven Almgren