Jump to content

Getting A File Name To Open


ka3pmw

Recommended Posts

I used to know how to do this, then I had a stroke. I am using an html input tag to get a file name and I want to pass that filename to a php routine. Please help this ole man.

 

Here is what I have:

 

<?php
if (isset($_POST['logbtn']))
{
$data = $_POST['logname'];
$file = $mylog;
$fh = fopen($file, "w") or die("Couldn't open $file for login!");

/* write other data here */

fclose($fh);
}
?>
</head>
<body>
 <form id="setupForm" name="setupForm" method="post" action="">

  <p><font size = "5">
	<label><strong>What do you wish to call this file?  </strong></label>
<input name="mylog" type="text" value="mylog" size="15" maxlength="15">
 </font></p>
 </form>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/270369-getting-a-file-name-to-open/
Share on other sites

I am getting the following error:

 

Notice: Undefined variable: mylog in C:\xampp\htdocs\logger\mysetup.php on line 5

 

Warning: fopen(): Filename cannot be empty in C:\xampp\htdocs\logger\mysetup.php on line 6

Couldn't open for login!

 

My code is:

 

<?php

if (isset($_POST['logbtn']))

{

$data = $_POST['mylog'];

$file = $mylog;

$fh = fopen($file, "w") or die("Couldn't open $file for login!");

 

 

/* write other data here */

 

fclose($fh);

}

?>

< html>

< body>

<form id="setupForm" name="setupForm" method="post" action="">

 

<p><font size = "5">

<label><strong>What do you wish to call this file? </strong></label>

<input name="mylog" type="text" value="mylog" size="15" maxlength="15">

</font></p>

</form>

< /body>

< /html>

 

I did change the "logname"

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.