<?php
//$tempfile="atextfile.txt";
//$fileprocess=fopen($tempfile,"w+");
//$temptext = "hello world!";
//fwrite($fileprocess,$temptext);
//fclose($fileprocess);
?>


<?php
if(isset($_POST['submit'])) {
$url= $_POST['url'];
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<?php include_once("title.php"); ?>

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">

<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css">

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" ></script>
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body style="background-image:('b.jpg')">
    <h1 style="text-align:center">Web Links Bookmarking Application</h1>
<hr/>
<form class="form-horizontal" method="post" action="">
<fieldset>

<!-- Text input-->
<div class="form-group">
  <label class="col-md-4 control-label" for="textinput">Enter Url</label>  
  <div class="col-md-4">
  <input id="textinput" name="url" id="url" type="text" placeholder="placeholder" class="form-control input-md">
 
  </div>
</div>

<!-- Button -->
<div class="form-group"> 
<label class="col-md-4 control-label" for="textinput"> </label> 
<div class="col-md-4">
<input class="btn btn-primary btn-block" type="submit" name="submit" value="submit">  </div>
</div>
</fieldset>
</form>

    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
   
  </body>
</html>

<?php
$file = 'atextfile.html';
// Open the file to get existing content
$current = file_get_contents($file);
// Append a new person to the file
//$current .= "<a href='$url'>$url</a> <br/>";

$current .= "<a href='$url' onclick='window.open(this.href); return false;' onkeypress='window.open(this.href); return false;'>$url</a><br/>";
//<a href=""></a>
// Write the contents back to the file
file_put_contents($file, $current);
?>


<?php
$fh = fopen('atextfile.html','r');
while ($line = fgets($fh)) {
echo '<p style="text-align: center;">';
echo($line);
echo '</p>';
}
fclose($fh);
?>
