Jump to content

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>

Edited by Zane
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"

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.