<html>
<head>
<title>Get URL</title>
<style type="text/css">
<!--
#Layer3 {
position:relative;
left:20px;
top:15px;
width:650px;
height:240px;
}
.style4 {
font-family: Arial, Helvetica, sans-serif;
font-size: 16px;
font-weight: bold;
}
-->
</style>
</head>
<body bgcolor="lightyellow">
<?php
error_reporting(E_ALL & ~E_NOTICE);
// include "get.php"; //include get functions
include "/home/sultans/web/php/demo/7adv/get.php"; //to make it work with PHP*Tester
display();
//------------------------------------------------------------------------------------------------------
function display()
{
$url = $_POST['url'];
$param = $_POST['param'];
$mthd = $_POST['mthd'];
$hdrs = $_POST['hdrs'];
$mthd = strtoupper($mthd);
$method = ($mthd == 'POST') ? 'POST' : 'GET'; #if not POST then all else is GET
// $page = getURL($url); #Simple GET with no parameters/headers
$page = getURL2($url,$method,$param,$hdrs); #complex GET/POST with parameters & headers
?>
<div id='Layer3'>
<form METHOD=post ACTION=getURL2.php>
<fieldset style='width:1025'>
<legend>Get a URL</legend>
<table>
<tr>
<td> URL <i>(required)</i>
<span style="cursor:pointer; color:red"
title="Examples:
https://www.google.com
https://workshop.sps.nyu.edu/~sultans/
https://workshop.sps.nyu.edu/~sultans/util/form/formTest.cgi">
<b>[?]</b>
</span>
<td><input type='text' name='url' size='50' value=<?php echo $url ?> >
<span style=<font-size:9px'>(eg: https://workshop.sps.nyu.edu/~sultans/util/form/HTTPrequest.php)</span>
<tr>
<td> Method <i>(optional) </td>
<td><input type='text' name='mthd' size='50' value=<?php echo $mthd ?> > (GET or POST)
<tr>
<td> Parameters <i>(optional) </td>
<td><input type='text' name='param' size='50' value=<?php echo $param ?> > (encoded: param1=value1¶m2=value2)
<tr>
<td valign=top> Headers <i>(optional)</i>
<span style="cursor:pointer; color:red"
title="Examples:
Connection: keep-alive
Cookie: name=Sam%20Sultan; id=1234
Accept: text/html
Cache-control: no-cache
Host: www.google.com">
<b>[?]</b></td>
<span>
<td valign=top><textarea name='hdrs' cols='50' rows='3' ><?php echo $hdrs ?></textarea> <span style='vertical-align:top'>(example: Cookie: cookie1=value; cookie2=... )</span>
<tr>
<td></td>
<td><input type='submit' value=' Retrieve ' />
</tr>
</table>
</fieldset>
</form>
</div>
<hr />
<?PHP echo $page; ?>
</div>
<?php
}
?>
<?php include "../include.php"; ?> <!-- hyperlink to see the code -->
</body>
</html>